Every line of 'crypto randombytes' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
11 export function bytes(length: number): Buffer 12 { 13 return randomBytes(length); 14 }
10 function randomBytes(size) { 11 var bytes = new Array(size); 12 var r; 13 14 for (var i = 0, r; i < size; i++) { 15 if ((i & 0x03) == 0) r = Math.random() * 0x100000000; 16 bytes[i] = (r >>> ((i & 0x03) << 3)) & 0xff; 17 } 18 19 return bytes; 20 }
3 export function random(): string { 4 return randomBytes(16).toString('hex'); 5 }
49 function random () { 50 return crypto.randomBytes(20).toString('hex') 51 }
108 randomBytes(length: number): Promise { 109 return this.bwCrypto.randomBytes(length); 110 }
55 static generateRandom(length = 128, wordArray = false) { 56 let random = CryptoJS.lib.WordArray.random(length/8); 57 return (wordArray) ? random : random.toString(); 58 }
16 function random(l) { 17 var ary = [] 18 while(l --) ary.push(crypto.randomBytes(1024)) 19 return ary 20 }
22 exports.randomBytes = function randomBytes(size) { 23 const data = new Uint8Array(size); 24 crypto.getRandomValues(data); 25 return Buffer.from(data.buffer); 26 };
190 function randomBytes (n) { 191 var buf = bufferAlloc(n) 192 sodium.randombytes_buf(buf) 193 return buf 194 }
29 function random(qty) { 30 return crypto.randomBytes(qty); 31 }