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.

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

Uploaded CPython 3.14macOS 12.0+ ARM64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11macOS 12.0+ ARM64

pyyescrypt-0.1.6-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.6-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.6-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.6.tar.gz.

File metadata

  • Download URL: pyyescrypt-0.1.6.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.1.dev25+ge1f847f11 CPython/3.12.3

File hashes

Hashes for pyyescrypt-0.1.6.tar.gz
Algorithm Hash digest
SHA256 3b160fa4da5935ed98446dcb11105e1ffcabf49e38c7cab674401c11c31e51e4
MD5 a8477bfaefa93a346d1ecff8417d4217
BLAKE2b-256 4e9cfb7d8ef1749f531eb5187e2728f5e9e49d7c8ca712bc94baa93e4fd63805

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.6-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 165f33e11803ea2f2c04121665e0a8cb135276da8d503cfbcf84ed642a548a38
MD5 333f3512d98ca18d451580d16d48eea4
BLAKE2b-256 7ceb5fd16ebbf20ff58527132f028463b28cde03d5e810096cbf81fa8477305b

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.6-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.6-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 fc3b46d52cdb091693d540c0619c0b70d2c9700a65cf41ec62b34c5b73f88f57
MD5 462da8a97005a04ab4717cca3c8d7f99
BLAKE2b-256 c5b5ea1c81a9587342eca9ca680267f39250286a7289f26a68d0dd9e3fcd0261

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.6-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 f0f3b021be9ff9e9a0eecf01db9cfd31ee7d66cd47e54be8faf8b31a2f6a9761
MD5 2cd7d5322a0721735137a7a4bb2f18a0
BLAKE2b-256 8a527a8cb55f50a3392226ba9ad3813248a87667c30109257e9839ef6bb6bb43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.6-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e07af55e05be9342de1404cdd8c13157f747a291df688226bb192bddfe99dd28
MD5 93935d59b2c06a6cc89b22eff1ba61b2
BLAKE2b-256 3a12222dadc226deaaaa1dbe429ee39ca99b8a75c3fcb1f76314eb673342e845

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.6-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.6-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 1d9b3454d750c0f53f2605bc057051fe0b1eb8348625ec7318b678fbf2b09bd2
MD5 ee3c4ffa3c3017a4c14a3bf3dcbc4a46
BLAKE2b-256 07df244eaf5fb6207e7a69ddd01159c4a0e30adb32dc522c1061276347cf6237

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.6-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 f3419c119defc9a91e82494fde5c9bb902eea5171295d1d1c2a911014f45d397
MD5 c811b17b585b60172f83427905749be2
BLAKE2b-256 a4eb6b90f0408840c63489069e3002d5e96d28078fe708642075b04f286b1c54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.6-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 78181a7db7e51da2c1f07cc2f45e893f962533a3e6810880c0eaa10f3ac3e999
MD5 fec53a0aa630f717f25bd2d09b95e52e
BLAKE2b-256 15e7eb024718360c9482bf85c6378be9fdbabc5d54e53c3cc00b20bae03560ee

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.6-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.6-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 cf0482de13aabedd38cff8e2610d8fae2b465b68319e7cb7c55bc5bd05515ab9
MD5 a10db183dc0d2c5736679b473242212c
BLAKE2b-256 1a114e1537631e8d99219300a78805296149e8130403be6b8742b87061ef8194

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.6-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 a28861cd4cd05214115c27c000013e9f5189d45252f11f877a3e34f1a9272340
MD5 1f0792be61d464473448ced7c23f29a6
BLAKE2b-256 bb4a2e3b07c436004ddd75aca3b6f98c7e4b1c784759aefcf8522b5f171c3f3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.6-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 19c016e8ce61ed572f4cdc6df04276cd98f4242ef933584a2d3bb993231f7af4
MD5 78ef67ff25c3ab20d8c02439e07ba811
BLAKE2b-256 e81f70882b3476b70596127706a0c9cc93e9c4395051604592c012e589edc5f8

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.6-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.6-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 99d94b9aa4e67f614f5a58abf06e4a534d347032db19c71c5e8150ce61f68cc5
MD5 cf7caf99ef966723ce050ff6f7c87cf6
BLAKE2b-256 24c49e23354e88a1fb5dacfcc80e3e80951c75574e12b83bfe19f325c20cdf7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.6-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 47a957d1e5ebe172f56bda3d9a8e087397e65bceae934a92bd019dd65ff22d39
MD5 c0ce0ee34adc2ed605e7e0c94224ef9a
BLAKE2b-256 7d138ae14fd4592a29f594a467a426a1174ed6bf98277f206c2feeb20c00e74f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.6-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fa86b6ec3c6580dd4fe24af292ad5c6c9b3176c64c0e799609b401e5014ad487
MD5 796040c8fc7b70375e848adf7fd99253
BLAKE2b-256 922159b986b51d72c31776f4ac497afd5e397aa58f582b9a9a2c6d8e0c6c0071

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.6-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.6-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 a03772bb4e34c183a94d059a96fcff1c3a7b20c173ba1c48763661073b5e6e9a
MD5 a64496944acc435f00ef973cc46cf037
BLAKE2b-256 8580a1b3b1550f8b9f4a8cbd1f0e0c21bc11ab015069d21addc0981390a6c7f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.6-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 984ce0533c8b6e960cc53d14ee7e62898db63d2ded336762b75a805ac3dc2270
MD5 5e91dd6511825c275e0a858d8bb622fb
BLAKE2b-256 780289fa492637fcacd7c36cfe14afd3bbd4f78a11f49e54f874e1d7efd02b02

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