DEV Community

Discussion on: Who's looking for open source contributors? (October 15th edition)

Collapse
 
nikoheikkila profile image
Niko Heikkilä

My Python library for interfacing with Troy Hunt's Have I Been Pwned API is now in version 0.5.0 and supporting Python 3.5 as well. However, there's surely more to improve on that. Go check the issues or stumble down the source code path. This is a very small library offering all the easy Hacktoberfest points! 🎃

nikoheikkila / pwnedapi

Library for easily interfacing with Have I Been Pwned API v2

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"