Skip to content

Instantly share code, notes, and snippets.

@nof
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nof/b2511e5aae9fe0ab41a9 to your computer and use it in GitHub Desktop.
Save nof/b2511e5aae9fe0ab41a9 to your computer and use it in GitHub Desktop.
require 'uri'
require 'rotp'
require 'rqrcode_png'
key = ROTP::Base32.random_base32
totp = ROTP::TOTP.new(key)
uri = totp.provisioning_uri('hoge@hoge.com')
puts "key:#{key} uri:#{uri}"
qr = RQRCode::QRCode.new(uri, size:8)
png = qr.to_img
png.resize(128, 128).save('qr.png')
require 'rotp'
key = 'boqgsqvnmakpldl6'
totp = ROTP::TOTP.new(key)
puts totp.now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment