Skip to content

Instantly share code, notes, and snippets.

@markbao
Created December 23, 2015 23:18
Show Gist options
  • Save markbao/94e445227bace89856de to your computer and use it in GitHub Desktop.
Save markbao/94e445227bace89856de to your computer and use it in GitHub Desktop.
Speakeasy Demo
var speakeasy = require("speakeasy")
// Generate a secret key of length 20
var secret = speakeasy.generate_key({length: 20})
console.log(secret.base32)
var qr = require('qr-js');
var authURL = 'otpauth://totp/SecretKey?secret=' + encodeURIComponent(secret.base32);
console.log(qr.toDataURL(authURL))
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