Skip to content

Instantly share code, notes, and snippets.

@codenoid
Forked from oprypin/check_passwords.cr
Created August 30, 2017 01:08
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 codenoid/5f59ddfc1f9326c3ce8ced4acc8e654c to your computer and use it in GitHub Desktop.
Save codenoid/5f59ddfc1f9326c3ce8ced4acc8e654c to your computer and use it in GitHub Desktop.
Check your passwords against https://haveibeenpwned.com/Passwords
# Check your passwords against https://haveibeenpwned.com/Passwords
# Usage:
# crystal run --release check_passwords.cr -- pwned-passwords*.txt
# Enter your passwords one per line, then press Return twice
require "digest/sha1"
my_passwords = Hash(String, String).new
until (line = gets || "").empty?
my_passwords[Digest::SHA1.hexdigest(line).upcase] = line
end
ARGV.each do |filename|
puts "----#{filename}----"
File.each_line(filename) do |line|
if my_passwords.has_key? line
puts my_passwords[line]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment