Skip to content

Instantly share code, notes, and snippets.

@myersjustinc
Created October 19, 2018 03:57
Show Gist options
  • Save myersjustinc/058dedde719455be1fafdd433b3a71f2 to your computer and use it in GitHub Desktop.
Save myersjustinc/058dedde719455be1fafdd433b3a71f2 to your computer and use it in GitHub Desktop.
Render QR codes to set up TOTP secrets
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