Skip to content

GautierPicon/cipher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cipher MIT License

CLI file encryption tool based on AES-256-GCM and Argon2id.

Dependencies


Install cipher on your machine

Download the latest .whl from the releases page, then:

# Install pipx if you don't have it
pip install pipx

# Install cipher
pipx install "cipher @ file:///path/to/cipher-X.X.X-py3-none-any.whl"

# cipher is now available globally
cipher --help

Update to a newer version

Download the new .whl from the releases page, then:

pipx install --force "cipher @ file:///path/to/cipher-X.X.X-py3-none-any.whl"

Uninstall

pipx uninstall cipher

Development setup

Clone the project

git clone https://codeberg.org/GautierPicon/cipher.git
cd cipher

Install dependencies and create environment with uv

uv sync

Run via uv

uv run cipher --help

Test your changes

uv run pytest

Build the wheel locally

# generates dist/cipher-X.X.X-py3-none-any.whl
uv build

Commands reference

encrypt

cipher encrypt <file> [<file2> ...]
cipher encrypt <file> --genpass
cipher encrypt <file> -o <output>
cipher encrypt <file> --overwrite
cipher encrypt <file> -o <output> --overwrite

decrypt

cipher decrypt <file.enc>
cipher decrypt <file.enc> -o <output>
cipher decrypt <file.enc> --overwrite
cipher decrypt <file.enc> -o <output> --overwrite

verify

cipher verify <file.enc>

help

cipher --help
cipher encrypt --help
cipher decrypt --help
cipher verify --help

Usage

Encrypt a file

# Encrypt secret.txt → secret.enc
cipher encrypt secret.txt

# Encrypt rapport.pdf and name the output vault.enc
cipher encrypt rapport.pdf -o vault.enc

# Encrypt a folder
cipher encrypt my-folder/

Encrypt multiple files at once

# Encrypt several files in one command — one password prompt for all
cipher encrypt file1.txt file2.pdf my-folder/

# With --overwrite if the .enc files already exist
cipher encrypt file1.txt file2.pdf --overwrite

-o / --output cannot be used when encrypting multiple files.

Encrypt with a generated password

# Generate a strong random password, use it to encrypt, and copy it to clipboard
cipher encrypt secret.txt --genpass

⚠ The generated password is displayed once and cannot be recovered. Store it in a password manager.

Decrypt a file

# Decrypt secret.enc → restores original filename automatically
cipher decrypt secret.enc

# Decrypt and choose a custom output name
cipher decrypt vault.enc -o restored_report.pdf

Verify a file

# Verify integrity and password without writing anything to disk
cipher verify secret.enc

verify decrypts every chunk in memory and checks the AES-GCM authentication tag. It confirms that:

  • the password is correct,
  • the file has not been tampered with or truncated.

No output file is ever created.


Platform support

cipher runs on macOS, Linux, and Windows.

Feature macOS Linux Windows
Encryption / Decryption
Verify
Clipboard (--genpass) pbcopy xclip / xsel / wl-copy clip
File permissions (chmod 600) skipped (no-op on NTFS)
Directory encryption pipe pipe temp file (pipes are blocking on Windows)

Security

Component Choice Why
Encryption AES-256-GCM Authenticated encryption (integrity + confidentiality)
KDF Argon2id GPU/ASIC-resistant; OWASP & RFC 9106 recommendation
KDF parameters t=3, m=64 MiB, p=4 OWASP 2024 interactive profile
Salt 32 random bytes Unique per file; protects against rainbow tables
Nonce 64-bit random + 32-bit counter Per-chunk; avoids reuse across files and chunks
File format CIPHER02 Self-contained header stores all KDF parameters

Format CIPHER02

Each .enc file is self-contained: the header embeds the magic bytes, all Argon2id parameters, a 32-byte salt, and a 12-byte base nonce. This means cipher can always re-derive the correct key even if the default parameters change in a future version.

Chunks are encrypted individually with AES-256-GCM. Each chunk has its own nonce derived from the base nonce, so a truncated or reordered file is detected immediately. The filename is authenticated inside the first chunk.


Feedback

Feedback is welcome! Feel free to open an issue or a pull request on the Codeberg repository.

About

Command-line tool for file encryption. CODEBERG MIRROR:

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages