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

Uploaded CPython 3.14macOS 12.0+ ARM64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11macOS 12.0+ ARM64

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

File metadata

  • Download URL: pyyescrypt-0.1.10.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.1.dev30+g2d06e1177 CPython/3.12.3

File hashes

Hashes for pyyescrypt-0.1.10.tar.gz
Algorithm Hash digest
SHA256 dacfb20ecbfd7ce8fd80436d3939758652a8be1026708914b7c1408697d4373e
MD5 3d9e61d5c12ef5fc0680a5ff7ac17d13
BLAKE2b-256 e621141f329ccceb75aa4b6fcd6339259a76218870d0d9cc5f7d81a65920c744

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.10-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5773d4f99f65adc4f19ee609c24f0db1594c174b9df124db4fa2f341cfe13fbc
MD5 70aeaf281baad23d84b96243fd33e878
BLAKE2b-256 65b6a0ca26cdfc3568aa1a34ccafd9c7feb37d289337464cc98fbb19b7f6bf90

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.10-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.10-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 10d7ba950f09b36ac2ad31020db17de10388c72899367afaacc854aa7f43cc8f
MD5 b0edf3eda4dcb0a1252a51a4155cd836
BLAKE2b-256 28964fb7890a5bc7c7021416f80372a882cf4b4ba829d3e6d5a0fb56ec98d5be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.10-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 cc68133386e74f8ba7eaba442383e434db762beca375552b5cb806560421e74d
MD5 f105f0382af3b5a7f2dfc3e67f7e84d9
BLAKE2b-256 cef051ef8aff734e561b0898a409e16f10c361d2fd9dbc1d18168f0045bcc9d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.10-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a6ba5da6640b98683b41788bae850ac93711f2abea4819a4582b70ef0df6b6a0
MD5 ae9c5230b609560d551697b50c1bb74f
BLAKE2b-256 c3e6735f9dbbdc015961a5c025360ecbbc602766f677b4ce258a1accc9d04dd2

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.10-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.10-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 6a69bd7bb22e63547729087a7b17711f2a169bb094e8fc712cb67c8c42450997
MD5 fc0bcee1e1f3b60f2c720653535710b5
BLAKE2b-256 5ef44226807332968558e31e9a4b8917960ec73afb5e7cc08797aa13b7fdc8ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.10-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 e16cc00ab40a48570c5ac599916892c85f898ff673754fea86319a1551fdad42
MD5 2dc200a0164cea5421f3547fbebb2cb8
BLAKE2b-256 ca9fb6f166252857ba492dd675fb95bd68d8ee89f7d62d9388b2ad10c09c6b4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.10-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ac34de95183aaea51c2086d05dd55b05d5b512e01faad10de65b65c385d210b0
MD5 2615627dbb14991e795eb31fd075261c
BLAKE2b-256 38f35e6143516648e8f2d3b01cdb07e7808d8deab8143d99be046a7b8d116ff6

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.10-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.10-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 17946c5d35bc7ed671115e75659a3e21488c99d0de8b703866fb385117bc3c3a
MD5 b31b6cf02e14049679cadff18a12ca47
BLAKE2b-256 078de001a8e38b0a73472062efe13087f60d051977eb4d1f7de86425d6afc502

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.10-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 98edb49c77329be3f640949fefa538fc08b416a8e65fb2a715944165245f8707
MD5 daa6789103a3e32ba4b2318665ff9a16
BLAKE2b-256 0393d5230fa4f1b7f4b36e5b72a7a4bf302637aa168326b00e7d83b2fa64cbcc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.10-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 eeaaba7fd2fecebdd1491692e1cdd8d8818b309055c0cc55907098f863a5fc89
MD5 b339a347498e5e5f1ce8297fdc443ed3
BLAKE2b-256 5cb2f62b2b31186cf48133a9bc40e6aa216356bd7276eae163e4827a1374c15b

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.10-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.10-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 47208db5ba2f50acb0bcff18d6d347eab1359a435ab47c37c9d8eea470b3d537
MD5 978585c9a6a4cfcbcf3c17fc176432d1
BLAKE2b-256 7fbf27dc48f33b531c6c459e4f0e40080c2cb5657c524c5da8a929aa39332ae3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.10-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 d89e645071ac7bac3022423375f508d2e19a2b903ac5a7375de763d03669b750
MD5 8812046dd23993c0f96d9cbe57e616fa
BLAKE2b-256 48b7080b0578dc45047ccb356d61fa2304ee5024e78cb539dda694c721e02e0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.10-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 003f8b59347fc24c9aa3d04f268d4883b5181025e40dd00030765851848b9e70
MD5 1b746c6e60b55eb5d3f6b14b2757af9d
BLAKE2b-256 0a241a8a7e16af240e76710f4cea651a378f4beeeb74cb98e1cdbbb66903082f

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.10-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.10-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e223bcadb0bd7c6146ec3bac861c69ae71e5383dc733b7e82a3390145df6e702
MD5 f25164075c54d2597ae62dcc94e36db3
BLAKE2b-256 82f90947edb7de0d5626b1ebc548a5613e59149411376ebeeb7b3d43e9208e58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.10-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 661b55dd071170f51275cfda2f798fb080b9a51811f9eda80271e44939d4554b
MD5 edb55d0fe67afe7f2e9b829ca7af6ac5
BLAKE2b-256 3b1133491f9a6ad97548c22c6729010de995bc1f37d76acd1e00432201a907cd

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