PHPackages                             syntaxseed/libsodium - 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. syntaxseed/libsodium

ActiveLibrary[Security](/categories/security)

syntaxseed/libsodium
====================

A wrapper/facade class for PHP's Libsodium extension functions. Covers symmetric and public key encryption functions.

v1.0.4(1y ago)346MITPHPPHP ^8.0|^8.1|^8.2|^8.3

Since Oct 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/syntaxseed/libsodiumfacade)[ Packagist](https://packagist.org/packages/syntaxseed/libsodium)[ RSS](/packages/syntaxseed-libsodium/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (6)Used By (0)

Libsodium Facade
================

[](#libsodium-facade)

 [![GitHub tag (latest SemVer)](https://camo.githubusercontent.com/34d5ed5db6cc1390ef3b57e6bfa6273534437f7aa6681644d71e2e6c2bd01076/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f73796e746178736565642f6c6962736f6469756d6661636164652e737667)](https://camo.githubusercontent.com/34d5ed5db6cc1390ef3b57e6bfa6273534437f7aa6681644d71e2e6c2bd01076/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f73796e746178736565642f6c6962736f6469756d6661636164652e737667) [![PHP v8.0+](https://camo.githubusercontent.com/81e4e007d20e342305d6e5db0c1495a2e805692299266abe8665596e87bac30c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302b2d627269676874677265656e2e737667)](https://camo.githubusercontent.com/81e4e007d20e342305d6e5db0c1495a2e805692299266abe8665596e87bac30c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302b2d627269676874677265656e2e737667) [![PHP v8.1+](https://camo.githubusercontent.com/e6cebb42666cfbdd19ff9d0fb9412179dbb1f973ac2c65c5d4c9a3632fa40330/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312b2d627269676874677265656e2e737667)](https://camo.githubusercontent.com/e6cebb42666cfbdd19ff9d0fb9412179dbb1f973ac2c65c5d4c9a3632fa40330/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312b2d627269676874677265656e2e737667) [![License: MIT](https://camo.githubusercontent.com/dd78cddde448ab3a81183bd0540be271d7fc8af76c14470a81607515822193c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73796e746178736565642f74656d706c61746573656564)](https://camo.githubusercontent.com/dd78cddde448ab3a81183bd0540be271d7fc8af76c14470a81607515822193c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73796e746178736565642f74656d706c61746573656564)
 [![follow on Twitter](https://camo.githubusercontent.com/57ed9099a81a900fc8ddcc4173da21d688a269684c00c64c94c42c9b75faff3a/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f73796e746178736565642e7376673f7374796c653d736f6369616c266c6f676f3d74776974746572)](https://twitter.com/intent/follow?screen_name=syntaxseed) [![Sponsor Project](https://camo.githubusercontent.com/e699f94416c82026cff6cc197dbdeb21e3fcd1fb9622550f8fe9d89967dc337b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d50726f6a6563742d626c7565)](https://github.com/syntaxseed#donatecontribute)

A wrapper/facade class for PHP's LibSodium extension. Providing symmetric and public key encryption and decryption static methods, and key generation methods.

Hex-encoded: All output converted to hex. Inputs expect hex-encoded values.

- Licence: MIT
- Version: 1.0.4
- PHP Versions: 8.0+, 8.1+, 8.2+, 8.3+.
- Author: Sherri Wheeler
- Packagist:

Install
-------

[](#install)

Via Composer:

```
composer require syntaxseed/libsodium

```

Or add to composer.json:

```
"require": {
    "syntaxseed/libsodium": "^1.0"
},

```

Static Functions
----------------

[](#static-functions)

- Symmetric Encryption (one secret key)

    - generateSymmetricKey()
    - symmetricEncrypt($secretString, $symmetricKey)
    - symmetricDecrypt($encryptedString, $nonce, $key)
- Public-Key Encryption (public/private key pair)

    - generateKeyPair()
    - publicKeyEncrypt($secretString, $theirPublicKey, $ourPrivateKey)
    - publicKeyDecrypt($encryptedString, $nonce, $ourPublicKey, $theirPrivateKey)

Usage
-----

[](#usage)

See `examples/` directory.

Changelog
---------

[](#changelog)

- v1.0.0 - (2018-10-27) Created. Added to GitHub.
    - v1.0.1 - (2018-10-27) Update readme, add Composer instructions.
    - v1.0.2 - (2022-02-02) Test for PHP 8.0. Add example usage file.
    - v1.0.3 - (2022-03-13) Test for PHP 8.1. Fix PSR formatting.
    - v1.0.4 - (2024-12-18) Test for PHP 8.3.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance40

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 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 ~561 days

Total

5

Last Release

512d ago

PHP version history (4 changes)v1.0.0PHP &gt;=7.2

v1.0.2PHP ^7.2|^8.0

v1.0.3PHP ^8.0|^8.1

v1.0.4PHP ^8.0|^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/812750e6370c8e25a9fe430e200c80a92cd65a47a2e0d919f982cb5d264726e7?d=identicon)[syntaxseed](/maintainers/syntaxseed)

---

Top Contributors

[![syntaxseed](https://avatars.githubusercontent.com/u/825423?v=4)](https://github.com/syntaxseed "syntaxseed (9 commits)")

---

Tags

encryptionlibsodiumfacadesodium

### Embed Badge

![Health badge](/badges/syntaxseed-libsodium/health.svg)

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

###  Alternatives

[phpseclib/phpseclib

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

5.6k434.8M1.3k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[paragonie/halite

High-level cryptography interface powered by libsodium

1.2k9.4M63](/packages/paragonie-halite)[paragonie/ciphersweet

Searchable field-level encryption library for relational databases

4641.2M21](/packages/paragonie-ciphersweet)

PHPackages © 2026

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