Today I Learned

hashrocket A Hashrocket project

Encrypting with gpg

Encrypting and decrypting is easy with gpg.

To encrypt the text "ABC" and write it to a file called "abc.enc":

$ echo "ABC" | gpg --symmetric --force-mdc > abc.enc

To decrypt the "abc.enc" file:

$ gpg -d < abc.enc
gpg: CAST5 encrypted data
gpg: gpg-agent is not available in this session
gpg: encrypted with 1 passphrase

Each step asks for a passphrase. Symmetric encryption is encryption that can be encrypted and decrypted with the same information, in this case that information is the passphrase.

--force-mdc enables the modification detection code, so that gpg will be able to know if the encrypted text has been modified or not.

See More #command-line TILs