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

Uploaded CPython 3.14macOS 12.0+ ARM64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11macOS 12.0+ ARM64

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

File metadata

  • Download URL: pyyescrypt-0.1.5.tar.gz
  • Upload date:
  • Size: 22.5 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.5.tar.gz
Algorithm Hash digest
SHA256 513102b96e00f62e3bddc7ab0ea1bd89d30d78f9a8eac5820ad86f041830d539
MD5 37c61ea1285c11b80e558d9177c4d44b
BLAKE2b-256 d2555735ef713e92e7e3d593614067b17e0236c3d13ca526c9cabe7f592a0dd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.5-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 29530147e16588d38267664f618d15498c1eefe11b8e44b75595175f7a378b20
MD5 9d3baee7c51d16845878427bcf53b4b2
BLAKE2b-256 e9bc579a147d19b177518f254ad705e520290b1b68413f72442f79321a547eb7

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.5-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.5-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e5d5cef35488d39199ae9ca3df2e3fa3b391dcd9a8ffa495d6bb58070f8ff024
MD5 7160db6acfd3aa24af6a813b31cf5087
BLAKE2b-256 62b3c7c165c85ccb62ff6175c2195724c326edd9e8b99c24741bce572bc612f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.5-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 4f917e43cef8441c971ff207f2d4b115c0d908c4e3fe555e8d91472126efdced
MD5 6b86a307b40c037ec541084564a5a0f4
BLAKE2b-256 9c3dbe96cd8b2987bfdda724548d26cfbd00aa94457b52d288607ec913e39303

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.5-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8b3df115070f3295905ba7e3f21a80cdbd9a6a52f7c59358e7a2cd679fd95563
MD5 0ed287aed59d3e2a999d23b49bc60ed9
BLAKE2b-256 0f79e5ec99de6f3ef69d3bf2b37011a69de70ac1dd5f1695548c60bb10faf02e

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.5-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.5-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 54706b5f122770156123e8d20297a4846475e714ce79e9a2db1a34c979d56e60
MD5 a45b114a2fd88376f0bcf8cf4fb503bc
BLAKE2b-256 70f1d08e9687bfb2a3323199373c0d71ae2a1fd0da1d3a96432328f6b9766c78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.5-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 7a889a406a3be6ce4449ad8c9e6ec4ca427485f9f278d8d0ada884be353ce636
MD5 c77babafdf56bb48abcada0b8144bce5
BLAKE2b-256 4fd82d4596d8ec36c4a76a69417dfeb2c7829d710f682be1af7a3b3e24d5b685

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.5-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 438ddd2fd2f6391c62ec3b2daa9beb1dfcc7cab1750d3e04ccdfb917510739ec
MD5 12bccd1908e828c55901bb16f2d2a10e
BLAKE2b-256 29f2deddeab4ddde6a47cf6e74efdcf836c4736d3e666c354107531c66521176

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.5-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.5-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 878e1d4b77e43eeb1b721556da04ba9f564c6c2109d0b8660730e2d53deafdf4
MD5 284bfdabd6a639f7865ff3252b620084
BLAKE2b-256 f860330d3fda9e2b8f37c3c9431d83491bab369fc2a8abe19ef215305ee45d17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.5-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 3782bc55e9b298249349f5396b476c76df6ab94e3e06f3d18a8fa91eace875d0
MD5 1c766d9f33e4604762171294219c611c
BLAKE2b-256 d13485f4463f101c39e0f84e7948412d08cadbcc347d3c4dc47af9e103679c67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.5-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e95b7e60d9c382a30d3a9e478a246dcbb31a237c0d80cefb5497807a0cd4dfa5
MD5 17bb0136d58d16f069aec701f0a284b8
BLAKE2b-256 677a9a2d1f10813d8a59e8677cdcef2bf2a0488231cea20cac15186cbd7c4fcf

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.5-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.5-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 a28ff90574d27e74466a735c4d23863ed19b803f62c0dcb84d4a94d7bddc4c98
MD5 ac465638c750c67ebee5bb1b4c6ce07f
BLAKE2b-256 14be986587f7ee47f77a84cff3f1e89574cf6e151b9e46a57b93b5b6b6894430

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.5-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 6d4dac05329a341d005be5ca1c6aec68c2889b5e83b75f249040e9418369c42c
MD5 ca6227a51c3dcdb37c253dfd0ace1b82
BLAKE2b-256 240b05242d92c9063d5dd9e3a8da362cd6c9c2b3d954af425db5a04ea1b92005

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.5-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e40ff1397071e426a525380e406cf0769f828de7cf64d63a275d8c390f12b780
MD5 3dc813bbc5e2d3af70c8dea970145fb5
BLAKE2b-256 1d67f976e62473367481f78973bce31a7ecdae2a9dab6289f8938a324ebe593e

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.5-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.5-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 fe0517f67037da8aa0a2af7ab282573b13bf7468e7ade03a33217cc9b610bd8f
MD5 92329b4093e1e71807cde23771340fa7
BLAKE2b-256 a6712544ccbec0cff659a41e685d1618a2d1932f08b165d470693d1c543e6669

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.5-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 eccd33751f8e2562edd37e06036e1e269a2934cf8886d99f1a7cd282aa631395
MD5 9afa70fa10cde2d4f69fe0d3af1af460
BLAKE2b-256 c78ea07bc36eaa498be045c8e5c3b01666dc175881e84550df386778ad92f9b5

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