2012-06-18 10:13:51 +00:00
|
|
|
#ifndef NALL_WINDOWS_GUID_HPP
|
|
|
|
#define NALL_WINDOWS_GUID_HPP
|
|
|
|
|
|
|
|
#include <nall/random.hpp>
|
|
|
|
#include <nall/string.hpp>
|
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
|
|
|
//generate unique GUID
|
|
|
|
inline string guid() {
|
2014-01-28 10:04:58 +00:00
|
|
|
LinearFeedbackShiftRegisterGenerator lfsr;
|
2013-03-15 13:11:33 +00:00
|
|
|
lfsr.seed(time(nullptr));
|
2012-06-18 10:13:51 +00:00
|
|
|
for(unsigned n = 0; n < 256; n++) lfsr();
|
|
|
|
|
|
|
|
string output;
|
2015-08-02 06:23:13 +00:00
|
|
|
for(unsigned n = 0; n < 4; n++) output.append(hex(lfsr(), 2L));
|
2012-06-18 10:13:51 +00:00
|
|
|
output.append("-");
|
2015-08-02 06:23:13 +00:00
|
|
|
for(unsigned n = 0; n < 2; n++) output.append(hex(lfsr(), 2L));
|
2012-06-18 10:13:51 +00:00
|
|
|
output.append("-");
|
2015-08-02 06:23:13 +00:00
|
|
|
for(unsigned n = 0; n < 2; n++) output.append(hex(lfsr(), 2L));
|
2012-06-18 10:13:51 +00:00
|
|
|
output.append("-");
|
2015-08-02 06:23:13 +00:00
|
|
|
for(unsigned n = 0; n < 2; n++) output.append(hex(lfsr(), 2L));
|
2012-06-18 10:13:51 +00:00
|
|
|
output.append("-");
|
2015-08-02 06:23:13 +00:00
|
|
|
for(unsigned n = 0; n < 6; n++) output.append(hex(lfsr(), 2L));
|
2012-06-18 10:13:51 +00:00
|
|
|
return {"{", output, "}"};
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|