Created
July 23, 2019 19:21
-
-
Save bhubr/b0432133c612b175d97c1d02a0731fe9 to your computer and use it in GitHub Desktop.
Generate 64-character long hexadecimal token with Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
const util = require('util'); | |
const randomBytesAsync = util.promisify(crypto.randomBytes); | |
const generateToken = async () => { | |
const buf = await randomBytesAsync(32); | |
return buf.toString('hex'); | |
}; | |
module.exports = generateToken; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment