Page MenuHomePhorge

uuid.cjs
No OneTemporary

Size
708 B
Referenced Files
None
Subscribers
None

uuid.cjs

function generateUUID() {
const bytes = Ant.Crypto.randomBytes(16);
bytes[6] = (bytes[6] & 0x0f) | 0x40;
bytes[8] = (bytes[8] & 0x3f) | 0x80;
const hex = function (i) {
const val = bytes[i];
const digits = '0123456789abcdef';
const hi = (val >> 4) & 0x0f;
const lo = val & 0x0f;
return digits[hi] + digits[lo];
};
return (
hex(0) +
hex(1) +
hex(2) +
hex(3) +
'-' +
hex(4) +
hex(5) +
'-' +
hex(6) +
hex(7) +
'-' +
hex(8) +
hex(9) +
'-' +
hex(10) +
hex(11) +
hex(12) +
hex(13) +
hex(14) +
hex(15)
);
}
console.log('builtin:', Ant.Crypto.randomUUID());
console.log('engine:', generateUUID());

File Metadata

Mime Type
text/plain
Expires
Sun, May 3, 7:52 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
524242
Default Alt Text
uuid.cjs (708 B)

Event Timeline