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. At the open of a version 2 store a master key that does not fit is WrongKeyError.

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.9.0

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.9.0
File Size Uploaded Provenance Actions
krypto_py-0.9.0.tar.gz 333.6 kB Without provenance Details for krypto_py-0.9.0.tar.gz

Built distribution (wheel)

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

Total release size: 1.3 MB

Release files / krypto_py-0.9.0.tar.gz

Download URL krypto_py-0.9.0.tar.gz
Size 333.6 kB
Tags Source
SHA-256 checksum
How to use checksums
744d68abbd5d2b1403163228cd024e259e568c379a3aed757a558d2d1e67cea1
BLAKE2b-256 checksum
How to use checksums
71bfa33c0b7e15d0ec83cd99255e1c624d2ca40d7170b5982577e0c738d4ffee
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.9.0-cp311-abi3-manylinux_2_34_x86_64.whl

Download URL krypto_py-0.9.0-cp311-abi3-manylinux_2_34_x86_64.whl
Size 961.4 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
25c388e1bdd51877ff475fe4427e3cc42f140c00a79783abe3afea825149a548
BLAKE2b-256 checksum
How to use checksums
f062424d616e9c7782a0a632667c7ae9d8288caa7e49d33d98ce6754164ad1f4
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.9.0

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