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.9.tar.gz (23.4 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.9-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.9-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.9-cp314-cp314-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.14macOS 12.0+ ARM64

pyyescrypt-0.1.9-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.9-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.9-cp313-cp313-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.13macOS 12.0+ ARM64

pyyescrypt-0.1.9-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.9-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.9-cp312-cp312-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.12macOS 12.0+ ARM64

pyyescrypt-0.1.9-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.9-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.9-cp311-cp311-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

pyyescrypt-0.1.9-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.9-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.9-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.9.tar.gz.

File metadata

  • Download URL: pyyescrypt-0.1.9.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.1.dev30+g2d06e1177 CPython/3.12.3

File hashes

Hashes for pyyescrypt-0.1.9.tar.gz
Algorithm Hash digest
SHA256 304b6a79b6306f3d89232d3bc63500799e4b7c20253cde9e4f8ea11da407699f
MD5 5c271ca3ee151cb9a306d1d9903bf290
BLAKE2b-256 d35330360da474c0e4911815c7fc5012c20e7eb4ad5c86d771ace98c1b6615fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.9-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c81218f263ec508d0bae771f6304e327c0d9c9c46b22f49c36cef58ecab77f5a
MD5 836c46ee39a82683093593c30df7a38f
BLAKE2b-256 61390b01f5bd0c840405fc3cdc151940ab9f37afaf427e3cdae7d5e668e3a314

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.9-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.9-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 645f213dd86d4e6fd68eb3d25fc5559007ed0f1c0179e8cd36e37085228376b3
MD5 b006bf151ea6070c366fa8e90d699873
BLAKE2b-256 bb24c6f5fc6af1d26c05e72a5dd97b80abcd2a42318ebd464fcd1d9497aa8f87

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.9-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 5ecc453f7e9cb330f8c1717b3aa1a24bdbbffbc5303960f58ac1d86667fd5c07
MD5 bda941831edcc567eac0aae462fc5bc8
BLAKE2b-256 eecc09925b99ad3fd22cf1070964f9ac32df5a4136b0ffbfd2498b49e9fbdc03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.9-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 826c7b2b6eb094ee81bd5d6e50686a2a24c982be2bfca7a5066ae5b4251bdaa7
MD5 0da9c1250c9f2bf940da9a575c5215de
BLAKE2b-256 e22b75ade0920bbc956e2db58eb8630d63768baf31fe424747939bd10e7576cc

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.9-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.9-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 64e14caa76640825dfed24882fdcb05d4c2173e0ef3162e28b08cc825d53ba8f
MD5 2a474d1b779a281ab586ec35d192bde2
BLAKE2b-256 439ad7eed56d0c2fd27042ebf44d47d1c95f95173d224a05e6c42fd34b538948

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.9-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 bf28c74578022d6deac4e9eadd952c3be8078ab73e72f715a320b0b994f418a0
MD5 5935bff892580d8393837c2ca72bb64f
BLAKE2b-256 d797486a43e2e5b73ab48b5c58b194399807e0a6b42f7689873a75823deeb1f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.9-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1aeace1c3e3e7ed44c2eea2461dbaa08194fbbde80cee94e1e2c1ed9e7900908
MD5 70691e6ef41fb6878189cc1faed7f7e0
BLAKE2b-256 0f34aa8a8f3683974579634c3102ce3675cb56f7a7be57ecfe7e3f26fde9c854

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.9-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.9-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 4b0c40f5a59dc03b39f8adba69930343fe1c6952d8dd00dc874d5edcc237bac9
MD5 c39f9b72fedbf01a35d0ae8859322bbc
BLAKE2b-256 d1a2258ac2bb7b32a430e2569464ac2540ba9e12aacc97f19ea433cf86b640bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.9-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 3e22da24dec9191addcd4ee3962a97eff400d98189c1c388b62e58716a7e8cc7
MD5 779c259dde2bd82e313f5eb18818917c
BLAKE2b-256 aac4f4684353e155512588586c1e6ec4a3b20e90b261b2e32f512284e50aae98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.9-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 08466484b28e9f714a0c164b08235963e15f345db2262df66705b384df9b7bc6
MD5 baa029806b8f5e96df8e85318a01ba57
BLAKE2b-256 ccf7d1444417dde2c1e3219f3bcfa3867f8731424d20f9bca0fe00295d251e01

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.9-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.9-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5fc4e410f7605c24491192d448e9c3a85a04e1e5b55fd8d530c7cbe37415f8c1
MD5 682a3cf7d4617a7c72e6deda4477acc4
BLAKE2b-256 a9fbde0edee764a5c0d91797a3aca2abb9794fa3fe788141e8d7f33e1ae77e8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.9-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 af02231c0581795f30d1c04753c5b202111ea9fa9610dce534ff0fa49390f06b
MD5 17d3dc5bbff3f02452ca48f8043e59e6
BLAKE2b-256 b4cd790e98ec06dafffcb8e67d8152b997f43d68889de39a39d50b84210b79cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.9-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 bee109f310427049b4cc9db9be45ada8d389a85fcde6330165b2938e64c2b5da
MD5 fa5b1097a1e4c264ab49ecee12e3cfff
BLAKE2b-256 e2ea18959fe797cead1d2c9f8de07c0208349cd15d5e4ccc8796c509951538e4

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.9-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.9-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e2e2483b2282df3db3047545258f8704960e59497dd992bf0a04b5a764d19077
MD5 f335e360ba204d76e43fa11aab7de98a
BLAKE2b-256 ba9c94d2961c7101865704377f650a168d1cf27cd81c57358a25706cd68651d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.9-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 699f7d6d1ee9dac35e2e0e7ceff5e60e434526ac602741f64ab632786bd7a6de
MD5 50f400cb0b0668b07d2549ae21f993a8
BLAKE2b-256 87e1e5d67e1561c786c397c295c08d35379475313da2cd010ce94aa6ff0597a3

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