Skip to main content

High-performance streaming encryption engine for large files

Project description

ciph

PyPI Downloads Python CI License

Fast, streaming file encryption for large files. Works on files bigger than your RAM.

Install

pip install ciph
ciph setup

Requirements: Linux/Termux, Python >= 3.8, libsodium

# Debian/Ubuntu
sudo apt install libsodium-dev

# Termux
pkg install libsodium

Or build from source:

git clone https://github.com/ankit-chaubey/ciph
cd ciph && make && pip install .

Usage

ciph encrypt video.mp4          # -> video.mp4.ciph
ciph decrypt video.mp4.ciph     # -> video.mp4 (filename restored)

Set cipher or chunk size:

ciph encrypt file.bin --cipher chacha -c 8

Non-interactive (scripting):

CIPH_PASSWORD=yourpassword ciph encrypt file.bin

How it works

  • AES-256-GCM or ChaCha20-Poly1305 (auto-fallback if no AES-NI)
  • Argon2id key derivation from password
  • Data key is randomly generated per file, then wrapped with the password key
  • File is encrypted in chunks (default 4 MB) so memory usage is constant
  • Each chunk gets a unique derived nonce, authenticated with the full header as AAD
  • Original filename stored in header, restored on decrypt
  • Chunk size used during encrypt is baked into the header -- you can decrypt with any -c value

File format

Offset Size Field
0 4 Magic (CIPH)
4 1 Version
5 1 Cipher (1=AES, 2=ChaCha)
6 4 Chunk size MB (big-endian)
10 16 Argon2id salt
26 12 Nonce-derivation key
38 1 Filename length
39 N Original filename
39+N 2 Encrypted key length
41+N L Encrypted data key

Followed by repeating [4-byte chunk length][encrypted chunk]. A final zero-length authenticated chunk marks EOF.

The entire header is bound as AAD to every chunk -- tampering with any field breaks decryption.

Limitations

  • No resume support
  • Password-based only (public-key mode not yet implemented)

License

Apache 2.0 -- see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ciph-1.2.2.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ciph-1.2.2-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file ciph-1.2.2.tar.gz.

File metadata

  • Download URL: ciph-1.2.2.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ciph-1.2.2.tar.gz
Algorithm Hash digest
SHA256 b37ccf72e26bc91ba642e4c434a8ddf1f78a2d025d0e54e3b021e6cfc336719f
MD5 4bed8d983f433c546ed9574893a196f6
BLAKE2b-256 f67a82d134b7bc359dc2fdd8b71b4cf4094fe653ff6353ece73813d296dec8d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ciph-1.2.2.tar.gz:

Publisher: publish.yml on ankit-chaubey/ciph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ciph-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: ciph-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ciph-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ab85650bee1844885e4603396f0d48b5f64658b5d40c9426a54a172ef031b784
MD5 3edea834f165a97b78f001c43f2d8f57
BLAKE2b-256 9e8ffe01a73fd574916f03876becca790c04ca52a6482529d2a00a8c20b634e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ciph-1.2.2-py3-none-any.whl:

Publisher: publish.yml on ankit-chaubey/ciph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page