PHPackages                             irfan-manitechnest/sodium-crypto - 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. irfan-manitechnest/sodium-crypto

ActiveLibrary[Security](/categories/security)

irfan-manitechnest/sodium-crypto
================================

A modern PHP 8.3+ encryption library (Fidelius replacement) using the Sodium extension.

v1.0.0(9mo ago)01MITPHPPHP &gt;=8.3CI passing

Since Jul 31Pushed 9mo agoCompare

[ Source](https://github.com/irfan-manitechnest/sodium-crypto)[ Packagist](https://packagist.org/packages/irfan-manitechnest/sodium-crypto)[ RSS](/packages/irfan-manitechnest-sodium-crypto/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

SodiumCrypto – A Modern PHP Encryption Library (Fidelius Replacement)
=====================================================================

[](#sodiumcrypto--a-modern-php-encryption-library-fidelius-replacement)

[![PHPUnit Tests](https://github.com/irfan-manitechnest/sodium-crypto/actions/workflows/tests.yml/badge.svg)](https://github.com/irfan-manitechnest/sodium-crypto/actions/workflows/tests.yml)[![PHP Version](https://camo.githubusercontent.com/89899a77bdce65fc4c3d3423dfacff9c6461066a0b5354dc18d7721c23ba596e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d626c75652e737667)](https://www.php.net/)[![Packagist Version](https://camo.githubusercontent.com/4c7117efde1fbb68a208233add916813f8bf1cfe10f1b3576fe6c6c268a2cb0d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f697266616e2d6d616e69746563686e6573742f736f6469756d2d63727970746f2e737667)](https://packagist.org/packages/irfan-manitechnest/sodium-crypto)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

A modern PHP 8.3+ encryption library (Fidelius replacement) using the Sodium extension.

A lightweight, object-oriented encryption/decryption library built on PHP's [libsodium extension](https://www.php.net/manual/en/book.sodium.php). It provides both **symmetric** and **asymmetric authenticated encryption** workflows (Fidelius-compatible), secure signing, password hashing, and utilities.

---

✨ Features
----------

[](#-features)

- ✅ Modern PHP 8.3+ OOP API
- ✅ Asymmetric Authenticated Encryption (Fidelius-like) with `sodium_crypto_box`
- ✅ Symmetric Encryption (secretbox) for fast, secure storage encryption
- ✅ Digital Signatures (signing and verification)
- ✅ Password hashing &amp; secure password-based encryption
- ✅ Fully tested with PHPUnit 10+
- ✅ PSR-4 compliant and ready for Packagist

---

📦 Installation
--------------

[](#-installation)

```
composer require irfan-manitechnest/sodium-crypto
```

Ensure the PHP [Sodium extension](https://www.php.net/manual/en/book.sodium.php) is enabled (`php_sodium.dll` or built-in since PHP 7.2+).

---

🚀 Usage Examples
----------------

[](#-usage-examples)

### 🔑 Generate Asymmetric Key Pairs

[](#-generate-asymmetric-key-pairs)

```
use SodiumCrypto\Crypto\FideliusEncryptor;

$keys = FideliusEncryptor::generateKeyPair();

echo "Public Key: " . $keys['publicKey'] . PHP_EOL;
echo "Private Key: " . $keys['privateKey'] . PHP_EOL;
```

---

### 🔒 Asymmetric Encryption (Fidelius-style)

[](#-asymmetric-encryption-fidelius-style)

```
use SodiumCrypto\Crypto\FideliusEncryptor;

// Sender encrypts
$encrypted = FideliusEncryptor::encrypt(
    "Hello Secure World",
    $senderPrivateKey,
    $senderPublicKey,      // Sender's public key
    $recipientPublicKey    // Recipient's public key
);

// Recipient decrypts
$decrypted = FideliusEncryptor::decrypt(
    $encrypted['ciphertext'],
    $encrypted['nonce'],
    $recipientPrivateKey,
    $encrypted['keyToShare'] // Sender's public key
);
```

---

### 🔑 Symmetric Encryption

[](#-symmetric-encryption)

```
use SodiumCrypto\Crypto\Encryptor;

$key = Encryptor::generateKey();
$cipher = Encryptor::encrypt("Secret Message", $key);
$plain  = Encryptor::decrypt($cipher, $key);
```

---

### ✍️ Digital Signatures

[](#️-digital-signatures)

```
use SodiumCrypto\Crypto\Signer;

$signKeys = Signer::generateKeyPair();
$signature = Signer::sign("Important data", $signKeys['privateKey']);

$isValid = Signer::verify("Important data", $signature, $signKeys['publicKey']);
```

---

### 🔑 Password Hashing

[](#-password-hashing)

```
use SodiumCrypto\Crypto\PasswordEncryptor;

$hash = PasswordEncryptor::hashPassword("SuperSecret");
$isValid = PasswordEncryptor::verifyPassword("SuperSecret", $hash);
```

---

🧪 Running Tests
---------------

[](#-running-tests)

```
composer install
vendor/bin/phpunit
```

All tests are defined in `tests/` and use PHPUnit 10+.

---

📂 Project Structure
-------------------

[](#-project-structure)

```
src/
  Crypto/
    Encryptor.php
    FideliusEncryptor.php
    KeyManager.php
    Signer.php
    PasswordEncryptor.php
    Utils.php
  Exception/
    *.php
tests/
  Crypto/
    *.php
phpunit.xml
composer.json

```

---

🏗 Architecture
--------------

[](#-architecture)

Below is the UML diagram representing the library's structure and relationships:

[![SodiumCrypto UML](https://raw.githubusercontent.com/irfan-manitechnest/sodium-crypto/main/SodiumCrypto_UML.png)](https://raw.githubusercontent.com/irfan-manitechnest/sodium-crypto/main/SodiumCrypto_UML.png)

This diagram illustrates the core classes (`Encryptor`, `FideliusEncryptor`, `KeyManager`, `Signer`, `PasswordEncryptor`, and `Utils`) and how they interact. Exception classes are thrown across all cryptographic components.

---

📜 License
---------

[](#-license)

MIT License – Use freely in commercial and open-source projects.

---

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

[](#-contributing)

Pull requests are welcome! Please run PHPUnit tests before submitting.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance57

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

286d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/eadbfe0acd16b5c4226611540d7000f41212e5ebbaa6a58d94384d0e8ef27926?d=identicon)[irfan-manitechnest](/maintainers/irfan-manitechnest)

---

Top Contributors

[![irfan-manitechnest](https://avatars.githubusercontent.com/u/180293896?v=4)](https://github.com/irfan-manitechnest "irfan-manitechnest (3 commits)")

---

Tags

cryptographyfideliuslibsodiumphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/irfan-manitechnest-sodium-crypto/health.svg)

```
[![Health](https://phpackages.com/badges/irfan-manitechnest-sodium-crypto/health.svg)](https://phpackages.com/packages/irfan-manitechnest-sodium-crypto)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

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