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

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}]'

Contributing

Check the source code and issues from this repository, and should anything interesting pop out feel free to open a pull request. Before your changes will be merged make sure that Travis CI pipeline is green and code coverage is on acceptable level. GitHub takes care of these eventually but to save time always consider running the tests locally before pushing.

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.5.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pwnedapi-0.5.0-py2.py3-none-any.whl (6.2 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: pwnedapi-0.5.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6

File hashes

Hashes for pwnedapi-0.5.0.tar.gz
Algorithm Hash digest
SHA256 5078cc605ce50ee3945fa6a5cecad28ad46d600b52abcbdebf98492a88be133b
MD5 37ef4946427a6ac3b4e775e1b417012b
BLAKE2b-256 a2473bbf3dbf2488d35092fdea76ea0a7473957cacb6a646612f99a7bcb64ef8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pwnedapi-0.5.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6

File hashes

Hashes for pwnedapi-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b2ff93d39ea2f0660a34f65b35a4de0981065cf4f069b3d261fac6cad87b3519
MD5 908d4dac42799a6bd6ef2540d0688ecf
BLAKE2b-256 e2efe1960a48ca3645246b49dd540e681576fa69da3863f5f2af3ce855f676ad

See more details on using hashes here.

Supported by

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