How to Generate a PGP Key Safely
Why Key Generation Matters
Your PGP key pair is the foundation of your cryptographic identity. If your key is generated with weak randomness, protected by a guessable passphrase, or lost without a backup, your encrypted communications are at risk. Taking a few minutes to generate and store your key properly saves you from permanent data loss later.
You can generate a PGP key online in seconds using our client-side tool, or use desktop software like GnuPG. In both cases, the same core security principles apply.
Step 1: Choose Your User ID (Name and Email)
Every PGP key includes a User ID, typically formatted as Your Name <you@example.com>. Email clients such as Thunderbird and Proton Mail use this email address to automatically match incoming public keys to your contacts.
If you are creating a key for work or everyday correspondence, use your real name and primary email address. If you are creating a key for anonymous or pseudonymous communication, use a dedicated pseudonym and avoid linking it to your personal accounts.
Step 2: Pick a Strong, Unique Passphrase
Your private key is protected by a passphrase. If someone steals your private key file, the passphrase is the last line of defense preventing them from reading your messages or signing statements in your name.
Avoid short passwords, birthdays, or common dictionary words. Instead, use a passphrase of at least 4 to 6 random words (such as a Diceware passphrase) or a 16+ character random string stored in a reputable password manager. Never reuse your email or banking password as your PGP passphrase. Note that the current web form on OnlinePGP.com does not enforce a minimum passphrase length, so it is up to you to choose a strong one.
Step 3: Generate and Download Both Keys
Open the Generate Keys tab on OnlinePGP.com, enter your name, email, and passphrase, and click GENERATE NEW PGP KEYS PAIR. Behind the scenes, OpenPGP.js uses your browser's cryptographically secure random number generator (window.crypto.getRandomValues) to create a 2048-bit RSA key pair locally—your key is never uploaded to our server.
Immediately click DOWNLOAD PRIVATE KEY and DOWNLOAD PUBLIC KEY to save privateKey.txt and publicKey.txt. Keep your private key strictly confidential and never share it with anyone.
Algorithms and Key Sizes: RSA-2048 vs. RSA-4096 and Curve25519
Be aware of what this tool does and does not offer: OnlinePGP.com currently generates 2048-bit RSA keys only and does not let you choose the algorithm or key size. RSA-2048 is still widely supported across older and newer OpenPGP clients.
However, if you are generating a long-term master key in desktop GnuPG, 4096-bit RSA or modern elliptic-curve keys—specifically Curve25519 (Ed25519 for signing and X25519 for encryption)—are better defaults. In GnuPG, you can run gpg --full-generate-key to choose your algorithm, key size, and expiration date interactively.
Backing Up Your Private Key Safely
Because PGP has no central server or 'Forgot Password' recovery, losing your private key means permanently losing access to any messages encrypted to it. Store your privateKey.txt file in at least two secure locations: for example, inside an encrypted disk volume, on an offline hardware-encrypted USB drive, or as a secure note in your password manager.
For advanced setups, hardware security keys (such as a YubiKey) can store your private key on a tamper-resistant chip so the key material never leaves the hardware device during decryption or signing.
Expiration, Rotation, and Revocation Certificates
Even well-protected keys should not live forever. Setting an expiration date (such as 1 to 2 years) on desktop GPG keys ensures that if you lose access to a key, contacts will eventually stop using it. You can always extend an expiration date later if you still control the key.
A revocation certificate is a special signed file that tells the world a key is no longer valid—essential if your private key is stolen or you forget your passphrase. You should generate a revocation certificate while you still have working access to your key. Note that OnlinePGP.com does not currently generate revocation certificates; if you need one, import your key into GnuPG and run gpg --gen-revoke.
What to Do Next
Once your key pair is safely backed up, you can share your publicKey.txt with contacts and start encrypting. Read How to Share Your Public Key and Verify Fingerprints, How to Encrypt and Decrypt a Message with PGP Step by Step, and Common PGP Mistakes.
Recommended Privacy Tools
Pair PGP with strong everyday privacy habits:
- Proton Mail — Encrypted email with built-in OpenPGP support.
- NordVPN — Encrypts your network traffic on public Wi-Fi.
- Bitwarden / 1Password — Store strong, unique PGP passphrases safely.
Frequently Asked Questions
What key size should I choose for PGP?
OnlinePGP.com currently generates 2048-bit RSA keys, which remain widely interoperable. For new long-term keys in desktop GnuPG, 4096-bit RSA or Curve25519 (Ed25519/X25519) is a stronger default.
What happens if I forget my PGP passphrase?
If you forget your passphrase, your private key cannot be unlocked and any messages encrypted to that key cannot be decrypted. There is no password reset in PGP.
Should I put my real name and email in my PGP key?
For standard email communication, yes, because mail clients match keys by email address. For pseudonymous use, you can use a pseudonym.
Can I generate a PGP key offline?
Yes. Using GnuPG on an offline or air-gapped computer is the gold standard for high-risk threat models, because the key never touches an internet-connected device.
Try It Now with OnlinePGP.com
Put this guide into practice right away. Generate a PGP key pair, encrypt a message, or verify a signature 100% locally in your browser.
Open the Online PGP Tool