PHPackages                             botdigit/completeopenpgp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. botdigit/completeopenpgp

ActiveLibrary[Security](/categories/security)

botdigit/completeopenpgp
========================

A high-performance OpenPGP cryptography library for PHP and Laravel supporting RSA, ElGamal, Ed25519 (EdDSA), ECDSA, and ECDH. Modern, secure, and zero-dependency alternative to php-gnupg.

v1.1.1(1mo ago)336PHP

Since Dec 10Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Tarun-developer/completeopenpgp)[ Packagist](https://packagist.org/packages/botdigit/completeopenpgp)[ RSS](/packages/botdigit-completeopenpgp/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (9)Versions (7)Used By (0)

CompleteOpenPGP: Ultimate OpenPGP Cryptography Package for PHP &amp; Laravel
============================================================================

[](#completeopenpgp-ultimate-openpgp-cryptography-package-for-php--laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/17b3f453d4209b781eb924aab32bc47ec578c2c0661537d31cd3781045601e74/68747470733a2f2f706f7365722e707567782e6f72672f626f7464696769742f636f6d706c6574656f70656e7067702f762f737461626c65)](https://packagist.org/packages/botdigit/completeopenpgp)[![Total Downloads](https://camo.githubusercontent.com/5e9be6d473785fbaa0f0267236670a96202a22fefeb2cdee198a33829ff41ee8/68747470733a2f2f706f7365722e707567782e6f72672f626f7464696769742f636f6d706c6574656f70656e7067702f646f776e6c6f616473)](https://packagist.org/packages/botdigit/completeopenpgp)[![License](https://camo.githubusercontent.com/4e6cfe999c9c3790c2b26c985e71d40217e484752a681ba196eb9fc1c527cfe7/68747470733a2f2f706f7365722e707567782e6f72672f626f7464696769742f636f6d706c6574656f70656e7067702f6c6963656e7365)](https://packagist.org/packages/botdigit/completeopenpgp)[![PHP Version](https://camo.githubusercontent.com/25e206969c7ba10d4fab3d9fa99b218d6d72a91f74e6067b6ddffa29d2509600/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f626f7464696769742f636f6d706c6574656f70656e706770)](https://packagist.org/packages/botdigit/completeopenpgp)

**CompleteOpenPGP** is the definitive, zero-dependency external OpenPGP library for PHP 8.1+ and Laravel. It integrates military-grade cryptographic primitives, supporting **RSA**, **ElGamal**, **EdDSA (Ed25519)**, **ECDSA**, and **ECDH** key generation, signing, and encryption.

This package is optimized for both human developers and AI coding assistants (like Copilot, Cursor, Gemini, and GPT), featuring clean namespaces, strict type contracts, and detailed error handling.

For premium digital platforms, tools, and enterprise security consulting, visit [botdigit.com](https://botdigit.com).

---

🎯 Target Search Keywords (SEO)
------------------------------

[](#-target-search-keywords-seo)

`PHP OpenPGP`, `Laravel OpenPGP`, `Ed25519 PHP`, `ECDH ECIES PHP`, `ElGamal Cryptography PHP`, `pure PHP PGP encryption`, `libsodium sealed box`, `secp256k1 PHP`, `NIST P-256`, `php-gnupg alternative`, `ASCII Armor CRC24`, `detached signatures PHP`.

---

📚 Table of Contents
-------------------

[](#-table-of-contents)

- [Comparison Matrix](#-cryptosystem-comparison-matrix)
- [Requirements](#-requirements)
- [Installation](#-installation)
- [Configuration](#-configuration)
- [Quick Start API Examples](#-quick-start-api-examples)
    - [1. Key Generation](#1-key-generation)
    - [2. Public-Key Encryption &amp; Decryption](#2-public-key-encryption--decryption)
    - [3. Detached Signatures &amp; Verification](#3-detached-signatures--verification)
    - [4. ASCII Armoring &amp; CRC24 Integrity](#4-ascii-armoring--crc24-integrity)
- [API Reference Manual](#-api-reference-manual)
- [Troubleshooting &amp; FAQ](#-troubleshooting--faq)
- [Contributing &amp; Roadmap](#-contributing)
- [License](#-license)

---

📊 Cryptosystem Comparison Matrix
--------------------------------

[](#-cryptosystem-comparison-matrix)

Use the matrix below to choose the right algorithm for your application security requirements:

AlgorithmPurposesStandard Curve / Key SizesUnderlying DriverSecurity Properties**RSA**Encrypt &amp; Sign`2048`, `3072`, `4096` bits`phpseclib3`Traditional PKCS1 / OAEP**ElGamal**Encrypt Only`2048` bits (MODP Group 14)`phpseclib3` BigIntegerDiscrete Logarithm Hardness**EdDSA**Sign &amp; Encrypt`Ed25519` (Converted to `Curve25519` for Box)`libsodium`High performance, side-channel immune**ECDSA**Sign Only`nistp256`, `nistp384`, `secp256k1``phpseclib3` ECModern elliptic curve signatures**ECDH**Encrypt Only`nistp256`, `nistp384`, `secp256k1``phpseclib3` DH + AES-256-GCMHybrid ECIES key agreement---

⚡ Requirements
--------------

[](#-requirements)

- **PHP**: `^8.1`
- **Extensions**:
    - `libsodium` (Required for EdDSA Ed25519 operations)
    - `openssl` (Required for AES-256-GCM symmetric ciphers in ECDH)
- **Key Dependencies**:
    - `phpseclib/phpseclib`: `^3.0`

---

🛠 Installation
--------------

[](#-installation)

```
composer require botdigit/completeopenpgp
```

### Laravel Integration (Optional)

[](#laravel-integration-optional)

The service provider automatically registers the unified service container. You can publish the configuration file to customize defaults:

```
php artisan vendor:publish --provider="CompleteOpenPGP\CompleteOpenPGPServiceProvider"
```

---

⚙️ Configuration
----------------

[](#️-configuration)

Your published `config/completeopenpgp.php` provides global defaults:

```
return [
    'key_storage' => storage_path('keys'),
    'default_curve' => 'nistp256', // curves: nistp256, nistp384, secp256k1
    'signing_key' => env('PGP_SIGNING_KEY'),
    'encryption_key' => env('PGP_ENCRYPTION_KEY'),
    'passphrase' => env('PGP_PASSPHRASE'),
];
```

---

🚀 Quick Start API Examples
--------------------------

[](#-quick-start-api-examples)

Here are copy-pasteable snippets for immediate implementation.

### 1. Key Generation

[](#1-key-generation)

Generates cryptographically secure key pairs in PEM (PKCS8) or Base64 formats.

```
use KeyManagement\PGPKeyManager;

// RSA (Traditional)
$rsa = PGPKeyManager::generateKey('RSA', 2048);
// public key string:  $rsa['public']
// private key string: $rsa['private']

// ElGamal (Discrete Logarithm)
$elgamal = PGPKeyManager::generateKey('ElGamal');

// EdDSA (Ed25519 - Libsodium)
$eddsa = PGPKeyManager::generateKey('EdDSA');

// ECDSA (Elliptic Curve Signatures)
$ecdsa = PGPKeyManager::generateKey('ECDSA', 'secp256k1');

// ECDH (Elliptic Curve Encryption)
$ecdh = PGPKeyManager::generateKey('ECDH', 'nistp256');
```

### 2. Public-Key Encryption &amp; Decryption

[](#2-public-key-encryption--decryption)

```
use KeyManagement\PGPKeyManager;

$payload = "Sensible financial transaction payload";

// ----------------------------------------
// RSA Encryption
// ----------------------------------------
$encRsa = PGPKeyManager::encrypt('RSA', $payload, $rsa['public']);
$decRsa = PGPKeyManager::decrypt('RSA', $encRsa, $rsa['private']);

// ----------------------------------------
// EdDSA Encryption (Converts Ed25519 to Curve25519 Sealed Box)
// ----------------------------------------
$encEd = PGPKeyManager::encrypt('EdDSA', $payload, $eddsa['public']);
$decEd = PGPKeyManager::decrypt('EdDSA', $encEd, $eddsa['private']);

// ----------------------------------------
// ECDH Encryption (ECIES Hybrid AES-256-GCM)
// ----------------------------------------
$encEcdh = PGPKeyManager::encrypt('ECDH', $payload, $ecdh['public']);
$decEcdh = PGPKeyManager::decrypt('ECDH', $encEcdh, $ecdh['private']);
```

### 3. Detached Signatures &amp; Verification

[](#3-detached-signatures--verification)

Verify the integrity of a message using detached signature arrays.

```
use KeyManagement\PGPKeyManager;

$message = "Verified document transmission.";

// --- EdDSA Signature ---
$sig = PGPKeyManager::sign('EdDSA', $message, $eddsa['private']);
$isValid = PGPKeyManager::verify('EdDSA', $message, $sig, $eddsa['public']); // returns bool(true)

// --- ECDSA Signature ---
$sigEcdsa = PGPKeyManager::sign('ECDSA', $message, $ecdsa['private']);
$isValidEcdsa = PGPKeyManager::verify('ECDSA', $message, $sigEcdsa, $ecdsa['public']); // returns bool(true)
```

### 4. ASCII Armoring &amp; CRC24 Integrity

[](#4-ascii-armoring--crc24-integrity)

Generate and parse RFC-4880 standard-compliant PGP ASCII armor strings.

```
use KeyManagement\PGPKeyManager;

$secretData = "Confidential Payload";

// Armor data with headers
$armored = PGPKeyManager::enarmor($secretData, 'MESSAGE', [
    'Version' => 'CompleteOpenPGP v1.1.0',
    'Comment' => 'Secure Message'
]);

echo $armored;
/*
-----BEGIN MESSAGE-----
Version: CompleteOpenPGP v1.1.0
Comment: Secure Message

U2VjcmV0IFBheWxvYWQ=
=3y9d
-----END MESSAGE-----
*/

// Unarmor and automatically verify CRC24 checksum
$unarmored = PGPKeyManager::unarmor($armored, 'MESSAGE');
// returns "Confidential Payload"
```

---

📖 API Reference Manual
----------------------

[](#-api-reference-manual)

### Class `KeyManagement\PGPKeyManager`

[](#class-keymanagementpgpkeymanager)

#### `generateKey(string $algorithm = 'RSA', int|string $keySizeOrCurve = 2048): array`

[](#generatekeystring-algorithm--rsa-intstring-keysizeorcurve--2048-array)

Generates key pair.

- **Algorithms**: `'RSA'`, `'ElGamal'`, `'EdDSA'`, `'ECDSA'`, `'ECDH'`
- **Returns**: `['public' => string, 'private' => string]`

#### `encrypt(string $algorithm, string $message, string $publicKey): string`

[](#encryptstring-algorithm-string-message-string-publickey-string)

Encrypts plaintext payload.

- **Returns**: Base64 encoded ciphertext string.

#### `decrypt(string $algorithm, string $ciphertext, string $privateKey): string`

[](#decryptstring-algorithm-string-ciphertext-string-privatekey-string)

Decrypts ciphertext payload.

- **Returns**: Decrypted plaintext string.

#### `sign(string $algorithm, string $message, string $privateKey): string`

[](#signstring-algorithm-string-message-string-privatekey-string)

Generates a detached cryptographic signature.

- **Returns**: Binary signature string.

#### `verify(string $algorithm, string $message, string $signature, string $publicKey): bool`

[](#verifystring-algorithm-string-message-string-signature-string-publickey-bool)

Verifies signature validity.

- **Returns**: `true` on success, `false` on failure.

#### `enarmor(string $data, string $marker = 'MESSAGE', array $headers = []): string`

[](#enarmorstring-data-string-marker--message-array-headers---string)

Encodes data block into ASCII armored PGP format.

#### `unarmor(string $text, string $marker = 'MESSAGE'): string`

[](#unarmorstring-text-string-marker--message-string)

Decodes ASCII armored PGP text, validating headers and CRC24 checksum.

---

❓ Troubleshooting &amp; FAQ
---------------------------

[](#-troubleshooting--faq)

#### Q: Getting `sodium_crypto_sign_ed25519_pk_to_curve25519()` error?

[](#q-getting-sodium_crypto_sign_ed25519_pk_to_curve25519-error)

**A**: Ensure the PHP `sodium` extension is enabled. Check using `php -m | grep sodium`.

#### Q: How does EdDSA support encryption if it is a signature scheme?

[](#q-how-does-eddsa-support-encryption-if-it-is-a-signature-scheme)

**A**: EdDSA (Ed25519) keys are mathematical representations of points on Curve25519. CompleteOpenPGP extracts these coordinates and converts them to Curve25519 birational equivalents to support Sealed Box encryption securely, mirroring modern GnuPG behaviors.

#### Q: Is the CRC24 checksum verification standard?

[](#q-is-the-crc24-checksum-verification-standard)

**A**: Yes, the package implements the OpenPGP standard CRC-24 generator polynomial (`0x1864CFB`) and initialization vector (`0xB704CE`) specified in **RFC 4880**.

---

🤝 Contributing
--------------

[](#-contributing)

We welcome security audits and updates from the open-source community. If you encounter any bugs, security issues, or have optimization proposals, please open an Issue or a Pull Request.

---

📄 License
---------

[](#-license)

This library is open-source software licensed under the [MIT License](LICENSE).

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance92

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~114 days

Recently: every ~143 days

Total

6

Last Release

41d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f7f790296887cbdc7d0e957467b9115360bf1fe5c11f9639ae98f31ec95127c9?d=identicon)[botdigit](/maintainers/botdigit)

---

Top Contributors

[![Tarun-developer](https://avatars.githubusercontent.com/u/28224590?v=4)](https://github.com/Tarun-developer "Tarun-developer (2 commits)")

---

Tags

cryptographyecdhed25519elgamallaravelopenpgppgpphp-gnupgcryptographyencryptionsignaturersaecdhEd25519EdDSAsecurePGPopenpgpECDSAECIESelgamalhybrid-encryptionlaravel-pgplaravel-openpgp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/botdigit-completeopenpgp/health.svg)

```
[![Health](https://phpackages.com/badges/botdigit-completeopenpgp/health.svg)](https://phpackages.com/packages/botdigit-completeopenpgp)
```

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k476.2M1.7k](/packages/phpseclib-phpseclib)[paragonie/sodium_compat

Pure PHP implementation of libsodium; uses the PHP extension if it exists

932149.1M197](/packages/paragonie-sodium-compat)[simplito/elliptic-php

Fast elliptic curve cryptography

2312.5M279](/packages/simplito-elliptic-php)[ionux/phactor

Phactor is a high-performance PHP implementation of the elliptic curve math functions required to generate &amp; verify private/public (asymmetric) EC keypairs and ECDSA signatures based on secp256k1 curve parameters. This library also includes a class to generate Service Identification Numbers (SINs) based on the published Identity Protocol v1 spec.

5391.1k30](/packages/ionux-phactor)[vlucas/pikirasa

PKI public/private RSA key encryption using the OpenSSL extension

104106.2k1](/packages/vlucas-pikirasa)[asymmetricrypt/asymmetricrypt

A simple PHP public key cryptography library

104.4k](/packages/asymmetricrypt-asymmetricrypt)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
