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

Uploaded CPython 3.14macOS 12.0+ ARM64

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

Uploaded CPython 3.13macOS 12.0+ ARM64

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

Uploaded CPython 3.12macOS 12.0+ ARM64

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

Uploaded CPython 3.11macOS 12.0+ ARM64

pyyescrypt-0.1.2-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.2-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.2-cp310-cp310-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.10macOS 12.0+ ARM64

pyyescrypt-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

pyyescrypt-0.1.2-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

pyyescrypt-0.1.2-cp39-cp39-macosx_12_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.9macOS 12.0+ ARM64

File details

Details for the file pyyescrypt-0.1.2.tar.gz.

File metadata

  • Download URL: pyyescrypt-0.1.2.tar.gz
  • Upload date:
  • Size: 831.4 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.2.tar.gz
Algorithm Hash digest
SHA256 fa3b9c460c447829707288f79da92f45e6c13b39220fccc7cde3973049831a84
MD5 ed8aba69e2d3f8e7bbe694db603af783
BLAKE2b-256 04ebcbe606303bd38b01ad2c3e2c0b918a3a86642e291ac2650d4feb4d372de6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 27bae92c3f73d34d339970051521de677594fd065e9926cec52e37cc3510fa26
MD5 fc8cc3b8830417b84bf5c556b098a3f0
BLAKE2b-256 299a8f03ad7f70bd813cff30c44c1053e4b589393e9dcd432427f2c97976f395

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.2-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.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e22e8dcc5228630ecf8e04615f5b8e3ca760cf10523dadc67e7500e5dfee80c0
MD5 fb670fe2032cbf692bdd0366e616f672
BLAKE2b-256 6f23fafbd66e0ba190f4c86a4432400a2296612ba7f3a6dc2966e2f7256f4817

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp314-cp314-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 007980b72fc0acc51a05a8723ea3feedd9623b4ff75e3620b1977c937e9b2020
MD5 31b9e46feabe7d709c0aab625f04d46c
BLAKE2b-256 6a192d6625059041d40cb793b4b525dcf5263e67ad258d57cbd38686e7dc8b91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 666cebe4c0667f91d57853b3513ad4e370b56a0e025cbbab8d30b08f34bd9a61
MD5 0d4176f0d298ca75751bba3cadce0ab7
BLAKE2b-256 461dd9453199c00afcc18f1633189ea02942dd3703160a50bbb5792dae20bebb

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.2-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.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 32b893d2bb101ff8ac578e27f4234941d459ae69c22df3573e462b127a32ac60
MD5 6c24a11757bb3a21a8c1a75e71ac2c6b
BLAKE2b-256 aa1260ac7c0ac1317a3427a6146ec71d7b84b5633d0d9f248c9c1494e5265062

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp313-cp313-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 7d1c5caa663222904677caee0a788d639e91aebe32f7c1c8131ffbce5f8ecc55
MD5 698c7862fb0101d4ba3e704a89a47659
BLAKE2b-256 5b20d9202ebdaf5034817f2d6b8a5f75131dcc186e4803b6c06f9195da6e99de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 067795809bf6ff6a2c5f14bd97282e8b243c23184ea2d30dcf8a418c158db9f1
MD5 f00e913eb497a20972fa01c6663000f3
BLAKE2b-256 03738bb93c0e5bf43eda14a2391f16b7b0439bc36bb7d2f555be7e1febd7760f

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.2-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.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 86c6322a2181789a830672ed6219010afc0b66dfc38d4bb2dd3c2f074b93a715
MD5 9a0d18f1413eb52058968fcea3cb6b96
BLAKE2b-256 828e496526094b7515120879fa0af2485c10790f0c3385ccf6b27581fd8a6633

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp312-cp312-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 6c3e78f26e3f10dac9bf45b87e225ee2830bd3fdf88eb32ec420e1f1c6d4d517
MD5 3b44795004f7890a9c0c4ac487210dce
BLAKE2b-256 6da1c907f4c663de797aee1746c2ea4a25ab171ade3d595a1be9fed5a510c87f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c1f87e1c06af80b7f1c53d685f8059b8ac79c0efef54149bc44b821db6b18209
MD5 c907c4e645dabc367506d091fbe58b9c
BLAKE2b-256 9ee1fbebc88b835e7d0537e0b4ee6fe8537be9c8afd5ffc19b40d99f33e15ad8

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.2-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.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 346fef925b0b5aede1306e36d10d13fab1a9433d3d2538f75446c6c286d9f2d8
MD5 b26cd334c3dca6c08edc2269ce4dfa6f
BLAKE2b-256 67c673eb96fc397d22a4b4eb94615aa35fd497888c02f25e6096ab95db4a1f7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp311-cp311-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 8085f1bd01475a6329757ba94fcb80a1368a2aafeb2dfe4cae649c226be8f126
MD5 31c0e51fd26c862a8e4837d6f5f8e2c0
BLAKE2b-256 5a0ece5cb6037f784007fea70a1f28c3fbeb057c8e5f1dcc170e9e621a019819

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5224c78fb06c2c83aabf3652aa31c5d8a8037d20934b835401951634b25aaeb0
MD5 ace7ad5284a7e26c94d218ab070ce081
BLAKE2b-256 444d0ad4b0e8d2f94bec3842674a425e5cb4de24ffdffe157d5f4e4e4c624c3c

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.2-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.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 cd4422c9db85832e24a20a8dc37f1ae4dbd01d9e6e30486fded9543f99db55b0
MD5 bbbed7d8e346b972bbc18d7f4c7dfaff
BLAKE2b-256 9b6be15cafd763122ff89cb1a8d22b4f790afb40876269e85586db12e78355fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 d906e1ef67ebaa86bad1ee34ff7345ec50148ca4d9925618396efc530528afd2
MD5 187d1cc935c474293e0bcb9cfabf09c2
BLAKE2b-256 8fb969344ac4a02556325a62ba1f83c64f932e155b010c95015c6fc9c2429987

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2bb8882479bb2f210abadf93cd462766011cbc52277de05e76080126a8b17ae1
MD5 5efa038d02e382f3771d21911100a4a6
BLAKE2b-256 2f55fbb247421ac3da528f54d088526ab7565fa63067c1a21fc039b9020f7f18

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.2-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 af1b42d890e981777096a000d9d965cb2e02b97657c206f29ed798d70640c764
MD5 c0ec492422e2cff30f7f363e36c046d0
BLAKE2b-256 09d09089bf5ba5cd83c1e8cde82c9e9112791613f95ea0c53aa67a99b658dd40

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.2-cp39-cp39-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.2-cp39-cp39-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 be6dfee904228f1f49f59bc41c67fbf7cd3807117c45b565f9b708ab91c4e020
MD5 de11897ff1d82820826212d25ab3dd40
BLAKE2b-256 e02993f93bd4c269376a3ee2f8f596b365219cb36a81fe1f54e6c8653799d581

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