This script provides a simple yet secure method to encrypt and decrypt files using the AES-256-CBC algorithm with password protection.
- ⭐ Features
- 📦 Requirements
- Quick instal
- ⚙️ Installation
- 📝 Usage
- 💡 Example
- 🔒 Security Considerations
- 🔍 How it Works
- 📜 encrypt.py
⚠️ Disclaimer
- Secure AES-256-CBC encryption.
- User-provided password for encryption.
- Password protection with PBKDF2 key derivation.
- Automatic output filename generation with
"_crypt"
suffix for encrypted files.
- Bash shell
- OpenSSL library
use only one command for install 'cryptonit' bin file
curl -sSL https://raw.githubusercontent.com/ruslanlap/encrypt-decrypt-git/master/install-not-bin.sh | sh
To use this script, ensure you have OpenSSL installed on your system. If you don't have it installed, you can typically install it using your system's package manager. Here are some examples:
sudo apt update
sudo apt install openssl
sudo yum install openssl
brew install openssl
For Windows, you can download OpenSSL binaries from the official OpenSSL website here.
just follow the workflow ;)
./encrypt.sh
- `🔑 Enter password for AES-256-CBC encryption (or press Enter to use hardcoded):
- Please enter the operation (encrypt/decrypt or e/d):
- Please enter the input file name:
Encrypt a file:
./encrypt.sh
- `🔑 Enter password for AES-256-CBC encryption (or press Enter to use hardcoded): pass is hiden
- Please enter the operation (encrypt/decrypt or e/d): e
- Please enter the input file name: my_secret_file.txt
This will encrypt the file my_secret_file.txt
and create a new file named my_secret_file.txt_crypt
.
add arguments after './encrypt.sh' or after 'python encrypt.py'
./encrypt.sh [encrypt|decrypt] <inputfile>
encrypt
: Encrypts the specified file.decrypt
: Decrypts the specified file.<inputfile>
: The path to the file you want to encrypt or decrypt.
Encrypt a file:
./encrypt.sh encrypt my_secret_file.txt
This will encrypt the file my_secret_file.txt
and create a new file named my_secret_file.txt_crypt
.
- Hardcoded Password: This script includes a commented-out section for a hardcoded password. Do not use this option! Always prompt the user for a password at runtime.
- Password Strength: Choose a strong and unique password for encryption.
- Script Permissions: Ensure this script has appropriate permissions to be executed.
- The script prompts the user for a password for encryption.
- It checks for at least two arguments (operation and input file).
- Based on the operation (
encrypt
/decrypt
):- Encryption:
- Extracts filename without path.
- Generates output filename with "_crypt" suffix.
- Uses
openssl enc
with AES-256-CBC, salt, and PBKDF2 for password derivation.
- Decryption:
- Checks if the input filename ends with "_crypt".
- Generates output filename by removing "_crypt" suffix.
- Uses
openssl enc -d
to decrypt the file.
- Encryption:
- The script displays a success or failure message based on the operation result.
- Finally, it clears the password variable from memory for security reasons.
The encrypt.py
script offers the same functionality as the Bash script, enabling file encryption and decryption using the AES-256-CBC algorithm. It provides a Python-based alternative for users who prefer or require Python for their workflow.
python encrypt.py [encrypt|decrypt] <inputfile>
encrypt
: Encrypts the specified file.decrypt
: Decrypts the specified file.<inputfile>
: The path to the file you want to encrypt or decrypt.
Encrypt a file:
python encrypt.py encrypt my_secret_file.txt
This will encrypt the file my_secret_file.txt
and create a new file named my_secret_file.txt_crypt
.
This script is for educational purposes only. While it offers basic encryption, ensure you understand the limitations and potential vulnerabilities before using it for sensitive data.