Metadata-Version: 2.4
Name: krypto-py
Version: 0.9.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Rust
Classifier: Operating System :: POSIX :: Linux
Classifier: Topic :: Security :: Cryptography
License-File: LICENSE-APACHE
License-File: LICENSE-MIT
Summary: Python binding for krypto: secrets in locked memory, AEAD at rest, signatures and passwords.
Keywords: secrets,encryption,aegis256,argon2,ed25519
Author-email: Roger Jorgensen <rogerj@gmail.com>
License-Expression: MIT OR Apache-2.0
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/rjorgensen123/krypto/blob/main/CHANGELOG.md
Project-URL: Documentation, https://github.com/rjorgensen123/krypto/blob/main/docs/Python.md
Project-URL: Repository, https://github.com/rjorgensen123/krypto

# krypto-py

The Python module of [krypto](https://github.com/rjorgensen123/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.

```sh
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.

```python
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.

- **[How to use it](https://github.com/rjorgensen123/krypto/blob/main/docs/Python.md)**, with
  examples
- **[The API](https://github.com/rjorgensen123/krypto/blob/main/docs/API.md)**, one for Rust and
  Python, and what Python cannot guarantee
- **[Changes](https://github.com/rjorgensen123/krypto/blob/main/CHANGELOG.md)**

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

