Remove unnecessary dependency on pyca
Python’s built-in hashlib is capable of calculating SHA1. There’s no need to depend on a third party library which may or may not be available.
This commit is contained in:
parent
80f2da2f03
commit
19fd5102cb
14
pwned.py
14
pwned.py
@ -1,18 +1,10 @@
|
||||
import hashlib
|
||||
import requests
|
||||
import cryptography
|
||||
from base64 import b16encode
|
||||
import sys
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
|
||||
def hash_password_sha1_hex(pwd):
|
||||
digest = hashes.Hash(hashes.SHA1(), backend=default_backend())
|
||||
digest.update(pwd.encode('ASCII'))
|
||||
sha1 = b16encode(digest.finalize()).decode('ASCII')
|
||||
return sha1
|
||||
|
||||
def lookup_pwned_api(pwd):
|
||||
sha1pwd = hash_password_sha1_hex(pwd)
|
||||
sha1pwd = hashlib.sha1(pwd.encode('ascii')).hexdigest().upper()
|
||||
head = sha1pwd[:5]
|
||||
tail = sha1pwd[5:]
|
||||
|
||||
@ -32,4 +24,4 @@ if (api_return):
|
||||
else:
|
||||
print (sys.argv[1], "was not found")
|
||||
|
||||
exit()
|
||||
exit()
|
||||
|
Loading…
Reference in New Issue
Block a user