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

Uploaded CPython 3.14macOS 12.0+ ARM64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11macOS 12.0+ ARM64

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

File metadata

  • Download URL: pyyescrypt-0.1.7.tar.gz
  • Upload date:
  • Size: 22.8 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.7.tar.gz
Algorithm Hash digest
SHA256 d269d28ce06a30973b2546ca0e2ce32a6068afc409e578bc209649202a4ed897
MD5 137802ae5a9c2545d109791a856efb44
BLAKE2b-256 c3519a50af661e2d1c26daa2a4b80e9203d27c0fe730d7417e2bc98acd62f293

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.7-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 063bb35979878efad090937f9e295aa8ca0c9fa8f7b86f3c714335f3989c08f5
MD5 30662a37ea36961bb739a86101ac4119
BLAKE2b-256 00b840e932b0a92910ea4b8637071428c9e8df84eb72b47a4e4d12acca6a38e1

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.7-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.7-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 7e6203d37eee49b2458cf3217511760e79f0c213438d56806521ccba5a73ac9f
MD5 c3ae0c081c7e9799f6de329c4e8ca896
BLAKE2b-256 243ba14757cfe50fc7e60d473b393b2b5c296fea9a966ad1fa11eb8c9d9cca5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.7-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 cf0003b3e047027a2f11e64b937fce1e3c3a5fa1d3fbbf83add46d9761188589
MD5 124fdb3466699f523a8d5bdc520d5411
BLAKE2b-256 810034697b1c002e22d20bb2dbb01d78ff97fe37c79079ec5e20e8804213fef2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.7-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d276fd6de8ff6611bfb097b89c69bd90de8ce56554aa6a99f1f18fa7000db19c
MD5 684e906f8713bd9957ae2b1cac7277e9
BLAKE2b-256 8c341179ed99d40e914ccf13bfa1e7cc5ab2d40da28eb2b30cbdf78479c0d8a3

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.7-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.7-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 cbcd51128f9a5cbcf2dd0eed8f4129aef8d317275249687e1168df5cf3a6d9f6
MD5 51193d8ff49b34b8d6746943ac3189e5
BLAKE2b-256 f2257f80295a85643fb336cbacc1353dbaa3957568484d3f39a850ae159e2277

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.7-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 b4ce219278a083fc1f12f9a53eae66666c282504efb6397a845f95ed3eb8c32a
MD5 d1f67f44140212bb5c24e9f7026b2a1e
BLAKE2b-256 914d77c5bb3dd9987f16c958141eb03c57954d98febd49429adc6a43201eab84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.7-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4a19205c6c6b9c480aadf76bcef83be426327aa192b6936948acc369a4114e7b
MD5 2eabffdbecab87c5a9470c502f314007
BLAKE2b-256 7f6ddb43b7a8af35516480c8d3df550e8ed4a2f3bcd836dcc0887f2bed408c14

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.7-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.7-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 3b667b7edaff0fcfd59a1bd4ee8d1b21a01d78faa8fbbac3fe48a29d452a3223
MD5 6b920e45b9cce7cfa4c9a417fbf81c94
BLAKE2b-256 4decdb95b59ce8e19b88f3cf7c125181161e7cc926d0df2ad8ea19d9030e3b54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.7-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 107f325b509f1a1e0d272dc32dff1442fdeac8a10db0a4da2e848def9aa591e4
MD5 ea8c6250cd370dcf982997d0561b9030
BLAKE2b-256 b7f5919cdbd65c01bebb9bccc49237372447154f0ed10282a1794bddbe7bf0d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.7-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 195fc6ed5acf3921ed101163584165dbe77866dfed87378c132512dc134844b0
MD5 258d09d6c8a7bc0deca46db9d1c1cb97
BLAKE2b-256 80920fb20e7c0863d0c7ed24666adf4bcbef4bfdedd061a039e755461b5259ef

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.7-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.7-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 57c6194549f432275ce0878f9d2e5ea2297b22f2a5834dfee74d58a6d447657f
MD5 df214790f3023e7380e37886cd0e92bd
BLAKE2b-256 cfd7b9fb2e7676be111da2cdbed9ad72077a2601480b9419d7e4864a76e92c2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.7-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 5932e00f8014438a483d6b6e79af0ad43736a3a7f1b48e637b866b8403936a76
MD5 646b925a016b96dc4fa006b5731ff71c
BLAKE2b-256 74dbc343b3e44b720be5b679f621c4e914a2d99d1235b8f28ff63715b0a06fca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.7-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4fb033530ac6a51ded59ffc0114e8d589da6b1553baa4cf84e36cdf4fb7596ab
MD5 77b3a19a43b772717339912282769d76
BLAKE2b-256 ee886bc7ed39ba145a59888e81466d3ee43dab4e61daff0c31dad04caf193d23

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.7-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.7-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 229e28e863a76baa2270de44b370bcc7fa72ae072ab6f3a7156dd38d2c71fd0f
MD5 32574f79397d16e6473cef76e87a5c88
BLAKE2b-256 685283d19b4d55d08a44ae5308ac7fcf53874133800645a1baba64c6ed3e58a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.7-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 682593b37f407dbea4e338b42d006dd1f13ebdc3996e08a83b04c3e214cf98c6
MD5 3821eab1971af947682e68d91a532d77
BLAKE2b-256 bd3ddb65c7287cf55941a6d8fce052c12673127db69c4bfe8abd04de350beb6e

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