Skip to content

Instantly share code, notes, and snippets.

@helloimalemur
Forked from spencerdodd/pgp.md
Last active December 13, 2022 14:23
Show Gist options
  • Save helloimalemur/c269cdef50b72b300a8bdfb8f9394f8e to your computer and use it in GitHub Desktop.
Save helloimalemur/c269cdef50b72b300a8bdfb8f9394f8e to your computer and use it in GitHub Desktop.
pgp file encryption / decryption with GPG

generate new key-pair

gpg --full-generate-key #If you are not on version 2.1.17 or greater, the gpg --full-generate-key command doesn't work.
gpg --default-new-key-algo rsa4096 --gen-key

list keys

gpg --list-keys
gpg --list-secret-keys --keyid-format=long /Users/foxx/.gnupg/secring.gpg

export key

gpg --armor --export 3AA5C34371567BD2 # Prints the GPG key ID, in ASCII armor format

import key

gpg --import private.key
------------------------------------<br>
sec   4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10]<br>
uid                          Hubot <hubot@example.com><br>
ssb   4096R/4BB6D45482678BE3 2016-03-10<br>


encryption

gpg --recipient jim@dundermifflin.com --output dwight.jpg.pgp --encrypt dwight.jpg

decryption

gpg --output dwight.jpg --decrypt dwight.jpg.gpg

ascii armor

add the `--armor` flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment