First, start up node from a terminal. Then type the following:
This will simply
The result will be a secret token.
First, start up node from a terminal. Then execute the following line:
This file contains 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
require("crypto").randomBytes(64).toString("hex") |
Here's the same thing as an executable JavaScript file, which outputs the token as both hex and base64:
This file contains 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
#!/usr/local/bin/node | |
const tokenBytes = require("crypto").randomBytes(64); | |
console.log({ | |
hex: tokenBytes.toString("hex"), | |
base64: tokenBytes.toString("base64"), | |
}); |