To encrypt a file using OpenSSL, you can use the following command:
openssl enc -aes-256-cbc -salt -in filename.txt -out filename.enc -pbkdf2
Breakdown of the command:
openssl enc: Invokes the OpenSSL command for encryption.-aes-256-cbc: Specifies the AES encryption algorithm with a 256-bit key in CBC mode.-salt: Adds a random salt to the encryption process for enhanced security.-in filename.txt: Indicates the input file you want to encrypt (replacefilename.txtwith your actual file name).-out filename.enc: Specifies the output file for the encrypted data (replacefilename.encwith your desired output file name).-pbkdf2: Uses the PBKDF2 key derivation function for better security when generating the encryption key from a password.
Steps to Encrypt a File:
- Open your terminal.
- Run the command above, replacing
filename.txtandfilename.encwith your actual file names. - You will be prompted to enter a password. Choose a strong password for encryption.
- After entering the password, the file will be encrypted, and the output file will be created.
If you have any further questions or need assistance, feel free to ask!
