Asyncio and aiohttp based library and CLI to connect to haveibeenpwned.
Project description
haveibeenpwned-asyncio
v0.0.4-1
Library to query and check haveibeenpwned with the aiohttp library.
NB: I have added async to sync methods if you are not writing async code. Every query function has an corresponding synchronous call -> example query_account_sync()
Install
pip install haveibeenpwned-asyncio
# or
poetry add haveibeenpwned-asyncio
Usage
See example.py for more uses
Ex:
import os
from haveibeenpwned_asyncio import haveIbeenPwnedPasswords, haveIbeenPwnedAccount, haveIbeenPwnedPastes
import asyncio
if __name__ == "__main__":
# Validation Class, inherits from Indentity Class
loop = asyncio.get_event_loop()
passwords = ["P@ssw0rd"]
accounts = ["admin@gmail.com", "test@test.com", "test@gmail.com"]
test_passwords = haveIbeenPwnedPasswords(
passwords=passwords, semaphore_max=10
)
print(loop.run_until_complete(test_passwords.query_passwords()))
print(test_passwords.query_passwords_sync())
test_acc = haveIbeenPwnedAccount(
accounts=accounts,
semaphore_max=10,
api_key=os.getenv("HAVEIBEENPWNED_API_KEY", None),
)
print(loop.run_until_complete(test_acc.query_accounts()))
print(test_acc.query_accounts_sync())
test_pastes = haveIbeenPwnedPastes(
accounts=accounts,
semaphore_max=5,
api_key=os.getenv("HAVEIBEENPWNED_API_KEY", None),
)
print(loop.run_until_complete(test_pastes.query_accounts()))
print(test_pastes.query_accounts_sync())
API Key
Some of the endpoints (breachedAccount) require authentication in the v3 of the API. This is to prevent script kiddies and abuse of the api, see blog post: https://www.troyhunt.com/authentication-and-the-have-i-been-pwned-api/
To get an API key follow: https://haveibeenpwned.com/API/Key
Usage:
# Could use env variables
haveIbeenPwnedAccount(
accounts=accounts,
semaphore_max=10,
api_key=os.getenv("HAVEIBEENPWNED_API_KEY", None))
# or
haveIbeenPwnedAccount(
accounts=accounts,
semaphore_max=10,
api_key='xxxxxxxxx')
CLI
Includes a CLI interface using pythong click library
(.venv) goose@pop-os:~/Development/haveibeenpwned_asyncio$ haveibeenpwned_async --help
Usage: haveibeenpwned_async [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
accounts
passwords
pastes
Speed
Check the file run_test_speed.py. This will give you an idea of the speedup asyncio does with multiple IO bound network calls
TODO:
- Add API key to github actions for pytest to pass on breachedAccount
Donations
Please feel free to buy me a cup of coffee as I pay a monthly $3 to test the library against haveibeenpwned's monthly billed API key
buymeacoffee.com/crypticg00se
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file haveibeenpwned-asyncio-0.0.4.post1.tar.gz.
File metadata
- Download URL: haveibeenpwned-asyncio-0.0.4.post1.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18ac5af87a429583a72889046b7171904d11189491b43ea3bdfd024f38a86fad
|
|
| MD5 |
6df128a747f5fdfd2543c8079ce813a8
|
|
| BLAKE2b-256 |
071feb60a5e045b0e80439cf9cb98b70a60a2de481439c674ebccca550195751
|
File details
Details for the file haveibeenpwned_asyncio-0.0.4.post1-py3-none-any.whl.
File metadata
- Download URL: haveibeenpwned_asyncio-0.0.4.post1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab998f9248bb530573e245031a1b6bd9ebc6d7e0b66065ec7eaa98779af5cbe4
|
|
| MD5 |
cca027b1a019f01066d5dfbb47ed4704
|
|
| BLAKE2b-256 |
dc0841f5eb9ec4949bff3f3985ed73092ffd96e029d0a556dff26946db99fe0d
|