I need a random sequence of bytes for making a password hash. In Ruby, this would look like:
File.open("/dev/urandom").read(20).each_byte{|x| rand << sprintf("%02x",x)}
In Node.js, I can get a sequence of random bytes with:
var randomSource = RandBytes.urandom.getInstance();
var bytes = randomSource.getRandomBytesAsync(20);
But the problem is, how to convert these to a String?
Also, I need to have them wrapped in promisses. Would this work:
get_rand()
.then(function(bytes) {
authToken = bytes;
})