Usage
First Time Setup
Before using the extension, you need to have a GPG key pair. You can either generate a new key pair or import an existing one.
Generating a New Key Pair
- Open VS Code
- Press
Ctrl+Shift+P(orCmd+Shift+Pon macOS) to open the Command Palette - Type and select
GPG: Generate New Key Pair - Enter your user ID (e.g., "John Doe john@example.com")
- Enter a passphrase to protect your private key (optional but recommended)
- Confirm your passphrase
- Wait for the key generation to complete
Importing an Existing Key
- Open VS Code
- Press
Ctrl+Shift+P(orCmd+Shift+Pon macOS) to open the Command Palette - Type and select
GPG: Import Key - Select your key file (
.asc,.gpg, or.key) - If the key is password-protected, enter the passphrase when prompted
- Choose whether to save the passphrase for future use
Opening Encrypted Files
Automatic Decryption
When you open a file with a .gpg or .asc extension, the extension will automatically decrypt it if:
- You have a matching private key in your key storage
- The passphrase is either saved or you enter it when prompted
Manual Decryption
To manually open an encrypted file:
- Press
Ctrl+Shift+P(orCmd+Shift+Pon macOS) - Type and select
GPG: Open Encrypted File - Select the file you want to open
- Enter the passphrase if prompted
Editing Encrypted Files
Once an encrypted file is open, you can edit it like any other file. When you save:
- The extension encrypts the content using the default recipient's public key
- The encrypted file is written to disk
- The editor continues to show the decrypted content
Encrypting New Files
To encrypt a new file:
- Create a new file and give it a
.gpgor.ascextension - Set a default encryption recipient (see below)
- Add your content and save
- The file will be automatically encrypted
Setting the Default Recipient
- Press
Ctrl+Shift+P(orCmd+Shift+Pon macOS) - Type and select
GPG: Set Default Recipient - Select a public key from the list
- This key will be used for encryption until you change it
Managing Keys
Listing Keys
To see all stored keys:
- Press
Ctrl+Shift+P(orCmd+Shift+Pon macOS) - Type and select
GPG: List Keys - A quick pick window will show all your stored keys
Removing Keys
To remove a stored key:
- Press
Ctrl+Shift+P(orCmd+Shift+Pon macOS) - Type and select
GPG: Remove Key - Select the key you want to remove
- Confirm the removal
Viewing Logs
To view extension logs for debugging:
- Press
Ctrl+Shift+P(orCmd+Shift+Pon macOS) - Type and select
GPG: Show Logs - The output panel will open with the extension logs
Troubleshooting
File Won't Decrypt
- Ensure you have the correct private key
- Check that you're entering the correct passphrase
- Try listing your keys to verify the key is present
File Won't Encrypt
- Ensure you have a public key for the recipient
- Check that a default recipient is set
- Verify the public key corresponds to the intended recipient
Passphrase Issues
- If you forget a passphrase, you'll need to remove and re-import the key
- Use the "Show Logs" command to see detailed error messages