bluzi / jsonstore

:rocket: jsonstore offers a free and secured JSON-based cloud datastore for small projects | Inactive
https://www.jsonstore.io/
MIT License
2.03k stars 74 forks source link

Use crypto.randomBytes #5

Closed 94b1 closed 6 years ago

94b1 commented 6 years ago

Uses crypto.randomBytes for random seed.

Credit to sehrope

bluzi commented 6 years ago

Thanks! :)

jdmnd commented 6 years ago

Hashing a random string is no better than displaying the data itself. Why not just convert the Buffer to a string directly? e.g.

const hash = crypto.randomBytes(32).toString('hex');

Note that you only need to generate 32 bytes of random data, since hexadecimal characters each contain 4 bits (half a byte) of data. The result will always be 32 characters in length, regardless of zeroes in the result. Feel free to disregard this as yak shaving, but just wanted to let you know. :)