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: libyescrypt.so
  • Windows: yescrypt.dll

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
  • src/pyyescrypt/_native/yescrypt.dll on Windows

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.

musl support (Alpine)

This approach works on musl if you compile the shared library against musl and build musllinux wheels.

Practical pattern:

  • Build inside an Alpine container (or with a musl toolchain)
  • Ensure CGO_ENABLED=1 and CC points to a musl-capable compiler
  • Produce a musllinux_* wheel containing the shared library

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.1.tar.gz (20.3 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.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

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

pyyescrypt-0.1.1-cp314-cp314-macosx_11_0_arm64.whl (761.5 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyyescrypt-0.1.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

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

pyyescrypt-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (761.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyyescrypt-0.1.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

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

pyyescrypt-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (761.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyyescrypt-0.1.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

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

pyyescrypt-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (761.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyyescrypt-0.1.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

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

pyyescrypt-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (761.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyyescrypt-0.1.1-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.5 MB view details)

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

pyyescrypt-0.1.1-cp39-cp39-macosx_11_0_arm64.whl (761.5 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pyyescrypt-0.1.1.tar.gz
  • Upload date:
  • Size: 20.3 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.1.tar.gz
Algorithm Hash digest
SHA256 a4b09c719d23753bf901a0326e156167107c32a9ae71b8fd222f78520902588b
MD5 cd3d2049a5881f59ceec0e71b1890f6d
BLAKE2b-256 cde82ab9c34829f538d6315b70e28e9c74aa468dc6d4a0d588be206bba0381f3

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-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.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 1558319169dd8751454fbad3fad17144cfa4cfd7ba0e773427759da1aab74ae1
MD5 ac6706825ddfae9db29a0fd06915c0ed
BLAKE2b-256 182fed827bf461031075b336acd9ea6c370fecd3fc040410713843d02269166e

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 12b4b6287ab737b4c48265596c50054cdf2d4ade150e365f73b25a69004de65a
MD5 7d252c27f500673494512d4df4dbbe48
BLAKE2b-256 13b50cdac4d4329003406eb18ecbf1fbea01cd9281ff70b441f809200cbf8871

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-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.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 3b87758a76120d236eca7b3cbbfb81172e387b2547f647b100308140dfb59658
MD5 849a6ec0d31100d289f2cc3601977321
BLAKE2b-256 f5fcec1d1cde0e11901867259e44a4514025d63c5245e87658627a7132f18cb7

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c7e1fed6ff1a30a84c47131f7d8951f4072fbbbf77f61f12c9a1b8c1a02c2894
MD5 5370db9d2a5d32b3dc2d96dafd8e721e
BLAKE2b-256 bb6b0275bd61be761a1bf9c5f525170b728c9c466719ddfd0fea3e9ba14b33fd

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-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.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 b4c8ceb54d35f5932ca48203bef344798aab74e0061688d947b870fa45736e64
MD5 bbfcabbf5420949feaa842da4787602d
BLAKE2b-256 5ebe0c5802af6adefd9e17d640761d297323a930f1d40989b40ad0c2b02e94f4

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dbb2c23cc1cf3e1e7a3526a900d5cf089fc13a92a97911a33ca360d923334c64
MD5 cd2da825b7999f730a4664a7b8bc1eb6
BLAKE2b-256 d30adf05266f3221dcd668be11987f92bfd7476aa8dfccb535248a2abdb5e591

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-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.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 6499b8ade924424c7e9da48ab16539f5bd9adc0e73c8c6335c0368ee4d991111
MD5 7028f8c5c17ae205e5751a148b27663b
BLAKE2b-256 41a830c3b2f1c09506fa8e5160594f9951f463934aad0efaea78acd17d84e8fc

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b13f2252297a12f4698d92b6aa35d6058e987441967aa8f3bff531a0ff76dedf
MD5 e824705ccd28a1f8d913389879733db3
BLAKE2b-256 01fbbd628b35674a23db2d9969d5daf02b180f2b3e59527f87ed905ee173eafb

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-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.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 d6d31ccae37f7a92809f7099cf42058cc81711b10885b85188dd2a8d6cfaed8d
MD5 3ca6ac742c18c3499dd8a045ed16b738
BLAKE2b-256 2c977e14873d6cc2c4c52197fec3ad0e7a1ed9bfab35709865d3f8c2f7073880

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1dff4ddb121c19a877646dba4c0573a082eec05e822fc4856a8cabfb42628f41
MD5 a7df4fd7a5153d198cf84fbf608b91fc
BLAKE2b-256 f22ab4d138d1f56a54963217763b026284a0950c0abc9e2075c2993dcc5c0c65

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-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.1-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e51e9569492b00de406883dfab13ecab06d7a1d2f7b45fb9b927924ea531af2c
MD5 eeeb80737c6f9068262968b4c1ff1bed
BLAKE2b-256 d83614373804d18bce897bf60e3cbd203ec71ef5b3f90e574f5e46dd40bbfdb9

See more details on using hashes here.

File details

Details for the file pyyescrypt-0.1.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyyescrypt-0.1.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ee0dc6792cc8f088c44421dce95b62c852420c10e71531854a8206d619e9239
MD5 2fff3826969442d11c64b6dc631a8b76
BLAKE2b-256 f41951b4e31a6876fa96d64a9a0e63438121a2ee13d7685152e742646a1320a3

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