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.8.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.8-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.8-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.8-cp314-cp314-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.14macOS 12.0+ ARM64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11macOS 12.0+ ARM64

pyyescrypt-0.1.8-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.8-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.8-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.8.tar.gz.

File metadata

  • Download URL: pyyescrypt-0.1.8.tar.gz
  • Upload date:
  • Size: 23.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.8.tar.gz
Algorithm Hash digest
SHA256 e3df64cf088c27b252ff32cf89fca22ad27f27c34fa81f52bbe8515d58275fbe
MD5 e671d3b056959c9a539bd67603e7f002
BLAKE2b-256 9eab0153c7f8755927cf6cbe2c9d68dbd78d899dc3214b6614b08d34ca2235b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.8-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e0fe3c9b39be11033ea2af8e0161b9c3a7d3a0aa0d161ce4b7d9b847693c1f78
MD5 a7960e594e87862cf285d1f373703085
BLAKE2b-256 8a828cbb06c15656c0f73973772a5d1f19fcd2813f2530d6705bef4db476f5f3

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.8-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.8-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 af6c7a36091a6a2d4b558b53b9763ef2d7958d3b6a7bd0643ea29e6c2c567014
MD5 e4f7dd2c8ddeb83ab514451bf6332310
BLAKE2b-256 f7ce820d9ae7371e0979fc69c263c6f140d61fc48149e37b9a49e58c444737b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.8-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 c5642306ebd71cd9885e0328cb165f88fe7636fe728668222ea8fb61446ebad9
MD5 8be03cb28feb99790b8c7578eca90d85
BLAKE2b-256 31517d665657ab02d11446d3435a06b34aaf9941fb61cb933df53842e7ba39a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.8-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5c3171cfc4d51709dd61652e0c9f73ff02c5ae69dd911e41fc8e5191d9dd6890
MD5 5becb293a3fcc3cfcae249e12e995c58
BLAKE2b-256 e8dae891f57e3aadfeb087581550f42edd56085d6d29fdaaf9703aa044f88ac9

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.8-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.8-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5908eefbc3c407f74e3915a789500a937735b6472a20f40e98e3177ac3d0df27
MD5 22e842d17eae2c8855c63c310be5d5c3
BLAKE2b-256 bbc969cc8baacd899199eb0cf96a2d24e6b9dca975d55eb550d4149f4130f309

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.8-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 a894309c4f20bfce4faae5193cc53358bdb107f6b98c0fd6e514020a7046dd10
MD5 dbfbddabbcc4ff8d951b0437afb67ee9
BLAKE2b-256 8c004e59179706ccdba64e186c1ee765f10bbcbb309de1a525bf8d22fda24fb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.8-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 71a24f2209ab65371cc37ceafc0bff5224a060d30280a6048bb8aca7c13c446b
MD5 9af724aa33a2d2cce4c06b023551443f
BLAKE2b-256 622a3d1c982ca3b5c8ee89aca899f23eb4c430ace2bcd080525758b7d3817d2a

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.8-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.8-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 3c6c2a965a6bd8d8d39fd87b6b4ed9b7d3817bb778784c93dcf25e304ec7c9e3
MD5 599a45a9f3b867ca299edf73fcab7125
BLAKE2b-256 ed76ff294dbeee5f75e40644d481f751b5af0f498508d566897e8d9aa0ee9f80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.8-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 3ff24efd819000393c5b584ad561602b0317b815a2ae13bad156ae0fcafe16e3
MD5 fe8d033d72c02b3316fef71c7fefcc9d
BLAKE2b-256 d0ddb2d34b2f044200cd6e1d7696c8400f062f0c9a4a07e85c9062bde555a30c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.8-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b69bec2fac2f84f7085a5692881e6b8a04c56a0cc03acf3b272b2d897e460f70
MD5 0d952087251753703d1d6c22b9089063
BLAKE2b-256 2cc27ee3998b290d69cad89d4cf1e15f11477a02356f11b1057cf7d133bc1222

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.8-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.8-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 f28a95199454c2488ec2439959019410a05ef579b749311e98d8b3b535ce5c3d
MD5 feeb59dd92d2d3961aa3b22ffe173bce
BLAKE2b-256 3470475776cb54c4ba71fdb4c7206a1b714037709e3762413228122779db44f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.8-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 810d49f7deb6750d5f97a7dede353d3748f0a2f6f0d2f3523bce3a500b8a3a9e
MD5 727c13842a40e4ece9dd3b3f4dac0a38
BLAKE2b-256 17b056bac87ace3dcfa1badd936faec8ec40abbb985013014e4826b66e5076eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.8-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 89b458bec7655e3b4d3cc485966e6c1980df91cf6feac123390b9d7fdbfdb9a3
MD5 8f5c8ed2e7c88a3cb69b345e80941111
BLAKE2b-256 6f1ef6ee8c9cdf5922355aeaac5d31db08e5086328ef5b794423848bfc1c7d82

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.8-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.8-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 9e951398c0a31a60f3fd14f54b59042712a5f121fb83da3871f0d0852ccbf07c
MD5 9bf536f8bc1f6ad54d0c9873d1287f73
BLAKE2b-256 41854add1bbf4631853e79c2713b1f2490c8badd70da3dea1ad6793d47588d5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.8-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 ed5ae1d7c966036ca13b27526bd4963956b769da6ec72668488785c231a3a590
MD5 67ba252ad6a56d254ad95fd00f2b69a7
BLAKE2b-256 2c531e5a89fa0407d9db69157ad39c3de4de9875ba5867c1a9e5916f2d8f8570

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