2016-01-07 08:14:33 +00:00
|
|
|
#pragma once
|
2012-06-18 10:13:51 +00:00
|
|
|
|
|
|
|
#include <nall/random.hpp>
|
|
|
|
#include <nall/string.hpp>
|
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
|
|
|
//generate unique GUID
|
2015-12-14 09:41:06 +00:00
|
|
|
inline auto guid() -> string {
|
2014-01-28 10:04:58 +00:00
|
|
|
LinearFeedbackShiftRegisterGenerator lfsr;
|
2013-03-15 13:11:33 +00:00
|
|
|
lfsr.seed(time(nullptr));
|
2015-12-14 09:41:06 +00:00
|
|
|
for(uint n = 0; n < 256; n++) lfsr();
|
2012-06-18 10:13:51 +00:00
|
|
|
|
|
|
|
string output;
|
2015-12-14 09:41:06 +00:00
|
|
|
for(uint n = 0; n < 4; n++) output.append(hex(lfsr(), 2L));
|
2012-06-18 10:13:51 +00:00
|
|
|
output.append("-");
|
2015-12-14 09:41:06 +00:00
|
|
|
for(uint n = 0; n < 2; n++) output.append(hex(lfsr(), 2L));
|
2012-06-18 10:13:51 +00:00
|
|
|
output.append("-");
|
2015-12-14 09:41:06 +00:00
|
|
|
for(uint n = 0; n < 2; n++) output.append(hex(lfsr(), 2L));
|
2012-06-18 10:13:51 +00:00
|
|
|
output.append("-");
|
2015-12-14 09:41:06 +00:00
|
|
|
for(uint n = 0; n < 2; n++) output.append(hex(lfsr(), 2L));
|
2012-06-18 10:13:51 +00:00
|
|
|
output.append("-");
|
2015-12-14 09:41:06 +00:00
|
|
|
for(uint n = 0; n < 6; n++) output.append(hex(lfsr(), 2L));
|
2012-06-18 10:13:51 +00:00
|
|
|
return {"{", output, "}"};
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|