Skip to main content

Library for easily interfacing with Have I Been Pwned API v2.

Project description

pwnedapi (Have I Been Pwned)

Build Status codecov pipeline status coverage report

A small utility class to leverage Troy Hunt's Have I Been Pwned API v2 and the k-Anonymity model. Inspired by Phil Nash's Ruby gem pwned.

Installation

# From repository
pipenv install pwnedapi

# Locally after cloning
python setup.py install

Usage

In its simplest form you'll only need to use two methods. Will probably add more if and when the API grows.

>>> from pwnedapi import Password
>>> password = Password("mysupersecretpassword")
>>>
>>> if password.is_pwned():
...     print(f"Your password has been pwned {password.pwned_count} times.")
...
Your password has been pwned 2 times.
>>>

You can also scan a file of passwords, and export results in any format supported by the tablib library.

>>> from pwnedapi import Scanner
>>> scanner = Scanner()
>>> scanner.scan("passwords.txt")
>>> scanner.export_as("leaked.json")
>>> open("leaked.json").read()
'[{"Password": "dog", "Leak Count": 28348}, {"Password": "cat", "Leak Count": 26354}, {"Password": "somepass", "Leak Count": 657}]'

Support

This is my first official Python package so if something is off feel free to send a PR. :fist:

TODO

  • Add password change form validators to Django and Flask

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

pwnedapi-0.4.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

pwnedapi-0.4.0-py2.py3-none-any.whl (5.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pwnedapi-0.4.0.tar.gz.

File metadata

  • Download URL: pwnedapi-0.4.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pwnedapi-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ee3ebde1afc1269b9fa3868931c8159457dfd1f5f7ede802c0609b2c06ea4d7c
MD5 c2b5100e212198c32c223bf5da984ab8
BLAKE2b-256 c2e6f69c96e96020ce3504ffb4a5e2f491b55439d7f6d55521a8be3773b69545

See more details on using hashes here.

File details

Details for the file pwnedapi-0.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pwnedapi-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f266d8f4b26b076f5530c111d8800c8fe169f0b9c914dc8a700f6ff2d61594e4
MD5 7016b04448eb130ce94ad72f1735a224
BLAKE2b-256 1872dfe34bc6cfc6d69269f2ea69ff275b3fe7562735cc5db126d98a15c0021c

See more details on using hashes here.

Supported by

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