Last active
February 26, 2021 11:28
-
-
Save tomasbasham/6628f7a70bdb5a2ffc4e021bfb566778 to your computer and use it in GitHub Desktop.
Revisions
-
tomasbasham revised this gist
Feb 26, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,8 +5,8 @@ hashed_password = Digest::SHA1.hexdigest password # SHA1 hashes will be 40 characters long prefix = hashed_password[0, 5].to_s.upcase # Get the first 5 characters suffix = hashed_password[5..-1].to_s.upcase # Get the remaining 35 characters puts "checking pwnedpasswords.com for: #{password}" uri = URI("https://api.pwnedpasswords.com/range/#{prefix}") -
tomasbasham revised this gist
Feb 26, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ password = ARGV[0] || 'Password' hashed_password = Digest::SHA1.hexdigest password # SHA1 hashes will be 40 characters long prefix = hashed_password[0, 5].to_s.upcase suffix = hashed_password[5..-1].to_s.upcase -
tomasbasham created this gist
Feb 26, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ require 'digest' require 'net/http' password = ARGV[0] || 'Password' hashed_password = Digest::SHA1.hexdigest password # SHA1 hases will be 40 characters long prefix = hashed_password[0, 5].to_s.upcase suffix = hashed_password[5..-1].to_s.upcase puts "checking pwnedpasswords.com for: #{password}" uri = URI("https://api.pwnedpasswords.com/range/#{prefix}") res = Net::HTTP.get(uri) puts res.split("\n").find { |pwned_password| pwned_password.start_with? suffix }