Skip to content

Instantly share code, notes, and snippets.

@arthuralvim
Created August 21, 2022 13:30
Show Gist options
  • Save arthuralvim/2d0b812322a0f1d3092b61f8079670e8 to your computer and use it in GitHub Desktop.
Save arthuralvim/2d0b812322a0f1d3092b61f8079670e8 to your computer and use it in GitHub Desktop.
GPG Summary

PGP Summary

Installation with Brew

$ brew install gnupg

List Keys

$ gpg --list-keys

Generate New Key

$ gpg --full-generate-key

Import Key

$ gpg --import key.pgp.pub

Generate Public Key

$ gpg --armor --output <key.pub> --export <key-id>

Sign File

$ gpg -u <key-id> –-detach-sign <file.app>

Verify Signature

$ gpg --verify <file.app.asc> <file.app>

Encrypt File

$ gpg -a -o <file-encrypted.app> --sign –-encrypt -r <key-id> <file-non-encrypted.app>

Decrypt File

$ gpg --output <file-non-encrypted.app> -d <file-encrypted.app>

Example

$ echo "echo hello world" > hello.txt
$ export GPG_KEY_ID=<SUPER_KEY_ID> # For the sake of the example the key id we will use is "SUPER_KEY_ID" but use a valid key.
$ gpg -u $GPG_KEY_ID -o hello.txt.sig --detach-sign hello.txt
$ gpg --verify hello.txt.sig hello.txt
$ gpg --armor --output key.pub --export $GPG_KEY_ID
$ gpg --import key.pub
$ gpg -a -o hello-encrypted.txt -se -r $GPG_KEY_ID hello.txt
$ cat hello.txt
$ cat hello-encrypted.txt
$ gpg --output hello-again.txt -d hello-encrypted.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment