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 or the wrong key, and is the one to alert on.

The secrets live in krypto's locked memory, kept out of core dumps and wiped when dropped. 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.1

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.1
File Size Uploaded Provenance Actions
krypto_py-0.8.1.tar.gz 182.3 kB Without provenance Details for krypto_py-0.8.1.tar.gz

Built distribution (wheel)

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

Total release size: 1.1 MB

Release files / krypto_py-0.8.1.tar.gz

Download URL krypto_py-0.8.1.tar.gz
Size 182.3 kB
Tags Source
SHA-256 checksum
How to use checksums
afbc594b171fc772a41d540a48c2152bd0f335cfe19480dc987b58f8af337cd1
BLAKE2b-256 checksum
How to use checksums
464df1443dde4bc1847a81138cdfbc1592915e714bf4290d6d67b69f48b9d590
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.1-cp311-abi3-manylinux_2_34_x86_64.whl

Download URL krypto_py-0.8.1-cp311-abi3-manylinux_2_34_x86_64.whl
Size 927.6 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
7c157b2046a8915cc42004147126b1903e818da385905c75e6af0866b75f739b
BLAKE2b-256 checksum
How to use checksums
13424d0f9e2e6b93b256757957dd04153140d6fcf038d7b42c5729869344f86d
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.1

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