Comment Comment by sehrope Hashing a value from Math.random() with a cryptographic hash (i.e. SHA256) doesn't make it cryptographically random[1].If you want a random string get one directly via crypto.randomBytes(...)[2]: const id = crypto.randomBytes(32).toString('hex'); [1]: https://github.com/bluzi/jsonstore/blob/87af0d3ef6bf11222b98...[2]: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes... parent sehrope 8 years ago
If you want a random string get one directly via crypto.randomBytes(...)[2]:
[1]: https://github.com/bluzi/jsonstore/blob/87af0d3ef6bf11222b98...[2]: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes...