Created
December 23, 2015 23:18
-
-
Save markbao/94e445227bace89856de to your computer and use it in GitHub Desktop.
Speakeasy Demo
This file contains hidden or 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
var speakeasy = require("speakeasy") | |
// Generate a secret key of length 20 | |
var secret = speakeasy.generate_key({length: 20}) | |
console.log(secret.base32) |
This file contains hidden or 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
var qr = require('qr-js'); | |
var authURL = 'otpauth://totp/SecretKey?secret=' + encodeURIComponent(secret.base32); | |
console.log(qr.toDataURL(authURL)) |
This file contains hidden or 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
var token = speakeasy.time({ | |
key: secret.base32, | |
encoding: 'base32' | |
}); | |
console.log(token); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment