Skip to main content

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

Metadata

Release files for haveibeenpwned-asyncio 0.0.4.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for haveibeenpwned-asyncio 0.0.4.post1
File Size Uploaded Provenance
haveibeenpwned-asyncio-0.0.4.post1.tar.gz 7.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for haveibeenpwned-asyncio 0.0.4.post1
File Interpreter ABI Platform
haveibeenpwned_asyncio-0.0.4.post1-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / haveibeenpwned-asyncio-0.0.4.post1.tar.gz

Download URL haveibeenpwned-asyncio-0.0.4.post1.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
18ac5af87a429583a72889046b7171904d11189491b43ea3bdfd024f38a86fad
BLAKE2b-256 checksum
How to use checksums
071feb60a5e045b0e80439cf9cb98b70a60a2de481439c674ebccca550195751
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / haveibeenpwned_asyncio-0.0.4.post1-py3-none-any.whl

Download URL haveibeenpwned_asyncio-0.0.4.post1-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab998f9248bb530573e245031a1b6bd9ebc6d7e0b66065ec7eaa98779af5cbe4
BLAKE2b-256 checksum
How to use checksums
dc0841f5eb9ec4949bff3f3985ed73092ffd96e029d0a556dff26946db99fe0d
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for haveibeenpwned-asyncio 0.0.4.post1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page