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.

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

Uploaded CPython 3.14macOS 12.0+ ARM64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11macOS 12.0+ ARM64

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

File metadata

  • Download URL: pyyescrypt-0.1.4.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pyyescrypt-0.1.4.tar.gz
Algorithm Hash digest
SHA256 69735a718d84152a2a51d81e2c63a28d641e3aa32f439c0343ab3b1702fdc9cf
MD5 54310065f669f29fbbfd3554cb81f5db
BLAKE2b-256 34930c8249bfffd4d0aacea0033deb96a45c65d292ce0b7d44907e29001728fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.4-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 657fbee26b95a1583b0a2980001cd8c932e2414aa6f25482a0bd8461f911c776
MD5 4771bd1a9f8673779434ee1917d312d7
BLAKE2b-256 1d5406f0b71e1c80fbcbd324b1bb176edb6457ffb2570479255df00d7311177c

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.4-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.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 2df567fdaef101d82d676d2dc830547949069649ec05c28efb5f9313edc8ced7
MD5 4e190bf826d64155223fea7e5412c4bb
BLAKE2b-256 2fb46971779a5f9efa90210440bd85f3f4c4ab702adf88d1ebe4ff44da12ce36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.4-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 ddde9486ee4642b7bc48f7a0e2aa5b37f5e598db83376cefd31dececc36f64c0
MD5 970fa13a9bebb40631493513537d9c80
BLAKE2b-256 4f2b72ad4e350d40458b441d9c850c67e5d77b6a65c1c2d1bc79157a730ec37f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c039311deb8cee0b17d9c29198d9f36c2e15f76519ab690c42299a4e5ab9d592
MD5 c83d3a168c52b69bc49a48b45dafc77d
BLAKE2b-256 e48ffad77806983ff4a68e5619647bfc0852fa597f307dfcbd25a9d02db7959b

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.4-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.4-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 68ebf5ff97330a8f027e18cf8e5e05012572e9f63b5daf39bbd02bbf670c2844
MD5 90886c5672bdde39671abf69667c78b6
BLAKE2b-256 94107ff7e435d6794087aba30decb90a6384d5515fc15314456689b7dfe2a183

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.4-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 e4977f907d6204636426d4afd784b94929c0b5a1ff83a560ffa2a3cf71c71378
MD5 eb57e4658614eb407d81bf7f73ad8711
BLAKE2b-256 0a43fced5c6463874f7533af9494cfe9fcc2a43cc1d20692f9194faa94feaad9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9f7755797c960cdfd0d57cd9e4ada614dccc0390367413b6650fb896ff5e789a
MD5 7d68992160df23d4d1701c1df4fd7f5f
BLAKE2b-256 17d67d5d3a31ea4fae80c2384297c0d6f734b561b0368dbe5eca1b88af12cc9a

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.4-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.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 2753c1722779b2be9829b4dcbed71e1e6b33e41cbc36fbd47988b8b0d7acaac7
MD5 e903be2019391004afb735055763f18c
BLAKE2b-256 18457d6ff3c31ec52e7d20c183e6d4703374550b14c9e9d0d03e9fdd58a5481e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.4-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 a506ad1dfe498ea017149be84979ce160324a6f615ed8672fbff2fa8af64aa7c
MD5 715992461d31969c3d240d4338463ef1
BLAKE2b-256 6be4c0d2ddeaa6c54f9b915384baa358ebff6d369eb11630aa913822fb793d52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.4-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e4824f93c09ee174560e517662c519abd3eb7d64c83b17a19264f5deeecedbd1
MD5 52d040aa66690a966fd290ccab0c090f
BLAKE2b-256 e8d44f451620ded228f37ee184560e747e12b28e411b5cbfd3b7fd8268cf3022

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.4-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.4-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 2111c85aa1a5a586df9a3430db0f0a340886dfc6158565116107d70d27d4c510
MD5 9eab9b5e3048376ac98b728adeacc1bd
BLAKE2b-256 fc554d8dbcfbf8c914e12f7fb52f8766be3ac68509f5fb2c60dbd83ee3fb8c4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.4-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 bd374213965f37001cafd9e64d940ee1adc3a8fce55695fba611246431a3fb54
MD5 849025efd08e517df226501dc7dedb44
BLAKE2b-256 2b8032399b22c44df59939e2606f6f26eeeb3b47b032241df2c5d32dca1da64b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.4-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 aa60a3b98cb69685e5dd24c70ce26bef13c26ed346fcebd9d5fef3121c09e2c4
MD5 0d32596097fcfb97d9b816260e98c864
BLAKE2b-256 11fcacc407451ef0bf9d2adff4ee431e4fa27120a41635c22e44bb5234522034

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.4-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.4-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 33536c6bc3df24394b50daae2b71d4d753a75cd89f81f950554056dd480edf14
MD5 8fa44c50cfab89a403c4449174114001
BLAKE2b-256 9a737d9b976f1283ea3b92b12da1e3aec376e4c8efd291524f4edd8fe34cd3e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.4-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 e5f3bbac3df9203d9d3df012cfeb8d951b54ca93919d8db41528893a984d33ff
MD5 4777bd59012e75af42f8da4a23a2e462
BLAKE2b-256 1f38518b680209ea651b9c1139864e938cb26475811f39615d12e77cc4eb61f1

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