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

Uploaded CPython 3.14macOS 12.0+ ARM64

pyyescrypt-0.1.14-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.14-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.14-cp313-cp313-macosx_12_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.13macOS 12.0+ ARM64

pyyescrypt-0.1.14-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.14-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.14-cp312-cp312-macosx_12_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.12macOS 12.0+ ARM64

pyyescrypt-0.1.14-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.14-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.14-cp311-cp311-macosx_12_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

pyyescrypt-0.1.14-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.14-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.14-cp310-cp310-macosx_12_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.10macOS 12.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pyyescrypt-0.1.14.tar.gz
Algorithm Hash digest
SHA256 f852c03fd060dbede918187cfbec1043afc40d24054540ecf19957fd05906236
MD5 431145a8274fb35f092ca5984e771c9a
BLAKE2b-256 c3ba4db97e3cc3d621d5a815b98374229dc0fbfcfe1c1909b6117bb7e2f15179

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.14-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2f120d079b5ced2fc12ec137defa5cb1b3d9f0a990a1a00d9df05026bfabb125
MD5 e17b41e0c6d2d50e12fa52444ad0fbdb
BLAKE2b-256 8aace29f9da1151d8eb205bf2a0db1caa26e4ed72c671948cb445860625e9279

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.14-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.14-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 8a98ae674d7ec3b45544abb21e32a9268cb42bb1d1949368522192e0901eaf34
MD5 924209008160e4290487606ab69be10e
BLAKE2b-256 9805d79ec6de64f50bd2deda2cbda6c052724a353a7d6ad91fbb660fe1ed9d6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.14-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 0c2948da2bcbccc20e30752f0120ff6bf1bc3f91357dcd7bea0b8f00bcbb3612
MD5 a323fc1ad0e800c8151e47785bd70147
BLAKE2b-256 76ce3333f8b32db4673cf059eb9f041782c7532148d430d3fef774b842370a32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.14-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4c28e1162ff473996aa5c6a3ddab17548bb681e5d499bdc2f161a1d8d7e7ffec
MD5 a8f7936ec217edb4c4f1895368ff6871
BLAKE2b-256 e039292576526f4b01708be753bab627709a46013e5b6dc1e91cbd8b9efbfd60

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.14-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.14-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 c645dc02a56f2fb6eb7cdd56202545039e8f527549a082e299f3948df8d190dc
MD5 6c85216d783fc22f5637abb0bded0e52
BLAKE2b-256 1572c54cc6a4ec03e587151dba561865087e7c493f339e996d101bdc686bc359

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.14-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 00040a2fe9788a6508e944938cf4e2ddcdd2fc6e25cd584d9a6ee0243791febc
MD5 7bd5de454dde151e1de5c166205a4e6f
BLAKE2b-256 523131f1a90906a4238777bccb36c9c018e94c007b3a3a434604e66c0bc9f3b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.14-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fcab9a14a562602b2c41978c355bbfde49591444d27e3a39400d29ffc54c3804
MD5 809c6b9706ba2e54f3e287eaf345f74b
BLAKE2b-256 659fbf6134b77635c1b50c60bff31fd3a3274967a55401d40555b3e800749b15

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.14-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.14-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 f766880030b663ef7a11597ec3c1a046ebcf39b20f74e250a27bce82e2b56766
MD5 cbbce85917008587161d0a524ed8c02d
BLAKE2b-256 aca003d2b7a0e51e7d9e60a99c417f1ed76a8831ecbaaa02c0cb6c5f44e07d66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.14-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 5967b34e8ddb79f3051d32c38e1109246d7bcc29044f3e1b00a506d8fc16aabb
MD5 241d5e50a39f315d5b97044a0bb7d4d5
BLAKE2b-256 9e54363c74167481144a1fdd53b3991c7d2efb58bb58e75a1663e67b25a8baab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.14-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 63e990dcd36dec74e133040cf39b030113eb3074f5dca467b5ed5b472d41de17
MD5 d2b818d2cc573c2600488e93292570f8
BLAKE2b-256 f980709d215f5c4c45033c5c7b29d49ffe9ab4a2198d69c4a734b4a44d3f9a66

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.14-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.14-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 ae3eb87835a78ba41868948a9984bc07be06f1270af4209268e8f4435a354a9c
MD5 c2164c6bbc7bcc6a2b021bd959800905
BLAKE2b-256 09b5039933784f4fe1127df3c4e838964f1f5e643e836cfd1e1cc9cca4a17339

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.14-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 9a5669376c837bd19f5ad4f9106311c33cc03043efbbc27eb35dcd8ea4c9f4e3
MD5 3ebe5a3679a8ebfba89a9dc8bac34337
BLAKE2b-256 96c38818fabd41ef6991dd0dd1166fedd5836137345f89bc135c121c97e31eda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.14-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a6a0261b664958fbb8c63443c4443c45ab3c5ee16267d921eef174caa2a99d68
MD5 7e8ee5dddd2f65c362b8b67eab08d137
BLAKE2b-256 aae9befe4843119b1a841c9b10baa2f5e2d4a1ad9b0543fba6f7cdc1728b5fd1

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.14-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.14-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 7a0213f8fca057b1850a015079d79cb270509cbd067e1c3c331ac9de61f27731
MD5 79cff864f2ce4548074566540157f472
BLAKE2b-256 2cef1a52ddd6b77d7d373d19a66ccbbb2c281b353a7b99810352cb9ef84649ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.14-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 fd0fd21b357afc0ecd2f2ec436ada144492f85bd8e95239f9314556352a059f3
MD5 b1ea310d41a0987744b3418f039700fc
BLAKE2b-256 0a81d9eb83d93e8a2f7847fdb10d0d5ee60cf0624001f9085e1da14660ca917d

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