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

Uploaded CPython 3.14macOS 12.0+ ARM64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11macOS 12.0+ ARM64

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

File metadata

  • Download URL: pyyescrypt-0.1.13.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.13.tar.gz
Algorithm Hash digest
SHA256 a60a0dae01bdfee68816b69724af53255494a846b4e401993c5f9a13a68c2ac9
MD5 765624374b7c86e0a8e54c71df53cc9d
BLAKE2b-256 a922e2f2707a8536cf9cb7fb8171020593374ee6e60ed17a8e9eaf03cae1d80c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.13-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 52bf7c163b285cda63ea9159256f85a99c322c42122ed0db59411ed395667a51
MD5 15951e7144197a3f5b5a53dfe48d3b58
BLAKE2b-256 a6157560a63a5e3bf2215c2bdddd8f60bf3e2588dc03572e3d6e52470d60efa1

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.13-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.13-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 6932550d963ed4a99054c9ac82dfa9f1579260ac71f68ea949d2f2238381ac39
MD5 854405bb1a9c28c80bd5968b3df14e78
BLAKE2b-256 5bae4461d4690aea07e915f0a83a131daeb45614b01c3dace2a4aa538b9726a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.13-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 d81390d80047424c445c3d4c1d25713bb11fa5a621c247cecbf5af5a6e0e2428
MD5 2e07d31600b176d17af5c9b9cdad18af
BLAKE2b-256 6c8544b933d5c97322288054f4a29c7024e0b4b4b0585200aa42f4b7246b0ff4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.13-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5e837ae101a1fbba6c8e908ed55d0e4a3f825d288d276c9193a9b58e7e22db97
MD5 838f89205ce1563bf08e166f0803fdb4
BLAKE2b-256 7743c323fcc52732244af5fdc1df97ecb34511b11560d5fb768c5c7e9b22128e

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.13-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.13-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 de244ac69c6d85bef6d89ef423a362d86e15bc32b06a87aa817eabd98ae39f82
MD5 f9435693e9266e0ba31a7ed60d970cfa
BLAKE2b-256 9b0f93b05179b69ac9ad14b8a5da76c456e13130ada926b5207a36ee4b37f2bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.13-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 5941501822d68e66342d1acdabd1fed7a5f1bea9cf7c8dd4121cc9294c06515f
MD5 3872137a08a5d3ed53d413ac498ff93a
BLAKE2b-256 57ed1bc48103f340f07a47860a6f6f93615faa7846b898e34e56ce84972428ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.13-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 85b74f74c27edc3ee63b236d043f428856282954fbad14bcb8e13a8861c7b2a5
MD5 7dfe96a287bc6d09bc6c6887958c3fda
BLAKE2b-256 666d80a1ce8ccb5301fb9d602cfb00600735eac96857b9c3b15b6b0517bc2762

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.13-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.13-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 1b270ba66db85194e5c9c6617e4cf27ef557652b24e2536886e0f19345b13b7e
MD5 829fe206123102da7c82cc547fcf00bb
BLAKE2b-256 ac6f29c90cf8b2c458b28207f8ea5efd07b53fac4aa02c89d492953572ddea23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.13-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 355e05b9fcec40e3a79e0357ec7ad44f6ce23ffa60cab5759f5b5e57708b4213
MD5 4d37720d38d6578a2f90c3f566ca89b6
BLAKE2b-256 416f0c038180ce1df805028385e216509541904e94f2ce174c9775196851ea55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.13-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ec9ec34b23ccc5407c5e72bac7aebfcd96fb789482cd2493d1c3dc08de1d41f4
MD5 c5acfe51abb43bded7d5b09e6f5ed70f
BLAKE2b-256 4fc0f4c983b4023f50e4a9a50f238efe9e2ed2c981ec52f6914e6aac46b8e423

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.13-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.13-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 4508e7d80acd69acd471249dae91d249a124e30bf0f86320f6a15a058f1a092a
MD5 102be4ffb689f1f1f467578a1c0b6c70
BLAKE2b-256 0c08166f65391685cb3306f5ff4f47ffa1d957ce0dd91456606dc2b69f25a2a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.13-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 a4bfa244eb084917ddae3b9dd48852ca31bb2d5a4fc2f43ffb4a460055d0cc21
MD5 2cb9dfe192529669419a5cd86c27a4d1
BLAKE2b-256 129f9520ace70c7478ec480be6b0442c0ac21afaf01b40ea4efffc6606ac55fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.13-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2d1ebe38870368ae305745a03f433e65e6942c0942b2306d1a0b99296fe6a03b
MD5 4ec887c61f9fec5d68137e98286c9e27
BLAKE2b-256 e2586bd73e34b6230457e5847fa053675a41ef99c29772135c9a700ce05e5783

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.13-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.13-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 77948960257059f895e98dc712379bf009999a2be491639a0bad82cda1c5cce4
MD5 42c0fd366e0496d59c8f442bf694174a
BLAKE2b-256 27d7adbce944768c71b73fdff761fc5f06771e76e776f74628f4eab0d12110b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.13-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 a94ce2c6a53fb3680f4c70a1b7693e66930af0856db9a3af88432ab6a0d5e9de
MD5 32f3ae86d7363258877ea2881cbb9983
BLAKE2b-256 ef604b7720680494fb23078e92cb0ebfdd492029bfb31e833725c98599049176

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