Sometimes you have the need to encrypt a small phrase or a list of words. This may be because you want to store it somewhere digitally but you dont want to keep it in clear. You can easily do it with openssl. In the following example we do it with openssl and linux with few lines of code.
You can generate a new 2048-bit RSA private key or you can use an existing one (for example the one you use in SSH connection or someone else). So let’s generate a new RSA private key:
openssl genrsa -out key.prv 2048
now you can use such a key to encrypt your phrase, suppose in this example “hello world”. Let’s encrypt this two words phrase with the key just created:
echo “hello world” | openssl rsautl -inkey key.prv -encrypt >output.bin
the encrypted data is stored into the file named output.bin . Now you can check unencryption (using the key), to test if all went smoothly. You can do that with the following command:
openssl rsautl -inkey key.prv -decrypt <output.bin
As you can see this is easy and you can encrypt a phrase with your private key. Obviously it’s important that your key is kept safe and possibly offline. For example it can be stored on external small storage medium and kept connected only for time necessary for encryption/decryption to take place.