Skip to main content

A Python wrapper for Troy Hunt's Pwned Passwords API.

Project description

Python Library and CLI for the Pwned Password v2 API

Version Python Versions

Installation

pwnedpasswords is available for download through the Python Package Index (PyPi). You can install it right away using pip.

pip install pwnedpasswords

Usage

import pwnedpasswords
password = pwnedpasswords.Password("testing 123")

pwnedpasswords will automatically check to see if your provided input looks like a SHA-1 hash. If it looks like plain text, it’ll automatically hash it before sending it to the Pwned Passwords API.

If you’d like to check an already hashed password before providing it as input, set the plain_text parameter when initializing the Password object. There’s not much value to doing this, since pwnedpasswords does this for your automatically, but it’s just a little extra control in case you’re extra paranoid.

password = pwnedpasswords.Password("b8dfb080bc33fb564249e34252bf143d88fc018f")

Likewise, if a password looks like a SHA-1 hash, but is actually a user-provided password, set plain_text to True.

password = pwnedpasswords.Password("1231231231231231231231231231231231231231", plain_text=True)

check

This is the preferred method to call the Pwned Passwords API. By default, the check method uses the https://api.pwnedpasswords.com/range/ endpoint.

password = pwnedpasswords.Password("username")
password.check()
# 8340

If you’d like to force pwnedpasswords to use the search endpoint instead (https://api.pwnedpasswords.com/pwnedpassword/), set the anonymous parameter to False.

password = pwnedpasswords.Password("password")
password.check(anonymous=False)
# 3303003

You might want to do this if you’d prefer faster response times, and aren’t that worried about leaking passwords you’re searching for over the network.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pwnedpasswords-0.1.13-py2.py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page