How to encrypt and decrypt with AES on the command line
We are going to encrypt a file using the openssl
command-line tool.
Let’s generate a sample file:
$ seq 1000 >somefile.txt
Using our knowledge of the symmetric encryption concepts, we are choosing the following parameters for our encryption:
- Cipher: AES-256
- Operation mode: CBC (we should have chosen GCM, but that mode is not supported by the command-line tool)
- Padding type: standard block padding
How can we find out how to encrypt the command line from the documentation? We can begin with the openssl
tool man page:
$ man openssl
On that man page, we can see different subcommands that the openssl
tool supports. From the man page, we can figure out that we need the enc
subcommand. We can then refer to the openssl-enc
man page for documentation on the enc
subcommand:
$ man openssl-enc
From the openssl-enc
man page, we can figure out which parameters the subcommand needs. We see...