jedisct1/turbocrypt
A fast, easy-to-use, and secure command-line tool for encrypting and decrypting files or entire directory trees.
refs
c927de569893d4754f6fb16fc3b5e2a4ea07c496
A fast, easy-to-use, and secure command-line tool for encrypting and decrypting files or entire directory trees.
Requirements: Zig
git clone https://github.com/jedisct1/turbocrypt.git
cd turbocrypt
zig build -Doptimize=ReleaseFast
The compiled binary will be in zig-out/bin/turbocrypt
. Move it elsewhere, add it to your PATH or use the full path.
First, create a key file. This is a random 128-bit key that you'll use to encrypt and decrypt your files.
turbocrypt keygen secret.key
Important: Keep this key file safe! Anyone with access to it can decrypt your files.
Store the key in your configuration so you don't have to specify it every time:
turbocrypt config set-key secret.key
After this, you can encrypt and decrypt without specifying the key. The tool is now ready to use!
Encrypt a single file:
turbocrypt encrypt document.pdf document.pdf.enc
Encrypt an entire directory:
turbocrypt encrypt my-documents/ encrypted-documents/
Check that your encrypted files are intact:
turbocrypt verify encrypted-documents/
This confirms all files were encrypted successfully and haven't been corrupted or tampered with.
Decrypt a file:
turbocrypt decrypt document.pdf.enc document.pdf
Decrypt the entire directory:
turbocrypt decrypt encrypted-documents/ my-documents/
That's it!
If you want to protect your key file, you can encrypt it with a password:
# Generate a password-protected key
turbocrypt keygen --password protected.key
# Enter your password when prompted
# Use it (you'll be prompted for the password)
turbocrypt encrypt --key protected.key --password source/ dest/
Sometimes you want to encrypt files directly without creating copies:
turbocrypt encrypt --key my-secret.key --in-place my-documents/
Warning: This overwrites the original files. Make sure you have backups first!
If you want to conceal not just the contents but also the names of your files:
turbocrypt encrypt --key my-secret.key --encrypt-filenames source/ dest/
This encrypts each filename component, making it impossible to tell what files are in the encrypted directory without the key.
Use exclude patterns to skip files you don't want to encrypt:
# Skip log files and the .git directory
turbocrypt encrypt --key my-secret.key \
--exclude "*.log" \
--exclude ".git/" \
my-project/ encrypted-project/
Common exclude patterns:
*.log
- skip all .log files*.tmp
- skip temporary files.git/
- skip git repository datanode_modules/
- skip Node.js dependencies__pycache__/
- skip Python cache filesCheck if encrypted files are intact without decrypting them:
# Verify a single file
turbocrypt verify --key my-secret.key encrypted-file.enc
# Verify an entire directory
turbocrypt verify --key my-secret.key encrypted-documents/
This is useful for checking backups or verifying files after transferring them.
If you use the same key and settings frequently, save them:
# Set your default key (stores it in config)
turbocrypt config set-key my-secret.key
# Set default thread count
turbocrypt config set-threads 8
# Add permanent exclude patterns
turbocrypt config add-exclude "*.log"
turbocrypt config add-exclude ".git/"
# View your configuration
turbocrypt config show
Now you can run commands without repeating options:
# Uses the key and excludes from your config
turbocrypt encrypt source/ dest/
# Generate a new key
turbocrypt keygen output.key
# Generate a password-protected key
turbocrypt keygen --password output.key
# Set default key in config
turbocrypt config set-key my.key
# Basic encryption
turbocrypt encrypt --key KEY source dest
# With password-protected key
turbocrypt encrypt --key KEY --password source dest
# Encrypt in place (overwrites source)
turbocrypt encrypt --key KEY --in-place source/
# Encrypt filenames too
turbocrypt encrypt --key KEY --encrypt-filenames source/ dest/
# Exclude certain files
turbocrypt encrypt --key KEY --exclude "*.log" --exclude ".git/" source/ dest/
# Add .enc suffix automatically
turbocrypt encrypt --key KEY --enc-suffix source/ dest/
# Custom thread count
turbocrypt encrypt --key KEY --threads 16 source/ dest/
# Basic decryption
turbocrypt decrypt --key KEY source dest
# Decrypt in place
turbocrypt decrypt --key KEY --in-place encrypted/
# Remove .enc suffix automatically
turbocrypt decrypt --key KEY --enc-suffix encrypted/ decrypted/
# Verify file integrity
turbocrypt verify --key KEY encrypted-file.enc
# Verify directory
turbocrypt verify --key KEY encrypted-directory/
# View current settings
turbocrypt config show
# Set default key
turbocrypt config set-key path/to/key
# Set thread count
turbocrypt config set-threads 8
# Set buffer size (in bytes)
turbocrypt config set-buffer-size 8388608
# Manage exclude patterns
turbocrypt config add-exclude "*.tmp"
turbocrypt config remove-exclude "*.tmp"
# Set symlink behavior
turbocrypt config set-ignore-symlinks true
# Run benchmarks
turbocrypt bench
Options available for most commands:
--key <path>
- Path to key file (required unless set in config)--password
- Prompt for password (for password-protected keys)--threads <n>
- Number of parallel threads (default: CPU count, max 64)--in-place
- Overwrite source files instead of creating new ones--encrypt-filenames
- Encrypt filenames (cannot be used with --in-place)--enc-suffix
- Add/remove .enc suffix automatically--exclude <pattern>
- Skip files matching pattern (can use multiple times)--ignore-symlinks
- Skip symbolic links--force
- Overwrite existing files without asking--buffer-size <bytes>
- Set I/O buffer size (default: 4MB)Encrypted files can be freely moved between directories. The encryption intentionally does not depend on the file's path or parent directories. This means you can reorganize your encrypted files however you like without needing to re-encrypt them.
When using --encrypt-filenames
:
TurboCrypt stores your settings in a JSON configuration file:
~/Library/Application Support/turbocrypt/config.json
~/.local/share/turbocrypt/config.json
%LOCALAPPDATA%\turbocrypt\config.json
The config file is created with restricted permissions (owner read/write only) to protect your key if you choose to store it there.
Settings are applied in this order (highest priority first):
--key
, --threads
)TURBOCRYPT_KEY_FILE
)turbocrypt keygen
- don't create keys manually--password
turbocrypt verify
to check files after copying or uploading them--exclude
to skip cache, logs, and other regenerable files--threads
based on your CPU core count and disk features--buffer-size 16777216
(16MB) for very large filesThis error means either:
Double-check you're using the same key that encrypted the file.
The file has been modified or corrupted after encryption. TurboCrypt detected tampering and refused to decrypt. This is a security feature - the file may have been altered maliciously or damaged during storage/transfer.
On some systems, memory-mapped I/O (used for files >1MB) requires specific permissions. Try running with sudo/admin privileges, or check that your user has read/write access to both source and destination directories.
--threads 4
is often faster than 32 for small files)--threads 2
Reduce the buffer size: --buffer-size 1048576
(1MB instead of default 4MB)
TURBOCRYPT_KEY_FILE
: Path to your key file (overridden by --key
flag)Example:
export TURBOCRYPT_KEY_FILE=~/.ssh/turbocrypt.key
turbocrypt encrypt source/ dest/ # Uses key from environment