yescrypt
Pure-Python yescrypt password hashing. It uses only the standard library and runs on Python 2.6 and on Python 3.
It creates and verifies $y$ hash strings compatible with libxcrypt, the crypt library used by many Linux distributions for ENCRYPT_METHOD YESCRYPT. Hashes made here can be checked by libcrypt, and the reverse also works.
Installation
python setup.py install
Or use the package directly by putting the yescrypt/ directory on PYTHONPATH.
Usage
import yescrypt
hashed = yescrypt.hash_password('correct horse battery staple')
# '$y$j9T$<salt>$<43-character digest>'
yescrypt.verify('correct horse battery staple', hashed) # True
yescrypt.verify('wrong', hashed) # False
hash_password(password, salt=None, N=4096, r=32, p=1, t=0)
Returns a hash string. password may be text (encoded as UTF-8) or bytes.
salt: bytes or text, 1 to 64 bytes long. If omitted, 16 random bytes come fromos.urandom.N: CPU/memory cost, a power of 2 greater thanp. The default is 4096.r: block size. The default is 32. Working memory is about 128 × r × N bytes, which is 16 MiB for the defaults.p: parallelism. The default is 1.t: extra time cost. The default is 0.
Raises ValueError for invalid parameters or salt length, and TypeError for a password that isn't text or bytes.
verify(password, hashed)
Returns True if password produces hashed, otherwise False. The hash can be text or bytes. A malformed or unsupported hash string also returns False and does not raise an exception. The comparison runs in constant time.
Supported settings
- The default RW flavor (
$y$j...), which is the one libxcrypt produces. - Any valid
N,r,pandt. The pre-hash pass that libxcrypt uses for largeNis included.
Not supported, and rejected with ValueError or False from verify:
- The ROM and NROM modes.
- Hash upgrade (
ggreater than 0). - Other flavors, including plain scrypt.
Performance
This is pure Python, so it is slow compared with the C implementation. The default settings take several seconds for each hash. Verification costs the same as hashing, because it recomputes the hash with the parameters stored in the string. For a login system, a native libcrypt binding is a better choice.
Testing
python tests/test_yescrypt.py
The default run takes about a minute and a quarter. To also run the two large-parameter vectors (about one minute more), set YESCRYPT_SLOW_TESTS=1.
The test vectors were generated once with the system libcrypt. The test suite does not use libcrypt. The scripts in tests/ that call libcrypt (gen_vectors.py, probe_settings.py, gen_extra.py, check_vectors.py) are development helpers and are not needed to use the library.
Layout
yescrypt/
__init__.py hash_password() and verify()
_core.py yescrypt RW calculation (port of yescrypt-ref.c)
_encoding.py base64 and $y$ setting encoding
_compat.py text/bytes, constant-time compare, HMAC and PBKDF2
tests/ unit tests and development helpers
Metadata
Release files for yescrypt 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yescrypt-1.0.1.tar.gz | 12.1 kB | With provenance | Details for yescrypt-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yescrypt-1.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for yescrypt-1.0.1-py2.py3-none-any.whl |
Total release size: 21.5 kB
Release files / yescrypt-1.0.1.tar.gz
| Download URL | yescrypt-1.0.1.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87989c3756719742dcd32b3a651ab5a17cbb6359e9dd3edb3eded15063d3aa43
|
|
BLAKE2b-256 checksum How to use checksums |
3c3b1b396585b6cd681fd0db77039485d995dc1801d076208c3e7ddad7c8037d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / yescrypt-1.0.1-py2.py3-none-any.whl
| Download URL | yescrypt-1.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
45bfa1fb03e90d875a9256cb556c7023101b13d9fb4e2599db48d9836351b58f
|
|
BLAKE2b-256 checksum How to use checksums |
41ab9d8aa4f64fab322ae3b5f57c1973849b50a84267a7052d9d0ad575fca6e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logSecurity for yescrypt 1.0.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for yescrypt-1.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logA 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.