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

Uploaded CPython 3.14macOS 12.0+ ARM64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11macOS 12.0+ ARM64

pyyescrypt-0.1.12-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.12-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.12-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.12.tar.gz.

File metadata

  • Download URL: pyyescrypt-0.1.12.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.12.tar.gz
Algorithm Hash digest
SHA256 ee228e042a5b582287182e1f4e32d5f0a73902697e3f4e4eec1eed5077d3ec5f
MD5 6ff4f1bfc13cb6bffd685598a59ffc24
BLAKE2b-256 238543ec6607aa2d3c610fe81149f6680ae31400b33655ce8749f0ef22a8bb67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.12-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c3efbd11519c77d22ee72bf6ea87092122f487baba201688c8df721a1f6c06f0
MD5 74861db5a2d31bbc6ba545ba252ac050
BLAKE2b-256 ca114096257b5ab0f225c58c512efca3b025ab7ee9bcd541b8de1914fb5b429b

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.12-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.12-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 cb573506fffb90495db8b4ab6043c1e8f02d131a9087c48745eee4358ae36709
MD5 81f9861230b2670c0041ff9816ff8d6f
BLAKE2b-256 bf730f17c630680b7dc39893ede481180a3baae9d04fe2ce74d38b80b8684609

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.12-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 67493cd443b0635d1563b4d116cc1418a30c8f453e735e9e6f45d6ebf1f69117
MD5 94131187820217dfb741589faf6be5e4
BLAKE2b-256 0ec573fc9199b67cbea8762f75777fb198f26a38db0c9ed9827c600082402cbb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.12-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 06ff85807b9987036d55c202d0d5b06d80d9f95b8055bd09d4e4a14d82ee89a6
MD5 9ed3c2eb24f09b9758d7d1cca250c0a6
BLAKE2b-256 28685f2f93cbe963eead5b119fca71cb8e7b6be5ef749388d86a45084452879a

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.12-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.12-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0926930bc8273d8b427cd9e2a6875bb846f664fc14b0816a2274f5f865b440d4
MD5 76464754f84b27848fa5d825df4528cd
BLAKE2b-256 b63fc9bc9d10d5b6bb12643abc3e8905c93a38aac91f87281943ff47879f2aa7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.12-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 39fe6d1b1c491508246a80da1511aba6cae88920afe03fbba9528ef7273240c4
MD5 24fcf55120e21055b6b75af098b5bde1
BLAKE2b-256 9a4e472608f59c2e00ce16718a7ba9befd1ee918544800d61eaa089b03d5ed07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.12-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ba4604cc82865368e1572952288e0780ada64f1e206cf91d3eee296a129198a9
MD5 4f74c482fa715f847c44c2f531bfb721
BLAKE2b-256 5a0eba366d0f50fa7cabd5cb9d1801b9979f38d654dc00925b0ad464f81a9408

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.12-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.12-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 f8bcaa2fbd6d1b622daf946ca995600a8dbf9cbfc9e271df10835b0c315445cd
MD5 936dd02502a661c3b4868741742622e0
BLAKE2b-256 fef93183edc61400051932824f4763c4e749450593eaa13bccb4794955b74392

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.12-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 26d472399cb9187b4535196a16d7745c03627c068477c018ee29fe0d13e2b817
MD5 415492ff98bd0c36958116ebc5d1ce58
BLAKE2b-256 05bdddbb514a29d213f358bfa5550b8d62c85e4f46a24ab17b377686ac3297c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.12-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5b1259db18dbaadaa26a36435baeeff4249a8efe5fbaf584c453d885f0b61539
MD5 9d7aecf2e26394c87b08e68a49dc72ff
BLAKE2b-256 e85f72e2121ea92ceec13082087f199c1a46b2969360273ab0ab392ac95c8d5d

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.12-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.12-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 aba04c2208195c4f9e95bce0da7375bc6eeefc67b6e4cefd434620e2eebe4d4b
MD5 f95cee0384001a1e21262c84fd32757a
BLAKE2b-256 0ff795e4098f763d9ab4a984eefb962d2a1d1984f858ea6faf9897c565ccddb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.12-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 4bb67bd764074bcb62044a63fb8f2c2124cc8d355a2c39d3a5ef4d4cd5f813af
MD5 e4f47fdfdd6b48c70aa76ea96b29191a
BLAKE2b-256 08c107ef4a21a047f977511eb7da939c9a960fac5dde33041b0802a487a1f7c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.12-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5337bd91ba9dcf951ca0f95a16b9b4487b062d89f0f545f8404b9b2aa04e5114
MD5 1e530946a43647e7e3e94a8c458ced02
BLAKE2b-256 cf9f264726585345cc40f4b9b302f721a98653d9322263c810be02063aee384d

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.12-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.12-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 7348562a0fcb945c876c75ee231d5ba0e6eeb5d77bf03a7883548411b13ca76b
MD5 71073d2300bec6f6a6dee7fec4bbb061
BLAKE2b-256 4f3c266b2f61d6ff40785674dfde060f4e89e402d0bd48bea939fa8b0cdc298d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.12-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 e443f16505d0ae4b3b8334c94d4625a1430673c78ece83bcff00796a06c7bb05
MD5 360ac180a4f07497053c4e3f19a4c66e
BLAKE2b-256 2fac5d655e35eeb4a4c39a29436054a65ca2c4165cce87ac0f74d9d72dfa98c9

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