[+] IRandomDevice::NextUUID
This commit is contained in:
parent
b3557ed938
commit
063aa5c548
@ -26,6 +26,7 @@ namespace Aurora::RNG
|
||||
virtual double NextDecimal() = 0;
|
||||
virtual double NextNumber(double dMin, double dMax) = 0;
|
||||
virtual AuUInt32 NextIndex(AuUInt32 uCount /* = max + 1*/) = 0;
|
||||
virtual uuids::uuid NextUUID() = 0;
|
||||
|
||||
virtual Memory::MemoryViewRead ToSeed() = 0;
|
||||
|
||||
|
@ -305,6 +305,20 @@ namespace Aurora::RNG
|
||||
return this->UniformFloatInRange(kDblEpsilon, dRange + kDblEpsilon) + dMin - kDblEpsilon;
|
||||
}
|
||||
|
||||
uuids::uuid RandomDevice::NextUUID()
|
||||
{
|
||||
AuUInt8 bytes[16];
|
||||
this->Read(bytes);
|
||||
|
||||
bytes[8] &= 0xBF;
|
||||
bytes[8] |= 0x80;
|
||||
|
||||
bytes[6] &= 0x4F;
|
||||
bytes[6] |= 0x40;
|
||||
|
||||
return uuids::uuid { bytes, bytes + 16 };
|
||||
}
|
||||
|
||||
AuMemoryViewRead RandomDevice::ToSeed()
|
||||
{
|
||||
if (this->def_.bSecure)
|
||||
|
@ -29,7 +29,7 @@ namespace Aurora::RNG
|
||||
double NextDecimal() override;
|
||||
double NextNumber(double dMin, double dMax) override;
|
||||
AuUInt32 NextIndex(AuUInt32 uCount /* = max + 1*/) override;
|
||||
|
||||
uuids::uuid NextUUID() override;
|
||||
AuMemoryViewRead ToSeed() override;
|
||||
|
||||
void Init(const RandomDef &def);
|
||||
|
Loading…
Reference in New Issue
Block a user