Skip to main content

krypto-py

The Python module of krypto: secrets in locked memory, authenticated encryption at rest, key derivation, signatures, key agreement and password hashing. It is the same API as the Rust crate krypto, with the same names, and the same Rust code runs inside it — so what one seals, the other opens.

pip install krypto-py

It needs Python 3.11 or newer, and is tested with 3.11 and 3.12. Wheels are built for Linux on x86_64 with glibc 2.34 or newer; elsewhere pip builds from source, which needs Rust.

import krypto_py as krypto

krypto.harden_process()
master = krypto.MasterKey.from_secret_file("/run/secrets/master_key")
key = master.derive(b"my-app/tokens/v1", b"per-store-salt")

secret = krypto.SecretBuf.from_vec(bytearray(b"api-token"))   # the bytearray is zeroed
blob = krypto.seal(key, master.key_id(), secret, krypto.Alg.Aegis256)
back = krypto.open(key, blob)                                 # a SecretBuf: the plaintext stays locked

Errors are exceptions, one per kind, all under krypto_py.Error. AuthError means tampering, the wrong key or the wrong password, and is the one to alert on.

The secrets live in krypto's locked memory, wiped when dropped and, on Linux, kept out of core dumps. What Python itself holds — the bytes you pass in, and the copies expose hands out — is ordinary Python memory, neither locked nor wiped.

License: MIT or Apache-2.0, at your option.

Metadata

Release files for krypto-py 0.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for krypto-py 0.8.2
File Size Uploaded Provenance Actions
krypto_py-0.8.2.tar.gz 210.8 kB Without provenance Details for krypto_py-0.8.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for krypto-py 0.8.2
File Interpreter ABI Platform Actions
krypto_py-0.8.2-cp311-abi3-manylinux_2_34_x86_64.whl CPython 3.11 abi3 Linux glibc 2.34+ x86-64 Details for krypto_py-0.8.2-cp311-abi3-manylinux_2_34_x86_64.whl

Total release size: 1.1 MB

Release files / krypto_py-0.8.2.tar.gz

Download URL krypto_py-0.8.2.tar.gz
Size 210.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6e3f99fde656c54d2c958981faf83173a2b576bef4ce40d76909bad5798ca7bc
BLAKE2b-256 checksum
How to use checksums
c8e885e55d4656ec431bf0dce1d5a645b711d94abecceb5d6f8ef55e2f165da2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / krypto_py-0.8.2-cp311-abi3-manylinux_2_34_x86_64.whl

Download URL krypto_py-0.8.2-cp311-abi3-manylinux_2_34_x86_64.whl
Size 935.8 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
fa81dc296087be28465e25e9f9acb3ff4921b21e20f3694d1dbf4c1037644b46
BLAKE2b-256 checksum
How to use checksums
e9a5956903fc625c58b218e2d688c318b8117092cc23a9a2171d0bf023c716d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for krypto-py 0.8.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page