#include <uuid/uuid.h>
string generateUUID()
{
#if 0
uuid_t uu;
uuid_generate(uu);
char buffer[32] = {0};
uuid_unparse(uu, buffer);
//cout << buffer << endl;
return string(buffer);
#else
ifstream ifs;
ifs.open("/proc/sys/kernel/random/uuid", std::ifstream::in);
string uuid;
getline(ifs, uuid);
//cout << "in " << __func__ << endl;
//cout << uuid << endl;
ifs.close();
return uuid;
#endif
}
generate UUID using uuid library or system uuid
最新推荐文章于 2024-07-14 11:52:40 发布