samedi 3 juillet 2021

What is a good way to generate a random 32 byte buffer in node js javascript

I'm attempting to create a random 32 byte buffer, here's what I have (not working):

let buf = Buffer.alloc(32).fill(0)
console.log('Buffer: ',buf)
buf.writeUInt16BE(Math.floor(Math.random() * 2147483647).toString(16),5)
console.log('Random Buffer: ',buf)

Does anyone know a good way to do this?




Aucun commentaire:

Enregistrer un commentaire