__ _____
|__| ______/ ______ _ __ ___________ ____
| |/ \ __\\ \/ \/ / / _ \_ __ \/ ___\
| | Y Y | | \ / ( <_> | | \/ /_/ >
/\__| |__|_| |__| \/\_/ /\ \____/|__| \___ /
\______| \/ \/ /_____/
USING GPG [0]
________________________________________________________________________________
GPG (GNU Privacy Guard) is a free implementation of the OpenPGP standard that
allows you to encrypt and sign your data and communications.
[0.0] Index
________________________________________________________________________________
- Create a key pair [1.0]
- Key Management [2.0]
- Encryption and Decryption [3.0]
- Signing and Verification [4.0]
- References [5.0]
[1.0] Create a key pair
________________________________________________________________________________
Generate a key pair by typing in a terminal:
+------------------------------------------------------------------------------+
| |
| $ gpg --full-gen-key |
| |
| # Follow the prompts: |
| # Select key type (e.g., ECC to sign and encrypt) |
| # Choose key size (Curve 25519) |
| # Set expiration date (0 = no expiration, or set any date) |
| # Enter a name and email |
| # Create a secure passphrase. |
| |
+------------------------------------------------------------------------------+
[2.0] Key Management
________________________________________________________________________________
List your keys:
+------------------------------------------------------------------------------+
| |
| # List public keys |
| $ gpg --list-keys |
| |
| # List private keys |
| $ gpg --list-secret-keys |
| |
+------------------------------------------------------------------------------+
Export your public key:
+------------------------------------------------------------------------------+
| |
| $ gpg --export --armor --output public-key.asc user-id |
| |
+------------------------------------------------------------------------------+
Import someone else's public key:
+------------------------------------------------------------------------------+
| |
| $ gpg --import their-public-key.asc |
| |
+------------------------------------------------------------------------------+
[3.0] Encryption and Decryption
________________________________________________________________________________
Encrypt a file for someone:
+------------------------------------------------------------------------------+
| |
| # Encrypt for recipient |
| $ gpg --encrypt --armor --recipient their@email.com file.txt |
| |
| # This creates file.txt.asc |
| |
+------------------------------------------------------------------------------+
Encrypt a message from stdin:
+------------------------------------------------------------------------------+
| |
| $ echo "Secret message" | gpg --encrypt --armor --recipient their@email.com|
| |
+------------------------------------------------------------------------------+
Decrypt a file:
+------------------------------------------------------------------------------+
| |
| $ gpg --decrypt file.txt.asc |
| |
| # Or decrypt to a new file |
| $ gpg --decrypt file.txt.asc > decrypted.txt |
| |
+------------------------------------------------------------------------------+
[4.0] Signing and Verification
________________________________________________________________________________
Sign a file:
+------------------------------------------------------------------------------+
| |
| # Create detached signature |
| $ gpg --detach-sign --armor file.txt |
| |
| # This creates file.txt.asc signature |
| |
+------------------------------------------------------------------------------+
Sign and encrypt in one command:
+------------------------------------------------------------------------------+
| |
| $ gpg --sign --encrypt --armor --recipient their@email.com file.txt |
| |
+------------------------------------------------------------------------------+
Verify a signature:
+------------------------------------------------------------------------------+
| |
| $ gpg --verify file.txt.asc file.txt |
| |
+------------------------------------------------------------------------------+
Create a clearsigned message:
+------------------------------------------------------------------------------+
| |
| $ gpg --clearsign message.txt |
| |
| # Creates message.txt.asc with readable text and signature |
| |
+------------------------------------------------------------------------------+
[5.0] References
________________________________________________________________________________
[0] https://left4code.neocities.org/blogs/apr-19-2025
[1] https://wiki.archlinux.org/title/GnuPG
[2] https://www.gnupg.org/gph/en/manual.html