LAB: Using openssl to encrypt and decrypt
Here are steps to replicate the demo in my symmetric encryption video.
- Create a text file named
plaintextcontaining some text. Whatever you want. Generate a random 16-byte (32-hexadecimal-digit) key
Kusing this command:openssl rand -hex 16- Generate another 32-hex-digit number to be your initialization vector
IV. Encrypt your file:
openssl enc -aes-128-cbc -K YOUR_K -iv YOUR_IV -in plaintext -out ciphertext- Do
cat ciphertextjust to see what you ended up with. - Well that was probably unsatisfying! Try
cat ciphertext | hexdump -C. Let's see if we can decrypt this baby.
openssl enc -d -aes-128-cbc -K YOUR_K -iv YOUR_IV -in ciphertext -out decryptedCheck to see whether you got what you hoped for.
cat decrypted diff decrypted plaintext