Created
October 19, 2018 03:57
-
-
Save myersjustinc/058dedde719455be1fafdd433b3a71f2 to your computer and use it in GitHub Desktop.
Render QR codes to set up TOTP secrets
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
const qrcode = require('qrcode-terminal'); | |
[ | |
// {issuer: '', user: '', secret: ''}, // TODO: Fill these in. | |
].forEach(function(keyInfo) { | |
const issuer = encodeURIComponent(keyInfo.issuer); | |
const user = encodeURIComponent(keyInfo.user); | |
const secret = keyInfo.secret.replace(/ /g, ''); | |
const url = ( | |
`otpauth://totp/${issuer}:${user}?secret=${secret}&issuer=${issuer}`); | |
qrcode.generate(url, function(code) { | |
console.log('\n\n\n\n\n'); | |
console.log(`${keyInfo.issuer} (${keyInfo.user}):`); | |
console.log(code); | |
console.log('\n\n\n\n\n'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment