Kapak is a simple-to-use file encryption script/library.
It uses AES_256_CBC as its encryption cipher.
If you are wondering what kapak means, it means mold.
Installation
Installing with pip:
pip install kapak
CLI Usage
kapak [global options] [command] [command options] [input]
kapak [encrypt | e] [options] [input]
kapak [decrypt | d] [options] [input]
Encrypt file
$ kapak encrypt -o ./image.jpg.kpk ./image.jpg
Enter password:
Confirm password:
■■■■■■■■■■ 100%
$ kapak decrypt -o ./image.jpg ./image.jpg.kpk
Enter password:
■■■■■■■■■■ 100%
Encrypt stdin
$ echo 'secret stuff' | kapak encrypt | base64
Enter password:
Confirm password:
AAAAbWth...t/ILJW/v
$ echo 'AAAAbWth...t/ILJW/v' | base64 --decode | kapak decrypt
Enter password:
secret stuff
$ cat ./text.txt | kapak encrypt -b 1024 > ./text.txt.kpk
Enter password:
Confirm password:
$ kapak decrypt -b 1024 ./text.txt.kpk > ./text.txt
Enter password:
Password file
$ echo 'P@ssw0rd' > ./password.txt
$ kapak encrypt -p ./password.txt -o ./image.jpg.kpk ./image.jpg
■■■■■■■■■■ 100%
$ kapak decrypt -p ./password.txt -o ./image.jpg ./image.jpg.kpk
■■■■■■■■■■ 100%
Integration
Encrypt file
from pathlib import Path
from kapak.aes import encrypt
input_file = Path("image.jpg")
output_file = Path("image.jpg.kpk")
with input_file.open("rb") as src, output_file.open("wb") as dst:
total_len = input_file.stat().st_size
progress = 0
for chunk_len in encrypt(src, dst, "P@ssw0rd"):
progress += chunk_len
print(f"{progress}/{total_len}")
kapak.aes.encryptis a generator. It yields the length of encrypted data on every iteration.
from pathlib import Path
from itertools import accumulate
from kapak.aes import decrypt
input_file = Path("image.jpg.kpk")
output_file = Path("image.jpg")
with input_file.open("rb") as src, output_file.open("wb") as dst:
total_len = input_file.stat().st_size
for progress in accumulate(decrypt(src, dst, "P@ssw0rd")):
print(f"{progress}/{total_len}")
kapak.aes.decryptis a generator. It yields the length of decrypted data on every iteration.
Encrypt stdin
import sys
from io import BytesIO
from kapak.aes import encrypt
with BytesIO() as dst:
for _ in encrypt(
src=sys.stdin.buffer,
dst=dst,
password="P@ssw0rd",
buffer_size=1024
):
pass
encrypted_data = dst.getvalue()
print(encrypted_data.hex())
Encrypt anything
from io import BytesIO
from kapak.aes import encrypt
anything = b"anything"
with BytesIO(anything) as src, BytesIO() as dst:
for _ in encrypt(
src=src,
dst=dst,
password="P@ssw0rd",
buffer_size=1024
):
pass
encrypted_data = dst.getvalue()
print(encrypted_data.hex())
Metadata
Release files for kapak 4.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kapak-4.0.1.tar.gz | 11.5 kB | Without provenance | Details for kapak-4.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kapak-4.0.1-py3-none-any.whl | Python 3 | none | any | Details for kapak-4.0.1-py3-none-any.whl |
Total release size: 25.0 kB
Release files / kapak-4.0.1.tar.gz
| Download URL | kapak-4.0.1.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4081b75f5ed34cb615e700d22016c12b8b9097bffeec12b3c05906b76396fb19
|
|
BLAKE2b-256 checksum How to use checksums |
16301a1d05a4511d008f790e348874c74a82b80a1c9e2b4146c2351d4b1f0cec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / kapak-4.0.1-py3-none-any.whl
| Download URL | kapak-4.0.1-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e6f763d76894a06f14df01c538f26e35adbe78bf7bce2e093a48aeb135613f9
|
|
BLAKE2b-256 checksum How to use checksums |
dff7ebf4a0bca05b2e8a97b2c0f3013e7ef4800df05c6fb742148f793bfa6ec4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for kapak 4.0.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.