Skip to main content

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!
  1. openssl - calling the program
  2. enc - specify which module we want to use, in this case, the encryption
  3. -aes-256-cbc - This is the algorithm we want to use
  4. -in - specifying our input file
  5. -out - specifying our output file
  6. -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.