Python Script: Password Check
- by Vince
-
in Blog
-
Hits: 2115
#!/usr/bin/python
import hashlib
import requests
import os
print
password = raw_input("[*] Enter password to check: ")
print
sha_1 = hashlib.sha1()
sha_1.update(password)
hashed = sha_1.hexdigest()
first_five = hashed[:5]
print "Checking against Pwned Passwords..."
print
host = "https://api.pwnedpasswords.com/range/" + first_five
remaining = hashed[5:40]
url = host
headers = {'User-Agent': 'Mozilla/5.0'}
html = requests.get(url, headers=headers).content
if remaining.upper() in html:
print("Bad Password!")
else:
print ("Good Password!")
print