A Bash script to Encrypt and Decrypt files using a chosen algorithm.

Опубликовано: 20 Июль 2026
на канале: BASH SCRIPTING & PROGRAMMING
351
3

for source code click this link: https://afgfunz.blogspot.com/
------------------------------------------------------------------------------------------------
‪@bashscripting6‬

Function Definitions:::

encrypt_file(): Encrypts a specified file using AES-256-CBC encryption.
decrypt_file(): Decrypts an encrypted file using AES-256-CBC decryption.

Main Script::::

Checks the number of arguments passed to the script.
Parses the mode (encrypt or decrypt), file name, and algorithm provided as arguments.
Executes encryption or decryption based on the mode specified.
Usage:

To encrypt: Run the script with ./encrypt_decrypt.sh encrypt filename_to_encrypt aes-256-cbc.
To decrypt: Run the script with ./encrypt_decrypt.sh decrypt encrypted_filename aes-256-cbc.

Note:::::

Replace file_to_encrypt with the file you want to encrypt.
Replace encrypted_file with the encrypted file name for decryption.


Security Considerations:::::

The script uses AES-256-CBC, a robust encryption algorithm. Ensure you handle sensitive data securely.
Be cautious when storing encryption keys and handling decrypted data to prevent unauthorized access.