Skip to content

Instantly share code, notes, and snippets.

@waleedsamy
Last active May 11, 2018 13:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waleedsamy/e0949fc997db6dd87a5446b5eebfb76e to your computer and use it in GitHub Desktop.
Save waleedsamy/e0949fc997db6dd87a5446b5eebfb76e to your computer and use it in GitHub Desktop.
GPG for file crypting, tag signing and email using 0x680b460f9694e494
3F9E 6349 5EA4 53A8 FF26 FDCD 680B 460F 9694 E494

print your private key

apt update && apt install -y pgp paperkey

# prepare to print
gpg -o secret.gpg --export-secret-key waleed
paperkey --secret-key secret.gpg --output paper.key
lpr paper.key

# restore your private key (you need your public key, get it from a keyservers and convert it binary by gpg --dearmor)
paperkey --pubring public.gpg --secrets paper.key --output restored.secret.gpg
gpg --import restored.secret.gpg


# Comment: Use "gpg --enarmor" for packing
# Comment: Use "gpg --dearmor" for unpacking
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Test encrypted
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEP55jSV6kU6j/Jv3NaAtGD5aU5JQFAlrLNuYACgkQaAtGD5aU
5JRtZg//cwm3lfWZsLwEQ6LJoy1BTq7/ZBMZWQk+XfF3ePuXCrXxKI9MSCbadiro
3CVr9ltQL/kjEOGiftX/lRGDc6j9wYReofmjp2I7aW4BNHeWfIjB0FNm5bgn0mBa
/p+BnDiplfaZRX1LKFZzqHVsNwrxYma5gLh2mAzclTKKTVxsr6Q9UD2G7Dr9Bffl
ub8IqjqRi6dcyvexY5hFJMqdCZ0rmbAWFPc0oV1E4eDvYwOwTXLqEu7nS5Zs73+g
nZe91pfWDKwVBM3RB9ROg3pMDWFJH6hjhJj0zZMrh0fzSMbcICjLs9pD0L/AvTOi
WWuW5VcILWbIyD+k0HP/kOanv7b9JiJdwWaC4gwklr9fDR0aWTNTIZd5gXolx3WR
bk1g+3BHCs9jlazpfGvMFRxkUIRBv3Hg2/MZG/5ri65CfX5jABh917kVn2UwWusM
vLcmwGjNze+9gCGmRPl1wkvHRsHNy5WL+TYX7YOCuBeXyPKXmrgyembzsz+u5V10
4/EkVgXXg4ZaZ3cbYladMZlR1R2ZvpidLYzmg8Fk22mnQhf9pTet+SMjGPfVCQE4
llIfJCHFc68ki1GV+0Du/jlYFsetE1VeReVBkc32UcssubKdEvGwbJ+cqIF6xy6E
NIiOWagLWBW709/q3eDuA+E/y4ePdKXXt/aINmD2k+/BTSzp44I=
=9Qed
-----END PGP SIGNATURE-----

Most used command is available here http://irtfweb.ifa.hawaii.edu/~lockhart/gpg/

steps:

  • encrypt(by recipient public key)
  • sign(by sender private key, you can sign an unencrupted message, will verfiy the sender, but your text is unencrypted e.g sign-but-not-encrypted.msg)
  • send the message
  • verify(by sender public key)
  • decrypt(by recipient private key)
  ##### sender ####
  # encrupt
  gpg -ea -o secret.txt.asc -r "recipient" secret.txt
  # sign (optional)
  gpg -o encrupted.sig -sa secret.txt.asc
  
  ##### recipient #####
  gpg --verify encrupted.sig (if signed)
  # get the message (still encrupted) (if signed)
  gpg -o encrupted -d encrupted.sig
  # decrypt the message
  gpg -o decrypted -d encrupted

search and load gpg

  gpg --keyserver keyserver.ubuntu.com --search-keys waleedsamy634@gmail.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment