Skip to content

Instantly share code, notes, and snippets.

@rubys
Created March 13, 2016 11:59
Show Gist options
  • Save rubys/38d47640e80af06d18bf to your computer and use it in GitHub Desktop.
Save rubys/38d47640e80af06d18bf to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'otp' # gem install ruby-otp
def OTP.md5(sequence, seed, password=nil)
if password == nil
begin
print "password: "
system 'stty -echo -icanon'
password = $stdin.gets
password.chomp! if password
ensure
system 'stty echo icanon'
print "\r"
end
end
if password.size < 10
joined = seed + password
password = joined[-10..-1]
seed = joined[0...-10]
end
OTP.new(sequence.to_i, seed, password, 'md5')
end
if __FILE__ == $0
puts OTP.md5(*ARGV[0..1])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment