Skip to main content

Python bindings for yescrypt using a tiny Go shared library

Project description

pyyescrypt

Python bindings for yescrypt, implemented as a small Go shared library loaded via ctypes.

No CPython C extension code. The Python package is pure Python, plus a platform-specific shared library:

  • macOS: libyescrypt.dylib
  • Linux (glibc): libyescrypt.so

Windows is currently unsupported because the Go-based build has only been validated on macOS and glibc-based Linux.

Public API

import pyyescrypt

hash_str = pyyescrypt.generate_hash("my password")
ok = pyyescrypt.verify_hash("my password", hash_str)
  • generate_hash(password: str) -> str returns a modular-crypt yescrypt hash string (typically starts with $y$).
  • verify_hash(password: str, hash_str: str) -> bool verifies a password against a stored hash string.

Errors raised from the native layer become ValueError in Python.

Command-line interface

Installing pyyescrypt also provides a pyyescrypt-cli executable (packaged Go binary). It exposes the same operations as the Python module:

# Generate a hash (reads the password from stdin)
printf "secret" | pyyescrypt-cli generate

# Verify returns exit status 0 on success and prints "1"
printf "secret" | pyyescrypt-cli verify --hash '$y$...'

The Python package automatically falls back to this CLI whenever the shared library cannot be loaded (for example on musl-based systems), and you can force it via PYYESCRYPT_BACKEND=cli.

Repo layout

  • capi/ Go code compiled as a C-shared library (-buildmode=c-shared)
  • src/pyyescrypt/_native.py loads the shared library with ctypes and exposes the Python API
  • src/pyyescrypt/_native/ destination directory for the built shared library
  • tests/ Python tests (ABI-level tests via ctypes)

Requirements

  • Go toolchain available on PATH
  • Python 3.10+ required
  • On macOS, Xcode Command Line Tools installed (xcode-select --install)

Build the native library

make native

This builds the shared library into:

  • src/pyyescrypt/_native/libyescrypt.dylib on macOS
  • src/pyyescrypt/_native/libyescrypt.so on Linux

To build the bundled CLI (used automatically on musl) run:

make cli

which outputs src/pyyescrypt/_cli/pyyescrypt-cli.

Run tests

make test

This will:

  • run go test -cover ./...
  • create a local virtualenv at .venv
  • install test dependencies into the venv
  • build the native library
  • run pytest

If you want only the Python tests:

make py-test

Development notes

Why ctypes instead of a CPython extension

CPython extension modules require a C ABI boundary anyway. This project avoids the CPython C-API completely by exporting a small C ABI from Go and calling it from Python using ctypes.

Memory ownership

Native functions return char* allocated by the native library. Python must free them by calling yc_free. The Python wrapper handles this.

Linux libc notes

glibc-based distros (manylinux wheels) are fully supported today. Musl-based systems such as Alpine cannot load the Go-built shared library because Go currently emits initial-exec TLS relocations for -buildmode=c-shared, which musl's dynamic loader refuses. Installing the wheel on Alpine succeeds, but the native backend fails to import.

The package now ships a small Go CLI binary that the Python module falls back to automatically whenever the native backend cannot be loaded (or when PYYESCRYPT_BACKEND=cli is set). Set PYYESCRYPT_BACKEND=native if you prefer to fail fast when the shared library is unavailable.

Packaging

The wheel must include the shared library under pyyescrypt/_native/.

For local development, make native places the library in the repo tree where the tests expect it.

To validate packaging, use a separate workflow:

  1. build a wheel
  2. install it into a clean venv
  3. import pyyescrypt and run the tests against the installed package data

License

