Last active
April 8, 2018 02:48
-
-
Save anoopemacs/78b1df1b516d9ad787944de0e90a398c to your computer and use it in GitHub Desktop.
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
| // The resulting string will be twice as long as the random bytes you generate; | |
| // each byte encoded to hex is 2 characters. 20 bytes will be 40 characters of hex. | |
| require('crypto').randomBytes(48, function(err, buffer) { | |
| var token = buffer.toString('hex'); | |
| }); | |
| // synchronous version | |
| var token = require('crypto').randomBytes(64).toString('hex'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment