Install GPG

 brew install --cask gpg-suite

Generate key

gpg --full-gen-key
gpg (GnuPG/MacGPG2) 2.2.34; Copyright (C) 2022 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
  (14) Existing key from card
Your selection?
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (3072)
Requested keysize is 3072 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: Jianqing Peng
Email address: [email protected]
Comment:
You selected this USER-ID:
    "Jianqing Peng <[email protected]>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?

Encrypt/Decrypt files

//for binary file, output > gpgtest.txt.gpg
gpg -r [email protected] -e gpgtest.txt
//for text, output >  gpgtest.txt.asc
gpg -r [email protected] -ae gpgtest.txt
gpg -d gpgtest.txt.gpg

Export the public key

gpg -a --output public_key.txt --export [email protected]
cat public_key.txt
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQGNBGLWdGwBDADEYBga76kEjgCthkPar/qZalbTmD55sGPBYoMd6t6GKItTb0Ut
MwjRfwrbgHsPpYZ3WYtQ4voHgQ+Kj5FWYUQ4EnN17gB9pR9N+YbjVV+9QYzkxtd3
mEMzdEdkadcScqi9zzJH8pdtQ4JIAJTSiDhqhRA4F0G56v2RalO3IXDRwUr07xAo
oXDgLK24UTf8EuN+bW63Bw+maqfxdsxnxwDjEqVpU0VfrzSDKuVlFto7W2gEtFMH
shwAsEnWqFaHYFJYpyV7QfbKIXneT7OD0qtVEj6+unX+tkaSpyeV75WU7C+ObvW/
XlNv3FUJp5L4FwGG++zbY4xUTiOsP9Orj1f4dazbK/Tagxjrw08BkCyXOVhEzer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j/5fWFrYptLzei9egZ4mqELNeVx2O
Eupns2KdUxyFl30Un+qC2dxtjXf919UJAmVF0Wgk9Hwv6JOPVDSZO7b5FCl9NtBX
CWexwD6DG6TTkRvK2npn9BSmL8F+U+AqFHn9ZDMk025M2g+QRyda+aPjWJKM6ax7
Ln7HqqW7+LaRQSPBDCNVEFEIQFMbc7n/6C/IIvSe+SITMttPPTaOlp64Ob4cw6+o
0QMCP42tbJs46hVOx1m0yd+ArrA+BPykc+a1oVd+L+1TexLYfiLAvpF8qF0Zcd42
yRNdtwARAQABiQG2BBgBCAAgFiEE+un+MwcNuB5KLBdo9wfU9EpfhGUFAmLWdGwC
GwwACgkQ9wfU9EpfhGUHmQwAtuTVEvWCdpSk82x9kVZHvduPQsF0EBaELiT7gsGj
FaXdcX99ACEs4fiKC7dIh2cbudT1m1qnbdhUIWMTGURP2JAIWaek3qQOfdvpiwKY
AEdqU7/N+d80MdKha9flV6OyuHeiBxJBJxqoNRiM2OdNCko2D9KEwM7X3SDUlrWd
xybbRKxDonT6YriO3rGlQGoy73i5O42k88qEqefleEKwge9WuPu5widCXdtUcBT+
R9mLZzQANXSz7538NzUJGhPChQAkBEF1eBjNmN4WnvRd8qcDVOGuKbfyyzu8LGbE
99i4/ymGX6HVrgToB7w1IASrEDunbsyLm1GrvgQ5u2EXAdd1bN0XkMBINdrjk3vo
s5NVjNaY5KA0lyTg31iclSLzWp+B/ClxL33zHNT88CIR7b9EwUMGskmBTkIs2Lt4
UmQEIfxRL7WKG7wYFcyseh131ix7wSDFmYPh+tu6flePQHSKk/XeUEtmTiJs05As
vx6Yx6ljtUjFH3k5j/ZsTDBI
=vYQw
-----END PGP PUBLIC KEY BLOCK-----

Enable GPG Sign for Github

git config --global user.signingkey F707D4F44A5F8465
git config --global commit.gpgsign true

* Copy&Paste the Public KEY to Github

Reference

  1. https://blog.creedowl.com/posts/gpg/
GPG

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.