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.9+ recommended (package metadata says 3.9+)
  • 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.3.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.3-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.3-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.3-cp314-cp314-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.14macOS 12.0+ ARM64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11macOS 12.0+ ARM64

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

File metadata

  • Download URL: pyyescrypt-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 ca6f5f2fba5dc6d03a8ce69edd96ec8a1a8456906897b6a0c21d70e8c63240e1
MD5 dfc6f8956514428ebc55ad7ae8dca704
BLAKE2b-256 a3c7ba336f949737273c6fd76705a06196d9217182665beb0257a23e6b50190d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.3-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c316244a9a76aae950c221d449c9e0affe423ec2e0f1a129e344409e027ce261
MD5 43f9a73e5505066f7b70e7ead13d5a44
BLAKE2b-256 a6c6923caffdb4cd63ed7d2f9e2fc3d16079971af1ce4e05676bdde598651746

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.3-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.3-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5e446e812e726445396a8cbafc93e1f472d660fefdcc4c62f35ce01fac248b2a
MD5 c446957d468cb26ad92bcf629dda90e1
BLAKE2b-256 9dc2dd45bee5d4ec9ded6a5321f0c595e89bc90034ac639120a74dbc96d3957d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.3-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 bdac144d8dcb8369589384fab3a742bd970217c7ffad140ec439d418ff90cca7
MD5 c9ea64931eaee2c74b04e28be97ba0bb
BLAKE2b-256 09167cd20f1196436cdca020ab070668acf9cefb242aec32b60f562e878c3142

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.3-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f5679334fbed2b6f46f8c2bca693b7fd7612a512f3cc9cab204d2eaf38a07119
MD5 f997b3e7f91b2fca7f28a69aa657facc
BLAKE2b-256 7fd4d242c2000e2a5fd5f1977b32afdac9dbe4e41f67919b28b45a9636ff8bac

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.3-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.3-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 205fe4e5d052baa9d4c7ce597c466df419439dfcd86bfac40871650290fed6d0
MD5 e202c5ecedbc356569ea201ea3e3e905
BLAKE2b-256 119fa8e48aa94c01a3e9900355586678aee86659094dbccf3f8310676e12d247

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.3-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 3c27ee91ddb588721e05cbf42119fde2be20ae6fc9a846c2d7aacf10087ad4b4
MD5 11355161f1701992da41cdbef1d6da6b
BLAKE2b-256 8a05d490baa964e187e7c41843888fce60c9077e534ed3c693f10ee5048f6fe5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.3-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 dd24526e5bb2aec997662e0e9e441409848b56605b02cb6214d7d0e713e05660
MD5 359de95b2f81b53bf22023355fb3a1b5
BLAKE2b-256 424c7606529495cca78ba3ce419d75029fabf484707a11ee836dda94da9b6cbe

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.3-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.3-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0b2e4f382dd382321a8ae729259b2e8c8696a544f9d677290ff5e0c491d2d530
MD5 f140d792dd8dd063e130695090abf440
BLAKE2b-256 c77a3ba10ee65c2d34001939e312f997e1d2bec96340f5be734b7e77fe0f4305

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.3-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 95aa30d2ed951a6b582eae2ae8817771e042ded19b62f72d8086ce498a17c1d7
MD5 6152ba95572e11a559e55ca2b8c1ff95
BLAKE2b-256 82aeb1cf19f893af79b5c1e63e46d641c99064841b0a69519680afc89cc1e249

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.3-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0e2f5c2c857e9fb5dbda8f859220cd48bd67e211e4d44ea65b8c7e9935fdeeef
MD5 2da80bdfb8c8690467b971e83eb4c16e
BLAKE2b-256 c6daaa41f695b375ab7bd8e92f41607264624e898b8d70c74f5a196c4a39e5bc

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.3-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.3-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 523485620d77c589d90bd057b044c17d25c59427cd25c22acaabbea87947f3f0
MD5 ecebff2af12d83760c074a7952251713
BLAKE2b-256 b87a37dd67b37f79acd6f37a0876a867f33026634e7883df2680d355870b7579

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.3-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 83526304808b6dd3fbeb6e836d24772849977d80c0d30ccd64ce5f462149e96c
MD5 ce99fa83e5ff706d713f1f29f7d633b2
BLAKE2b-256 6ccc311be8dce8ecee27c7154e8e51d9519f8dea03ade90153d25588dea159c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.3-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e8f83ce809817e0be6f88f7d8dff1cd806374ffc3024204b9097f9e756fbab64
MD5 ea600c9b6bb4679acf11f48933281262
BLAKE2b-256 86450b9cc413d4f0236f508679b0f08b02d057a106212b48d3d6815ee3e18f41

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.3-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.3-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 74a084c5a575eda3ee82d5209cc8ffda29efb830ace04f89c75c1c794d6b2954
MD5 f1b06e52c24d96165edb3a5f0b3ea92f
BLAKE2b-256 465c8a4876419394c77ce4f4cbd903e4658ed74febb728849fb36f3b27109516

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.3-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 439bb26d749869e696a8b7278dde7b5be883189092242775b94d3df4a9b5d493
MD5 cb2d7aa35cc10b34ea67334c73c6294f
BLAKE2b-256 2e4f575e6fc762924cab5e309b3aa698f026085fd66789d6d5add3e65b9ebff8

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