See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyyescrypt-0.1.11.tar.gz (23.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyyescrypt-0.1.11-cp314-cp314-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

pyyescrypt-0.1.11-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pyyescrypt-0.1.11-cp314-cp314-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.14macOS 12.0+ ARM64

pyyescrypt-0.1.11-cp313-cp313-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pyyescrypt-0.1.11-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pyyescrypt-0.1.11-cp313-cp313-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.13macOS 12.0+ ARM64

pyyescrypt-0.1.11-cp312-cp312-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pyyescrypt-0.1.11-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pyyescrypt-0.1.11-cp312-cp312-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.12macOS 12.0+ ARM64

pyyescrypt-0.1.11-cp311-cp311-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

pyyescrypt-0.1.11-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pyyescrypt-0.1.11-cp311-cp311-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

pyyescrypt-0.1.11-cp310-cp310-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

pyyescrypt-0.1.11-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pyyescrypt-0.1.11-cp310-cp310-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.10macOS 12.0+ ARM64

File details

Details for the file pyyescrypt-0.1.11.tar.gz.

File metadata

  • Download URL: pyyescrypt-0.1.11.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.1.dev35+gbea960757 CPython/3.12.3

File hashes

Hashes for pyyescrypt-0.1.11.tar.gz
Algorithm Hash digest
SHA256 4295c3d412d161a5853e3546d4fa19ea9a01d894a3b8271dc46ed7fa78cc1a42
MD5 9add60c2ef083f52d533b5d14417f3cd
BLAKE2b-256 54bb3c1052e05482a49c1041eddf537e9829b83235999282149563b0a80177cb

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2ddd43bf2296872f6b3c56c36671a1c82a74ed5ad4ab44a9de2dd11330e5310e
MD5 86ffec05b2ba78a5c7737ef87cbe1ae0
BLAKE2b-256 ae96febb9f2af4afa4674797a8d80c025e9ffbb00cc3152b8c7ea531a2cf6e8e

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0464122a40b1eeab67a63ba01683655ec696c1233802112e5f6e0fab2676115d
MD5 e7bdba5ffaba43ae186e6ea9f6931ae7
BLAKE2b-256 67e6ad84e5beccaff840a03b0c9c4ad856d2022fb9ba5bbbcc8ce3c6e51b5989

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp314-cp314-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 bef68f3ca0499e7ebff9cf4d49ac4d084db632645e88db436a758bc69407c4ab
MD5 66ef3359e806acb992c5c4e64a8398b7
BLAKE2b-256 8b73e42ca1ef11ba0df890ae0bb0097d50b05e3998f6f35df64b36be17f5dd86

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 387c00749cad75e657d06b0cb6ee236bedf7ba67d9a794aae8f7555558f0da89
MD5 91e553ac8ffd4dc0f654e9b463e9ccc4
BLAKE2b-256 c7fef16fc1cd8bbbf5e0e25150fe2e33c19126a7bf34ca2a1fd9baaebd1d87e1

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 92f0144d7877fec1ee1315076048389e38a8c63b7f0d1ef971a4ce4d269b95b3
MD5 568f122c52added867164b31abb37d4f
BLAKE2b-256 c64673f4bb1cdaad15ec4d017ddca6d2f0f114b52c4a3b0b07630845d2a7c68b

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp313-cp313-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 fe59e016c4e9fbabd8f660443500ec22914d6bb1cdc48e4c5a66cbbe79f51d14
MD5 e94cae8eeca060cd9e6f9c7d6abf1e7c
BLAKE2b-256 866bc97eec369baca8cfc45081e84299fdf647d07f23567f4d140373a7c600a8

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b78056d6b13b92d948b0c2f33d445d6362a1c409b5ba0664037c35c5bea1c841
MD5 64306d3c539dea92419bdf3c17db97d0
BLAKE2b-256 de040f11405622c84362682e9e9ce96f056dee0e1d439ad6d0fc5749e47f6006

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 1431cc04b1f654ea3973929774835fa94cd53b26c820282d987353fc16b0febc
MD5 a2b53da33d2fa8ec0270d569168e3b4a
BLAKE2b-256 c0f006c2df17d4f0b5e59993be00faec48e4797b1337595426e5c0a3fedd2883

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp312-cp312-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 726fde388a08cc6a9cc7d7efb6bd5efd7f8088accde9e91d8456ce0a467e7c74
MD5 96718a8b2d22532a0ee719fc32a1915e
BLAKE2b-256 0b2d961accadaa7208cebe2b71648e4e659258a993969093f17cebb1534ef817

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c515e326931c95fb19c31a4d7d33621cc260a4e03935f0b41779ede380796020
MD5 1b0b1dbf0490946f4f537b6d63096d3a
BLAKE2b-256 816d5f2052cf733212d4ac6024ae8f98c189d9fcdc7286b4169e377b62f3b67a

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 b7ee06c143cd693514c0791fa5ae1be2bd7f427aa1129231040cf5dc6f873662
MD5 3aa013bb44f1b331bee352531f330087
BLAKE2b-256 9e8bc0559403f6c46f4547a7952e888b71f4e527cc7963b90873e08d35b3f5c1

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp311-cp311-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 f14ca070416ee4b30f60cdfff3560b3764244ab6a061b0a6e91f4e599e7585e9
MD5 f188303fa62bf817371689691c7dbc8f
BLAKE2b-256 f8d39a9933047e30b95307354a8fc75a3a0aaf1ab7f5956cbfc14b608abdf592

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ac20480d80e50c254effc0bf9d0f054a3f0ee259bde742898af374acf8dcdf37
MD5 e7ba949292ac0a8ce774f0a6105edc50
BLAKE2b-256 bd7210024485043994d832997b4d9f84895218c5943f9cc239d420fa3c145c92

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 87bf6f582ed07fc5d9591d2c3f2d7436c6c78a0cb92c83523a67d6972056ad32
MD5 42ecb7466e549adb10193c342f832dd7
BLAKE2b-256 0872730a076da21642cb778ad2dae7fa48bd660be56e16323d2bc4d9b91a1a49

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.11-cp310-cp310-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.11-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 51d5a36f7d77e93603fbdb1cf0c58577209402563db22f3e2ae5547295f4e448
MD5 6dfeb9c8b3269df7cfbcebc7ce1c6c2f
BLAKE2b-256 d2238d7515423792c358bde1a167f96338d7855e3a37598a27d315ccfea3cb87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page