Symmetric Encryption Example
Download Secret File #
Download the file we want to protect from here
Install OpenSSL #
OpenSSL is required for this example, if it’s not already installed, run the following in your command line:
sudo apt install openssl
Encrypt #
openssl enc -aes-256-cbc -in grandmas_cookie_recipe.txt -out secret.enc -k Sup3rS3cr3t!
- openssl - calling the program
- enc - specify which module we want to use, in this case, the encryption
- -aes-256-cbc - This is the algorithm we want to use
- -in - specifying our input file
- -out - specifying our output file
- -k - specifying the key
Decryption #
openssl enc -aes-256-cbc -d -in secret.enc -out decoded.txt -k Sup3rS3cr3t!
This command is most the same, except with the addition of the -d
flag to specify that we want to decrypt the file. We’ll also want point -in
to the encrypted file. and we can name the output file something that recognizable.