PgpCore wraps one library's OpenPGP classes behind a few file and string helpers (PGP, EncryptFile, DecryptFile, SignFile, VerifyFile, GenerateKey, EncryptFileAndSign, DecryptFileAndVerify, InlineSign, ClearSign). OneCrypto's Pgp class covers the same tasks directly, on an OpenPGP implementation of its own with no other dependency. There is no compatibility layer. The PgpCore names below come from its public documentation.
Differences to know first:
- Keys are objects, not files. A certificate (public key with its User IDs and signatures) or a certificate with its secret keys is a
PgpCertificate. Read it withPgpCertificate.Parse(bytes)(binary or armored); write it withExport()orExportPublic(). Nothing needs a file path, and stream overloads take streams. - The passphrase is a parameter, the algorithm is not. Ciphers, hashes, the container (SEIPD v2 with AEAD, or v1 with an integrity check) and compression come from the recipients' key preferences and the policy.
- Integrity is not optional. Plaintext is released only after the AEAD tag or the MDC has verified; unauthenticated messages are refused unless you opt in with the layered
PgpReadOptions.AllowUnauthenticatedEncryption. - Signatures are reported, never thrown.
Verify*returns a verdict per signature, with the reasons (unknown signer, expired key, weak hash, wrong data) and the signer's key. - Time is explicit. Calls take a
TimeProvider(the system clock when null).
| Task | PgpCore | OneCrypto |
|---|---|---|
| Generate a key pair | GenerateKey(publicOut, privateOut, username, password) | PgpCertificate key = Pgp.GenerateKey("Name <mail>", password); key.ExportPublic(armor: true), key.Export(armor: true) |
| A post-quantum key | not available | Pgp.GenerateKey("Name <mail>", CryptoPolicy.Cnsa2) (ML-DSA-87 with Ed448, ML-KEM-1024 with X448); onecrypto fix adds a hybrid encryption subkey to an existing key |
| Load keys | EncryptionKeys, SigningKeys from files or strings | PgpCertificate.Parse(File.ReadAllBytes(path)); a GnuPG home or cert-d store through GnuPGHome and CertDirectory |
| Encrypt a file | EncryptFile(input, output, publicKeyFile, armor) | File.WriteAllBytes(output, Pgp.Encrypt(File.ReadAllBytes(input), recipient, armor: true)); for large files Pgp.Encrypt(inStream, outStream, [recipient]) in constant memory |
| Encrypt to several recipients | EncryptionKeys with several keys | Pgp.Encrypt(data, [alice, bob], signer: null) |
| Encrypt with a password | EncryptFile with a symmetric option | Pgp.EncryptWithPassword(data, password) |
| Decrypt | DecryptFile(input, output, privateKeyFile, passphrase) | Pgp.Decrypt(message, secretKey, passphrase).Content; stream overload for large files |
| Sign (detached) | SignFile(input, output, privateKey, passphrase) | Pgp.SignDetached(data, secretKey, passphrase, armor: true) |
| Sign (inline) and clear-sign | InlineSign, ClearSign | Pgp.Sign(data, secretKey, passphrase); clear-signing through the layered PgpMessageWriter.SignCleartext |
| Verify | VerifyFile, VerifyClearFile returning a bool | Pgp.VerifyDetached(data, signature, [signerCertificate]), Pgp.Verify(message, certificates); read HasValidSignature or each Signatures[i].Status and Reasons |
| Encrypt and sign | EncryptFileAndSign | Pgp.Encrypt(data, [recipient], signerCertificate, signerPassphrase) |
| Decrypt and verify | DecryptFileAndVerify | Pgp.Decrypt(message, secretKey, passphrase, signers: [signerCertificate]): Content and HasValidSignature |
| Key servers | not part of it | HkpClient, VksClient, WkdClient in RecursiveAI.OneCrypto.Online; nothing fetches unless you call them |
Migrating keys: keys made by PgpCore are ordinary OpenPGP keys. PgpCertificate.Parse reads them whatever made them (version 4 keys, RSA, ECDSA, EdDSA, ECDH, and the newer version 6 and post-quantum keys). Keys that GnuPG keeps in its home are read from there directly.