Skip to content

Instantly share code, notes, and snippets.

@ryanamaral
Last active May 15, 2020 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanamaral/7bb3a4e94c27396968289ba808a25b7a to your computer and use it in GitHub Desktop.
Save ryanamaral/7bb3a4e94c27396968289ba808a25b7a to your computer and use it in GitHub Desktop.
How to use GPG to encrypt and decrypt messages

How to use GPG to encrypt and decrypt messages

Importing Someone Else’s Public Key

$ gpg --import someone-else.pub_key

Encrypting File

$ gpg --encrypt --sign --armor --recipient someone-else@mail.com clear_message.txt

--sign: sign the file with your details
--armor: create an ASCII output
--recipient: email address (or ID) of the person you’re sending the message to

(Optional) Use a specific public key of yours

$ gpg --encrypt --sign --armor --local-user "my@email.com" --recipient someone-else@email.com clear_message.txt

--local-user: specify user ID (or) user fingerprint to sign the message. If this option is not used, the default key will be used.

Decrypting File

$ gpg --decrypt encrypted_message.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment