PHPackages                             slam/php-symmetric-encryption - 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. slam/php-symmetric-encryption

ActiveLibrary[Security](/categories/security)

slam/php-symmetric-encryption
=============================

PHP Symmetric Encryption

v1.5.1(2mo ago)115.7k↓75%[1 issues](https://github.com/Slamdunk/php-symmetric-encryption/issues)MITPHPPHP ~8.4.0 || ~8.5.0CI passing

Since Nov 8Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Slamdunk/php-symmetric-encryption)[ Packagist](https://packagist.org/packages/slam/php-symmetric-encryption)[ Docs](https://github.com/slamdunk/php-symmetric-encryption)[ Fund](https://paypal.me/filippotessarotto)[ GitHub Sponsors](https://github.com/Slamdunk)[ RSS](/packages/slam-php-symmetric-encryption/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (5)Versions (11)Used By (0)

Slam / php-symmetric-encryption
===============================

[](#slam--php-symmetric-encryption)

[![Latest Stable Version](https://camo.githubusercontent.com/a2f510463a6380879980181618ec38db4764b7ea1f89a76e528e898a3b03e10c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c616d2f7068702d73796d6d65747269632d656e6372797074696f6e2e737667)](https://packagist.org/packages/slam/php-symmetric-encryption)[![Downloads](https://camo.githubusercontent.com/5caee277cbdacea6dcd1f2f7a82957f9f6900c030c987ec2b927a3133a861e65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736c616d2f7068702d73796d6d65747269632d656e6372797074696f6e2e737667)](https://packagist.org/packages/slam/php-symmetric-encryption)[![Integrate](https://github.com/Slamdunk/php-symmetric-encryption/workflows/CI/badge.svg?branch=master)](https://github.com/Slamdunk/php-symmetric-encryption/actions)[![Code Coverage](https://camo.githubusercontent.com/8b20ae37a30b380358514338c5246a335f1fdcc75b00805cc5da3a0abbcfc79e/68747470733a2f2f636f6465636f762e696f2f67682f536c616d64756e6b2f7068702d73796d6d65747269632d656e6372797074696f6e2f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/gh/Slamdunk/php-symmetric-encryption?branch=master)[![Infection MSI](https://camo.githubusercontent.com/d334e3e8a3ce7e5c69281a9dc32099505abec452934a94e52ef920ecd614fd21/68747470733a2f2f62616467652e737472796b65722d6d757461746f722e696f2f6769746875622e636f6d2f536c616d64756e6b2f7068702d73796d6d65747269632d656e6372797074696f6e2f6d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/Slamdunk/php-symmetric-encryption/master)

V1: encrypt strings with [`sodium_crypto_aead_xchacha20poly1305_ietf_encrypt`](https://www.php.net/manual/en/function.sodium-crypto-aead-xchacha20poly1305-ietf-encrypt.php) function.

Installation
------------

[](#installation)

To install with composer run the following command:

```
$ composer require slam/php-symmetric-encryption
```

Usage
-----

[](#usage)

```
use SlamSymmetricEncryption\V1Encryptor;

// Generate a key and save it somewhere
$key = V1Encryptor::generateKey();
var_dump($key); // string(44) "Hog2u9jtOzyt+mPyAJwp8v3dI6Uvp1T4FUKrAjizVGo="

// Use the key
$encryptor = new V1Encryptor($key);

$ciphertext = $encryptor->encrypt('foo');
var_dump($ciphertext); // string(59) "dznmjbqHnI_26crKpRYvp125K9N6ctqU0kVCmoSRbG7HAKCIrnAz0RBELQ"

$plaintext = $encryptor->decrypt($ciphertext);
var_dump($plaintext); // string(3) "foo"
```

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance67

Regular maintenance activity

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 93.2% 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 ~224 days

Recently: every ~211 days

Total

8

Last Release

84d ago

PHP version history (5 changes)v1.0.0PHP &gt;=8.0

v1.1.0PHP ~8.1.0 || ~8.2.0

v1.3.0PHP ~8.2.0 || ~8.3.0

v1.4.0PHP ~8.3.0 || ~8.4.0

v1.5.0PHP ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/50348?v=4)[Sahn Lam](/maintainers/Slam)[@slam](https://github.com/slam)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (276 commits)")[![Slamdunk](https://avatars.githubusercontent.com/u/152236?v=4)](https://github.com/Slamdunk "Slamdunk (20 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/slam-php-symmetric-encryption/health.svg)

```
[![Health](https://phpackages.com/badges/slam-php-symmetric-encryption/health.svg)](https://phpackages.com/packages/slam-php-symmetric-encryption)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[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

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

Realistic password strength estimation PHP library based on Zxcvbn JS

87117.5M63](/packages/bjeavons-zxcvbn-php)[illuminate/encryption

The Illuminate Encryption package.

9229.7M280](/packages/illuminate-encryption)[paragonie/hidden-string

Encapsulate strings in an object to hide them from stack traces

7410.6M39](/packages/paragonie-hidden-string)

PHPackages © 2026

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