Skip to content

Instantly share code, notes, and snippets.

@AWRyder
Last active March 22, 2019 15:06
Show Gist options
  • Save AWRyder/57987e862f83130eef98f3b299334186 to your computer and use it in GitHub Desktop.
Save AWRyder/57987e862f83130eef98f3b299334186 to your computer and use it in GitHub Desktop.
import sys
import hashlib
import requests
hash_object = hashlib.sha1(sys.argv[1].encode('utf-8'))
hex_dig = hash_object.hexdigest()
print('Hex: '+hex_dig)
print('First 5 chars: '+hex_dig[:5])
response = requests.get('https://api.pwnedpasswords.com/range/'+hex_dig[:5])
response_text = response.text
if response.status_code != 200:
print(response_text)
exit(0)
response_text_lines = response_text.splitlines(False)
for line in response_text_lines:
word = line.split(':')[0]
quantity = line.split(':')[1]
if (hex_dig[:5]+word).upper() == hex_dig.upper():
print("Password insecure. Found "+quantity+" times on leaks.")
exit(0)
print("Password is safe. Nothing was found.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment