Secure streaming file encryption with O(1) memory usage
Project description
KREL
Secure streaming file encryption with constant memory usage.
Features
- Simple API - Encrypt files with 3 lines of code
- Streaming - Process unlimited file sizes with O(1) memory
- Instant rekey - Change passwords in constant time without re-encryption
- Battle-tested crypto - XChaCha20-Poly1305, Argon2id, BLAKE3
- Safe by default - Automatic password zeroization
Install
pip install krel
Quick Start
from krel import encrypt, decrypt, rekey
# Encrypt
encrypt("file.pdf", "file.pdf.krel", "password")
# Decrypt
decrypt("file.pdf.krel", "file.pdf", "password")
# Change password instantly
rekey("file.pdf.krel", "old-password", "new-password")
Usage
Basic Operations
from krel import encrypt, decrypt, verify_password
# Encrypt a file
encrypt("document.txt", "document.txt.krel", "my-password")
# Decrypt
decrypt("document.txt.krel", "document.txt", "my-password")
# Check password without decrypting
if verify_password("document.txt.krel", "my-password"):
print("Correct password")
Password Change
from krel import rekey
# O(1) password change - no re-encryption needed
rekey("file.krel", "old-password", "new-password")
Error Handling
from krel import decrypt, AuthenticationError, IntegrityError
try:
decrypt("file.krel", "output.txt", "password")
except AuthenticationError:
print("Wrong password")
except IntegrityError:
print("File corrupted")
Async API
For large files or high performance:
from krel import encrypt_async, decrypt_async
await encrypt_async("large.iso", "large.iso.krel", "password")
await decrypt_async("large.iso.krel", "large.iso", "password")
API
Functions
encrypt(source, dest, password)- Encrypt a filedecrypt(source, dest, password)- Decrypt a filerekey(path, old_pass, new_pass)- Change passwordverify(path) -> bool- Check file integrityverify_password(path, password) -> bool- Verify password
All functions have async versions: encrypt_async(), decrypt_async(), etc.
Exceptions
KrelError- Base exceptionAuthenticationError- Wrong passwordIntegrityError- File corrupted
Security
Cryptography
- Encryption: XChaCha20-Poly1305 (AEAD)
- KDF: Argon2id (256 MB, 3 iterations)
- Hashing: BLAKE3
- Chunk size: 64 KiB
Memory Safety
- Passwords automatically zeroed after use
- Constant memory usage regardless of file size
- Secure key wrapping with commitment
Performance
- Throughput: ~500 MB/s (CPU-dependent)
- Memory: ~130 KiB constant
- Rekey: O(n) but no decryption/encryption
File Format
Header (128 bytes)
├─ Magic: "KREL"
├─ Version: 1
├─ Salt: 16 bytes
├─ Nonce base: 16 bytes
├─ Wrapped DEK: 48 bytes
└─ Commitment: 32 bytes
Encrypted chunks
└─ Chunk: 65552 bytes (64 KiB + 16 byte tag)
Trailer (36 bytes)
├─ Integrity hash: 32 bytes
└─ Magic: "KREL"
Examples
See examples/ directory for more usage patterns.
License
MIT - see LICENSE file.
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file krel-0.1.2.tar.gz.
File metadata
- Download URL: krel-0.1.2.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2007ff2d72bcf1670203f6031cc7c938634de3058160fc452b8989a64164326
|
|
| MD5 |
d62599aed3ff1dc13428f3614f014fbb
|
|
| BLAKE2b-256 |
ddd77d6eeb61c10715b852bce725f85fa9606e646d4bd390a63923d60d8b6db0
|
Provenance
The following attestation bundles were made for krel-0.1.2.tar.gz:
Publisher:
release.yml on Muran-prog/krel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
krel-0.1.2.tar.gz -
Subject digest:
c2007ff2d72bcf1670203f6031cc7c938634de3058160fc452b8989a64164326 - Sigstore transparency entry: 730605742
- Sigstore integration time:
-
Permalink:
Muran-prog/krel@e4509eb78c9fe4bffed6644adcef6cd44a7ba785 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Muran-prog
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e4509eb78c9fe4bffed6644adcef6cd44a7ba785 -
Trigger Event:
push
-
Statement type:
File details
Details for the file krel-0.1.2-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: krel-0.1.2-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 451.0 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d233e5b074f6f686c802b20207df87b7a8064609f846b4880bdfb62625b594d
|
|
| MD5 |
a206a4fb1131fc322f8682ab686f566d
|
|
| BLAKE2b-256 |
9584fa241ae12fc648227b4b6572ae4a3ea3177d1e32ea4866001cfa0516abec
|
Provenance
The following attestation bundles were made for krel-0.1.2-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on Muran-prog/krel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
krel-0.1.2-cp38-abi3-win_amd64.whl -
Subject digest:
5d233e5b074f6f686c802b20207df87b7a8064609f846b4880bdfb62625b594d - Sigstore transparency entry: 730605765
- Sigstore integration time:
-
Permalink:
Muran-prog/krel@e4509eb78c9fe4bffed6644adcef6cd44a7ba785 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Muran-prog
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e4509eb78c9fe4bffed6644adcef6cd44a7ba785 -
Trigger Event:
push
-
Statement type:
File details
Details for the file krel-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: krel-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 495.3 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e612ee1d57aab5579e63a6ba3737a5a00a765e2362a819e2d22f4a6efc37939
|
|
| MD5 |
cc93410e2a6fb74a8bdb55b7db80cd9d
|
|
| BLAKE2b-256 |
1e7ce39022b79b81a258b29d980d7b53861db07e7098a71ecc25177d80b9d318
|
Provenance
The following attestation bundles were made for krel-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on Muran-prog/krel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
krel-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
0e612ee1d57aab5579e63a6ba3737a5a00a765e2362a819e2d22f4a6efc37939 - Sigstore transparency entry: 730605788
- Sigstore integration time:
-
Permalink:
Muran-prog/krel@e4509eb78c9fe4bffed6644adcef6cd44a7ba785 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Muran-prog
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e4509eb78c9fe4bffed6644adcef6cd44a7ba785 -
Trigger Event:
push
-
Statement type:
File details
Details for the file krel-0.1.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: krel-0.1.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 890.8 kB
- Tags: CPython 3.8+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de56ccfcae81d131f7326c0eb4a1e70af18e842221bdca1d3fd1d43a9345be72
|
|
| MD5 |
070c0de085d20a1a905c0f9e5aa848a1
|
|
| BLAKE2b-256 |
cc521e94adcfae6b00507a41e48f5d11b3a87109d1e6abe32238ea747c1eb579
|
Provenance
The following attestation bundles were made for krel-0.1.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release.yml on Muran-prog/krel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
krel-0.1.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
de56ccfcae81d131f7326c0eb4a1e70af18e842221bdca1d3fd1d43a9345be72 - Sigstore transparency entry: 730605754
- Sigstore integration time:
-
Permalink:
Muran-prog/krel@e4509eb78c9fe4bffed6644adcef6cd44a7ba785 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Muran-prog
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e4509eb78c9fe4bffed6644adcef6cd44a7ba785 -
Trigger Event:
push
-
Statement type: