Skip to content

Instantly share code, notes, and snippets.

@yan12125
Created July 10, 2017 16:48
Show Gist options
  • Save yan12125/3dcebd58a4c789f387c523fefa6eb5d9 to your computer and use it in GitHub Desktop.
Save yan12125/3dcebd58a4c789f387c523fefa6eb5d9 to your computer and use it in GitHub Desktop.
TOTP with Node.js
'use strict';
var notp = require('notp'),
thirty_two = require('thirty-two');
var stdin = process.openStdin();
console.log("Entery TOTP key:");
stdin.addListener("data", function(d) {
var key = d.toString().trim().replace(/ /g, '');
var totp_token = notp.totp.gen(thirty_two.decode(key));
console.log("TOTP token: " + totp_token);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment