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

ActiveLibrary[Security](/categories/security)

driftwood/symmetric-encryption
==============================

PHP wrapper around the OpenSSL library providing preconfigured, binary safe, Authenticated Symmetric Encryption.

2.0.3(5y ago)95951[1 issues](https://github.com/Pixelfck/SymmetricEncryption/issues)[1 PRs](https://github.com/Pixelfck/SymmetricEncryption/pulls)EUPL-1.1PHPPHP ^7.3CI passing

Since Feb 20Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/Pixelfck/SymmetricEncryption)[ Packagist](https://packagist.org/packages/driftwood/symmetric-encryption)[ Docs](https://github.com/Pixelfck/SymmetricEncryption)[ RSS](/packages/driftwood-symmetric-encryption/feed)WikiDiscussions master Synced 1mo ago

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

[![Latest Stable Version](https://camo.githubusercontent.com/ecc39c75877d77e97f26b2ab81b1a5a32518b56c2cc078d30567f669d2b5c86c/68747470733a2f2f706f7365722e707567782e6f72672f6472696674776f6f642f73796d6d65747269632d656e6372797074696f6e2f762f737461626c653f666f726d61743d706c6173746963)](https://packagist.org/packages/driftwood/symmetric-encryption)[![License](https://camo.githubusercontent.com/f7e6a7f20a62cb3a7d6711cbe689ff10fb2cba2f5df1841075cf3020fc018900/68747470733a2f2f706f7365722e707567782e6f72672f6472696674776f6f642f73796d6d65747269632d656e6372797074696f6e2f6c6963656e73653f666f726d61743d706c6173746963)](https://packagist.org/packages/driftwood/symmetric-encryption)SymmetricEncryption
=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#symmetricencryption)

PHP wrapper around the OpenSSL library providing preconfigured Authenticated Symmetric Encryption.

- Simple to use
- Uses only well-known cryptographic building blocks
- Authenticated (Encrypt-then-mac)
- Binary safe

Intended use
------------

[](#intended-use)

This class is intended to function as a preconfigured, drop-in option for whenever symmetric encryption is needed within your PHP project.

The SymmetricEncryption class is intended to be used 'as-is': the various class constants defined are *not* configuration options. Instead, they are there to facilitate easy review of choices made. If you change any of the defined constants, or any other part of the code for that matter, the implied security no longer exists; it would be reduced to just another incarnation of home grown crypto.

Review status
-------------

[](#review-status)

Class SymmetricEncryption has received some informal code reviewing, but not nearly enough to be guaranteed to be secure. Having said that, it is probably more secure than what most people can come up with themselves.

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

[](#installation)

You can either download the code as a [.zip file](https://github.com/Pixelfck/SymmetricEncryption/archive/master.zip) or use [Composer](https://getcomposer.org/) to download it directly from [packagist](https://packagist.org/packages/driftwood/symmetric-encryption), by adding the following to your composer.json file.

```
{
	"require": {
		"driftwood/symmetric-encryption": "^2.0.0"
    }
}
```

Usage
-----

[](#usage)

Since SymmetricEncryption comes preconfigured, you can encrypt and decrypt data using:

```
// Assuming a PSR-4 compatible autoloader

use Driftwood\SymmetricEncryption;
$password = 'correct horse battery staple';

$crypto = new SymmetricEncryption(20);

$encrypted = $crypto->encrypt('Never roll your own crypto.', $password);
$decrypted = $crypto->decrypt($encrypted, $password);

echo $decrypted; // Never roll your own crypto.
```

Maintenance status
------------------

[](#maintenance-status)

This class is actively maintained, yet there are no frequent updates. This is a good thing: updates would mean that there was something that needed fixing, which is generally a very bad thing in cryptography.

The use of a password instead of a key
--------------------------------------

[](#the-use-of-a-password-instead-of-a-key)

SymmetricEncryption expects the user to supply a password. However, passwords are, generally speaking, weak authenticators and it would be more secure to require a strong cryptographic key instead. This choice for requiring a password was made to facilitate maximum simplicity (the user supplied password is stretched into a key using PBKDF2). There is (of course) no maximum password length for SymmetricEncryption, nor is there any requirement that it cannot be binary. So you are strongly encouraged to pick a very long, randomly generated set of bytes as your password.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance52

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 87.8% 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 ~474 days

Total

5

Last Release

1832d ago

Major Versions

1.1.2 → 2.0.02016-03-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/37f2c58a00861e64cffde4b52034b8c8fd411cc1407a439aef88ed2d03cc185f?d=identicon)[Driftwood](/maintainers/Driftwood)

---

Top Contributors

[![Pixelfck](https://avatars.githubusercontent.com/u/9901252?v=4)](https://github.com/Pixelfck "Pixelfck (43 commits)")[![Jacco-V](https://avatars.githubusercontent.com/u/19333579?v=4)](https://github.com/Jacco-V "Jacco-V (6 commits)")

---

Tags

encryption

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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.4M212](/packages/defuse-php-encryption)[paragonie/ciphersweet

Searchable field-level encryption library for relational databases

4641.2M21](/packages/paragonie-ciphersweet)[ass/xmlsecurity

The XmlSecurity library is written in PHP for working with XML Encryption and Signatures

955.6M30](/packages/ass-xmlsecurity)[pear/crypt_gpg

Provides an object oriented interface to the GNU Privacy Guard (GnuPG). It requires the GnuPG executable to be on the system.

954.4M10](/packages/pear-crypt-gpg)[soved/laravel-gdpr

GDPR compliance with ease

299127.5k2](/packages/soved-laravel-gdpr)

PHPackages © 2026

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