PHPackages                             phlib/encrypt - 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. phlib/encrypt

ActiveLibrary[Security](/categories/security)

phlib/encrypt
=============

Generic class for performing encryption

3.0.1(2mo ago)67.0k↓50%11LGPL-3.0PHPPHP ^7.4 || ^8.0CI failing

Since Feb 12Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/phlib/encrypt)[ Packagist](https://packagist.org/packages/phlib/encrypt)[ RSS](/packages/phlib-encrypt/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (7)Dependencies (7)Versions (8)Used By (1)

phlib/encrypt
=============

[](#phlibencrypt)

[![Code Checks](https://camo.githubusercontent.com/49142238055b76cc5d94b2efbee8177980abf27618194277730bc8832a68c81d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70686c69622f656e63727970742f636f64652d636865636b732e796d6c3f6c6f676f3d676974687562)](https://github.com/phlib/encrypt/actions/workflows/code-checks.yml)[![Codecov](https://camo.githubusercontent.com/b6b8531618f09290cd7f7a0a1b93e4959748c5c7b40ce7015b27107eafff23ca/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f70686c69622f656e63727970742e7376673f6c6f676f3d636f6465636f76)](https://codecov.io/gh/phlib/encrypt)[![Latest Stable Version](https://camo.githubusercontent.com/3022902497b7bcb2e0e48b463d9ab945aa2c6ffba1603440b80e0f7501bf0f75/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70686c69622f656e63727970742e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/phlib/encrypt)[![Total Downloads](https://camo.githubusercontent.com/a6a97a8e8a32094666567eb2fd8e213486c426a6dd818a197bc8dd435e602230/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70686c69622f656e63727970742e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/phlib/encrypt)[![Licence](https://camo.githubusercontent.com/2a7328519c264e883d8042512d4a39a7b594489d4eb49a3ee190c7d3cb39c1ce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70686c69622f656e63727970742e737667)](https://camo.githubusercontent.com/2a7328519c264e883d8042512d4a39a7b594489d4eb49a3ee190c7d3cb39c1ce/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70686c69622f656e63727970742e737667)

PHP encryption/decryption tool

Install
-------

[](#install)

Via Composer

```
$ composer require phlib/encrypt
```

Usage
-----

[](#usage)

Creation of an encryptor

```
$encryptor = new \Phlib\Encrypt\Encryptor\OpenSsl($encryptionPassword);
```

The encryption password should be a random string of data, preferably at least 32 bytes long, and should be stored on the server. For example, this could be a configuration value or constant (perhaps base64 encoded depending on how the value needs to be stored).

The same encryption password must be used to decrypt as was used to encrypt.

Example of creating an encryption password

```
$encryptionPassword = \openssl_random_pseudo_bytes(32);
```

Encrypt/decrypt some data

```
$encryptor = new \Phlib\Encrypt\Encryptor\OpenSsl($encryptionPassword);
$myData    = 'some sensitive data which needs encrypting';

$encrypted = $encryptor->encrypt($myData);

// $encryptor could be a completely different instance here,
// so long as it is initialised with the same encryption password
$decrypted = $encryptor->decrypt(encrypted);
```

License
-------

[](#license)

This package is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see .

###  Health Score

54

—

FairBetter than 96% of packages

Maintenance83

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 92.7% 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 ~617 days

Recently: every ~916 days

Total

7

Last Release

89d ago

Major Versions

1.0.3 → 2.0.02016-04-06

2.0.0 → 3.0.02021-09-18

PHP version history (3 changes)1.0.0PHP &gt;=5.5.0

1.0.1PHP &gt;=5.4.0

3.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/135b7ddf9ec91c412e1b18174f81d1ad2bef66e732624195c156717c96b13731?d=identicon)[letssurf](/maintainers/letssurf)

![](https://www.gravatar.com/avatar/10c53cdcfb3a6d299820aecb993521cc1a972baa09fd8f31d2468908cded7e1d?d=identicon)[chrisminett](/maintainers/chrisminett)

---

Top Contributors

[![chrisminett](https://avatars.githubusercontent.com/u/1084019?v=4)](https://github.com/chrisminett "chrisminett (38 commits)")[![jdempster](https://avatars.githubusercontent.com/u/10297?v=4)](https://github.com/jdempster "jdempster (2 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (1 commits)")

###  Code Quality

TestsPHPUnit

Code StyleECS

### Embed Badge

![Health badge](/badges/phlib-encrypt/health.svg)

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

###  Alternatives

[phpseclib/phpseclib

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

5.6k465.6M1.5k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k175.2M254](/packages/defuse-php-encryption)[ass/xmlsecurity

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

955.7M35](/packages/ass-xmlsecurity)[oat-sa/tao-core

TAO core extension

66143.7k122](/packages/oat-sa-tao-core)[spomky-labs/php-aes-gcm

AES GCM (Galois Counter Mode) PHP implementation.

715.0M20](/packages/spomky-labs-php-aes-gcm)[sarciszewski/php-future

Polyfill new (5.6+) features into old (5.4+) versions of PHP

421.5M7](/packages/sarciszewski-php-future)

PHPackages © 2026

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