Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function uuid() {
const buf = randomBytes(16);
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
buf[6] = (buf[6] & 0x0f) | 0x40;
buf[8] = (buf[8] & 0x3f) | 0x80;
let i = 0;
return [
bth[buf[i++]],
bth[buf[i++]],
bth[buf[i++]],
bth[buf[i++]],
'-',
bth[buf[i++]],
bth[buf[i++]],
'-',
bth[buf[i++]],
export function createClientNonce(length: number = 32): string {
return Hashes.randomBytes(length).toString('hex');
}