Skip to content

Instantly share code, notes, and snippets.

@jikkujose
Created August 5, 2021 13:02
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 jikkujose/66ccbf7c965019e9a4f3f898734db081 to your computer and use it in GitHub Desktop.
Save jikkujose/66ccbf7c965019e9a4f3f898734db081 to your computer and use it in GitHub Desktop.
Generate TOTP codes from command line
require "rotp"
key = STDIN.tty? ? ARGV[0] : $stdin.read
if key.nil?
puts "Error: No key found in stdin or as flag"
exit
end
puts ROTP::TOTP.new(key.strip, issuer: "Unnamed Service").now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment