Skip to content

le717/pwned-passwords

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pwned-passwords

Pwned Passwords API wrapper

Purpose

This project provides a simple Python API around the Pwned Passwords API.

Usage

import pwned_passwords


# Check a password for pwned-ness
# password: bytes | str
result: pwned_passwords.PwnedResults = pwned_passwords.check("password")

# Check the results
print(result.is_pwned)  # bool
print(result.times_pwned)  # int

# options: pwned_passwords.PwnedOptions | None
result: pwned_passwords.PwnedResults = pwned_passwords.check(
    "password",
    options=pwned_passwords.PwnedOptions(
        add_padding=True,  # Pad the API response with empty records
        mode="ntlm",  # Get NTLM hashes instead of SHA-1
        get_hashes=True,  # By default, the response hashes are not provided
    ),
)

# Print all of the hashes
print(result.hashes)  # list[pwned_passwords.PwnedHash]

Note: NTLM hash support is dependent on platform support, with fallback support provided by pyspnego. It is recommended to stick with the SHA-1 hash default.

License

Pwned Passwords API, created and maintained at Have I Been Pwned.

Have I Been Pwned is not affiliated with nor endorses this project.

2023 MIT