Created
July 11, 2019 19:16
-
-
Save jeffwilcox/e85481a47623be81e3184517cd51ab37 to your computer and use it in GitHub Desktop.
Generating a token in Node.js
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
// simple JavaScript (Node.js CLI) generating of a key and token | |
const crypto = require('crypto'); | |
const myKey = crypto.randomBytes(32).toString('base64'); | |
console.log('This is your key. Store is very securely, i.e. KeyVault:'); | |
console.log(myKey); | |
console.log(); | |
const sha1 = crypto.createHash('sha1'); | |
sha1.update(myKey); | |
const hashValue = sha1.digest('hex'); | |
console.log('This is your token. Share this value to enable the key:'); | |
console.log(hashValue); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment