Skip to main content

Library for easily interfacing with Have I Been Pwned API v2

Project description

# `pwnedapi` (Have I Been Pwned)

[![Build Status](https://travis-ci.org/nikoheikkila/pwnedapi.svg?branch=master)](https://travis-ci.org/nikoheikkila/pwnedapi)

A small utility class to leverage Troy Hunt's [_Have I Been Pwned API v2_][hibp] and the _k-Anonymity_ model. Inspired by Phil Nash's Ruby gem [_pwned_][pwned].

## Installation

```bash
# 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.

```python
>>> 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.

```python
>>> 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

[hibp]: https://haveibeenpwned.com/API/v2#SearchingPwnedPasswordsByRange
[pwned]: https://philnash.github.io/pwned/
[tablib]: http://docs.python-tablib.org/en/latest/

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

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for pwnedapi-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7c732c740e15b0554e3a0e9285e470da2d7f4ca0356de4d37be6489dbbd8ad41
MD5 302c74461ae79aee179548de424c518c
BLAKE2b-256 9b3cdaad96174a651c8d39949f93f0d00dcdf19d79e092195c4c9770b9eac0b0

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