Python interface to the OpenBSD functions crypt_checkpass and crypt_newhash
Project description
OpenBSD crypt
Python 3 wrapper for OpenBSDs crypt_checkpass(3) and crypt_newhash(3)
Usage
$ python3
Python 3.8.12 (default, Sep 26 2021, 13:12:50)
[Clang 11.1.0 ] on openbsd7
Type "help", "copyright", "credits" or "license" for more information.
>>> from obsd_crypt import crypt_checkpass, crypt_newhash
>>> pass_hash = crypt_newhash("password")
>>> print(pass_hash)
$2b$10$RoAK6.GPdcXZId.cmFhmG.5YbXmANB/FyvzIbxj8uCKQWqRubiwee
>>> crypt_checkpass("password", pass_hash)
True
Functions
crypt_checkpass(password: str, hash: str) -> bool
Check a password against a given hash.
If both the hash and the password are the empty string, authentication is a success. Otherwise, the password is hashed and compared to the provided hash. If the hash is empty, authentication will always fail, but a default amount of work is performed to simulate the hashing operation. A successful match returns True and a failure returns False.
crypt_newhash(password: str, rounds: int = -1) -> str
Return a new hash for a password.
The provided password is randomly salted and hashed and returned as a string using the bcrypt algorith. The number of rounds can be any integer between 4 and 31, inclusive. If the number of rounds is not given or is negative, an appropriate number of rounds is automatically selected based on system performance.
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
File details
Details for the file obsd_crypt-0.0.2.tar.gz
.
File metadata
- Download URL: obsd_crypt-0.0.2.tar.gz
- Upload date:
- Size: 31.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eba4160c5017a5bbdfec422b8faac423421434fda90bb85869198a82a0e8e366 |
|
MD5 | 5b092ca6c50fbc6bdbb915e396e013f9 |
|
BLAKE2b-256 | 0f7d0c3011f61ff865b7cf9d06f466737973e1b6a36262c7885af090eef0f536 |