Pwned Passwords check (offline)
Project description
Pwned Passwords check (offline)
Quickstart
- Download "SHA-1" version "(ordered by hash)" from https://haveibeenpwned.com/Passwords
- Extract file, yielding
pwned-passwords-sha1-ordered-by-hash-v7.txt
(for current version 7)
Simple usage
from pwnedpasswords_offline import PwnedPasswordsOfflineChecker
if PwnedPasswordsOfflineChecker("data/pwned-passwords-sha1-ordered-by-hash-v7.txt").lookup_raw_password("Password1!"):
print("Pwned!")
Batch usage
You can also pre-open the database file, especially if you're checking multiple passwords in bulk:
from pwnedpasswords_offline import PwnedPasswordsOfflineChecker
checker = PwnedPasswordsOfflineChecker("data/pwned-passwords-sha1-ordered-by-hash-v7.txt")
checker.open()
for password in ["Password1!", "correct horse battery staple", "actress stapling driver placidly swivel doorknob"]:
if checker.lookup_raw_password(password):
print(f"'{password}' is pwned!")
checker.close()
You should not forget to call .close()
after you're done.
As context manager
You can use the object as a context manager to automatically open and close it:
from pwnedpasswords_offline import PwnedPasswordsOfflineChecker
with PwnedPasswordsOfflineChecker("data/pwned-passwords-sha1-ordered-by-hash-v7.txt") as checker:
for password in ["Password1!", "correct horse battery staple", "actress stapling driver placidly swivel doorknob"]:
if checker.lookup_raw_password(password):
print(f"'{password}' is pwned!")
Check hash directly
Instead of calling .lookup_raw_password()
you can call .lookup_hash()
if you already have the plain SHA-1 hash:
from pwnedpasswords_offline import PwnedPasswordsOfflineChecker
if PwnedPasswordsOfflineChecker("data/pwned-passwords-sha1-ordered-by-hash-v7.txt").lookup_hash("32CA9FD4B3F319419F2EA6F883BF45686089498D"):
print("Pwned!")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for pwnedpasswords-offline-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 394e57228b883b0664f969e4daea180777ffa231b6bc14d577ae5c7d6276ff5a |
|
MD5 | a41511bc2549d2669dd2c4077d0bea3c |
|
BLAKE2b-256 | 5ead50c0b7d3321cea1c4a6c284e33c2a8dc7532b6de745056a36b95df0ac711 |
Close
Hashes for pwnedpasswords_offline-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21f1190b46528c543427f11752332634d68dedb8c8de3f0fe13adda2f1ccbb61 |
|
MD5 | 5fa6813c0a550b350bda71383dba6237 |
|
BLAKE2b-256 | c2cb0ab6e6f90663cb4c010d13df6feb32bc09e7700cfc35cdb8fb9a29f19624 |