Memory-hard password hashing algorithm for Python
Project description
noctahash
Memory-hard password hashing algorithm for Python (Rust bindings).
Installation
pip install noctahash
Or from source:
pip install maturin
maturin develop --release
Usage
import noctahash_py as noctahash
# Generate hash with automatic salt
hash_string = noctahash.hash('password', None, 3, 64, 4, 'base64')
print(hash_string)
# Verify password
is_valid = noctahash.verify_password('password', hash_string)
print(is_valid)
# Custom salt
salt = noctahash.generate_salt(32)
hash_with_salt = noctahash.hash('password', salt, 3, 64, 4, 'base64')
# Hex encoding
hash_hex = noctahash.hash('password', None, 3, 64, 4, 'hex')
API
hash(password, salt, time_cost, memory_cost_mb, parallelism, encoding)
Creates a password hash.
password(str): Password to hashsalt(bytes | None): Optional salt (32 bytes recommended)time_cost(int): Number of iterations (1-16777216)memory_cost_mb(int): Memory usage in MB (≥1)parallelism(int): Number of lanes (1-255)encoding(str): "base64" or "hex"
Returns: str - Formatted hash string
verify_password(password, hash_string)
Verifies a password against a hash.
password(str): Password to verifyhash_string(str): Hash string to verify against
Returns: bool - True if password matches
generate_salt(length=32)
Generates a random salt.
length(int, optional): Salt length in bytes (default: 32)
Returns: bytes - Random salt bytes
get_version()
Returns the algorithm version number.
Returns: int
Parameters
- time_cost: 1-16777216 (recommended: 2-3)
- memory_cost_mb: ≥1 (recommended: 32-64)
- parallelism: 1-255 (recommended: 4-8)
- encoding: "base64" or "hex"
Building from Source
pip install maturin
maturin develop --release
License
MIT
Author
Tuna4L - GitHub
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 noctahash-0.1.0.tar.gz.
File metadata
- Download URL: noctahash-0.1.0.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2164131920c2a70b2c98bd1de09f015685e00e756915b1b2c6e319a3d0dff15
|
|
| MD5 |
12a4c912a03840f1f0856806145129c1
|
|
| BLAKE2b-256 |
1facf59ec82cec7910098d6318e2e52d70348b298edc6526051d117d95acb79a
|
File details
Details for the file noctahash-0.1.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: noctahash-0.1.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 189.8 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b0a15a6a25a11e744b42ee9c0f7220adc3968f706b95045d3e294418592a415
|
|
| MD5 |
f5da1cf1352a239033358e30443dabce
|
|
| BLAKE2b-256 |
28470e0f9895a14bc3c678a5fa5ae897500da4f77c700f9135c0882ad8d58b4a
|