In this question Erik needs to generate a secure random token in Node.js. There\'s the method crypto.randomBytes that generates a random Buffer. However, the ba
crypto.randomBytes
Try crypto.randomBytes():
require('crypto').randomBytes(48, function(err, buffer) { var token = buffer.toString('hex'); });
The 'hex' encoding works in node v0.6.x or newer.