3 ms·
I do this in nodejs all the time for IDs: require(‘crypto’).randomBytes(15).toString(‘base64’) Is this bad practice? Can you say more about why?
by josephg 6y ago
I do this in nodejs all the time for IDs:
require(‘crypto’).randomBytes(15).toString(‘base64’)
Is this bad practice? Can you say more about why?
- cperciva 6y agoThat's only 120 bits of entropy, which means that you'll get a collision after generating ~ 2^60 IDs. Ok, maybe you're not worried about that scale; but I normally recommend 256-bit IDs in order to make sure that you don't need to worry about that possibility.