This tool is a simple symmetric encryption tool that allows you to encrypt and decrypt content using a password.
The goal of this project is to have the same encryption/decryption mechamism written in several languages and make them all interoperable.
The encryption algorith used is AES-256-CBC and the key and IV is derived from the password using PBKDF2. You can see the default parameters below.
All script implementations share the same command signature. The general command structure is:
<executable> [encrypt|decrypt] [options]Note: Replace <executable> with the appropriate command for your chosen language implementation (see language-specific sections below).
encrypt- Encrypt the input contentdecrypt- Decrypt the input content
--text=<text>or-t <text>- Input text to encrypt/decrypt. Mutually exclusive with--file.--file=<file>or-f <file>- Input file to encrypt/decrypt. Mutually exclusive with--text.--password=<pass>or-p <pass>- Password for encryption/decryption. Optional - if not provided, the tool will prompt for it interactively (recommended for security).--output=<file>or-o <file>- Output file path. If not specified, the result is printed to stdout.--dec-encoding=<enc>- Encoding of the decrypted input/output. Valid values:base64orutf8(default:utf8). Note: This option may not be available in all implementations.--helpor-h- Show help message
Input behavior: If neither --text nor --file is provided, the tool will prompt for input content interactively.
Important
It is recommended that, even if the examples show it, you DO NOT enter the password in the terminal for security reasons. If you do not enter it, the tool will ask for it interactively.
Below are examples for each language implementation. All implementations follow the same command structure described above.
Command: ./encrypt.sh (or bash encrypt.sh)
Note: Supports both short (-t, -f, -p, -o) and long (--text, --file, --password, --output) option formats. The --dec-encoding option is available.
Command: node encrypt.js
Note: Uses long option format (--text, --file, --password, --output). The --dec-encoding option is available.
Command: python encrypt.py (or python3 encrypt.py)
Note: Uses long option format (--text, --file, --password, --output). The --dec-encoding option is not available in this implementation.
Command: php encrypt.php (or ./encrypt.php if executable)
Note: Uses long option format (--text, --file, --password, --output). The --dec-encoding option is available. Requires PHP 7.0+ (for random_bytes) and PHP 5.5+ (for hash_pbkdf2).
By default, the tool uses the following parameters:
- Encryption algorithm:
AES-256-CBC - Key length:
32 bytes - Salt prefix:
"Salted__"
This is used to follow "openssl" standard. - PBKDF2 algorithm:
sha256 - PBKDF2 rounds:
10000 - Encrypted content encoding:
base64 - Unencrypted content encoding:
utf8
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.