Simple SSL-based encryption
Oct 21, 2021
Send me a “secret message” with my ssl key:
Encrypt a short secret
Encrypt a long secret
You can’t directly encrypt a large file using rsautl
.
Instead, do the following:
- Generate a key using openssl rand, e.g.
openssl rand 32 -out keyfile
. - Encrypt the key file using
openssl rsautl
. - Encrypt the data using
openssl enc
, using the generated key from step 1. - Package the encrypted key file with the encrypted data.
- I’ll decrypt the key with my private key, then decrypt the data with the resulting key.
On a mac, you can use the following shell function to encode input_file
:
Example 1.
This is an identity operation and gives you back the original message.
Example 2.
This encrypts input_file and displays secret key, encrypted key (ASCII armored) and encrypted message using the secret key.
This also copies the following command line into clipboard, which you can share with me: