Created
August 24, 2013 13:04
-
-
Save haf/6328013 to your computer and use it in GitHub Desktop.
Answer a security question!
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
require 'openssl' | |
require 'base64' | |
unless ARGV[0] && ARGV[1] | |
$stderr.puts 'you need to provide the question as the first argument' | |
$stderr.puts 'you need to provide the password as the second argument' | |
$stderr.puts 'usage: ./md5question.rb <question> <password> [ base64 | hex ]' | |
exit -1 | |
end | |
MODE = ARGV[2] || 'base64' | |
hasher = OpenSSL::Digest::MD5.new | |
# calculate security question: md5(concat(security q as string, password)) | |
puts case MODE | |
when 'base64' | |
Base64.encode64(hasher.digest(ARGV[0] + ARGV[1])) | |
when 'hex' | |
hasher.hexdigest(ARGV[0] + ARGV[1]) | |
end | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment