PHPackages                             stymiee/php-simple-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. stymiee/php-simple-encryption

ActiveLibrary[Security](/categories/security)

stymiee/php-simple-encryption
=============================

The PHP Simple Encryption library is designed to simplify the process of encrypting and decrypting data while ensuring best practices are followed. By default is uses a secure encryption algorithm and generates a cryptologically strong initialization vector so developers do not need to becomes experts in encryption to securely store sensitive data.

1.0.7(4y ago)449.2k↑129.3%11Apache-2.0PHPPHP &gt;=7.2.0CI failing

Since May 11Pushed 1y ago2 watchersCompare

[ Source](https://github.com/stymiee/php-simple-encryption)[ Packagist](https://packagist.org/packages/stymiee/php-simple-encryption)[ Docs](https://github.com/stymiee/php-simple-encryption)[ RSS](/packages/stymiee-php-simple-encryption/feed)WikiDiscussions master Synced yesterday

READMEChangelog (8)Dependencies (3)Versions (10)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/07036c2937c92cc0d05b8448a577d216c53d2cca1e984a07d55ba943a3554864/68747470733a2f2f706f7365722e707567782e6f72672f7374796d6965652f7068702d73696d706c652d656e6372797074696f6e2f762f737461626c652e737667)](https://packagist.org/packages/stymiee/php-simple-encryption)[![Total Downloads](https://camo.githubusercontent.com/7fff616cc1dc060689f4a8d0b7c290f638c0211bd58e6857eed935b4e63d3623/68747470733a2f2f706f7365722e707567782e6f72672f7374796d6965652f7068702d73696d706c652d656e6372797074696f6e2f646f776e6c6f616473)](https://packagist.org/packages/stymiee/php-simple-encryption)[![Build](https://github.com/stymiee/php-simple-encryption/workflows/Build/badge.svg?branch=master)](https://github.com/stymiee/php-simple-encryption/workflows/Build/badge.svg?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/def50fa0018e2e4313c37c077670fa19c3d159213f8a328e2c8cfbca100b118d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7374796d6965652f7068702d73696d706c652d656e6372797074696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/stymiee/php-simple-encryption/?branch=master)[![Maintainability](https://camo.githubusercontent.com/9324e6b23899eaa89e05464929734c99974863aeaa1963eb373e3e8802871f64/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f61636662336664643732303132613366376364362f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/stymiee/php-simple-encryption/maintainability)[![License](https://camo.githubusercontent.com/84cb9e090479a226dcb526dcc13f318adce0cc9d2713b7bc61421443d29d1002/68747470733a2f2f706f7365722e707567782e6f72672f7374796d6965652f7068702d73696d706c652d656e6372797074696f6e2f6c6963656e7365)](https://packagist.org/packages/stymiee/php-simple-encryption)

PHP Simple Encryption (php-simple-encryption)
=============================================

[](#php-simple-encryption-php-simple-encryption)

A PHP library that makes encryption and decryption of text easy.

Requirements
------------

[](#requirements)

- PHP 7.2+
- Openssl PHP extension

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

[](#installation)

Simply add a dependency on `stymiee/php-simple-encryption` to your project's `composer.json` file if you use [Composer](http://getcomposer.org/) to manage the dependencies of your project.

Here is a minimal example of a `composer.json` file that just defines a dependency on PHP Simple Encryption:

```
{
    "require": {
        "stymiee/php-simple-encryption": "^1"
    }
}

```

Basic Usage
-----------

[](#basic-usage)

To get a more detailed introduction to this library, visit the [PHP Simple Encryption tutorial](https://www.johnconde.net/blog/php-simple-encryption/?utm_source=github&utm_medium=link&utm_campaign=php-encryption)on my blog.

```
require('./vendor/autoload.php');

use Encryption\Encryption;
use Encryption\Exception\EncryptionException;

$text = 'The quick brown fox jumps over the lazy dog';
$key  = 'secretkey';
try {
    $encryption = Encryption::getEncryptionObject();
    $iv = $encryption->generateIv();
    $encryptedText = $encryption->encrypt($text, $key, $iv);
    $decryptedText = $encryption->decrypt($encryptedText, $key, $iv);

    printf('Cipher   : %s%s', $encryption->getName(), PHP_EOL);
    printf('Encrypted: %s%s', $encryptedText, PHP_EOL);
    printf('Decrypted: %s%s', $decryptedText, PHP_EOL);
    printf('Version  : %s%s', Encryption::VERSION, PHP_EOL);
}
catch (EncryptionException $e) {
    echo $e;
}
```

Outputs

```
Cipher   : AES-256-CBC
Encrypted: lierDqV4Qo3Cm87YU01K+YnQsDGrFsYypjHJVZaagqfLFg7xb2T7b9qfqb4NcoIGcTzqvQbOx72AVgbuRFxqgg==
Decrypted: The quick brown fox jumps over the lazy dog
Version  : 1

```

An exception may be thrown if:

- An invalid/unsupported cipher is attempted to be used (`Encryption\Exception\InvalidCipherException`)
- A cipher available in openssl but yet implemented is attempted to be used (`Encryption\Exception\CipherNotImplementedException`)
- `generateIv()` is unable to generate a initialization vector (`Encryption\Exception\GenerateIvException`).
- `Encryption::encrypt()` is unable to encrypt the data (`Encryption\Exception\EncryptException`).
- `Encryption::decrypt()` is unable to decrypt the data (`Encryption\Exception\DecryptException`).

Supported Ciphers
-----------------

[](#supported-ciphers)

The PHP Simple Encryption library currently defaults to `AES-256-CBC`. This may change in future versions and will result in a major version bump when this occurs. You can check the version of your library by calling `Encryption::VERSION`. This library is currently on version "1".

To determine what cipher you are using you can call the `getName()` method on your encryption object.

```
$encryption = Encryption::getEncryptionObject();
$cipherName = $encryption->getName(); // AES-256-CBC
```

To get a list of ciphers supported by your system *and* this library you can call `Encryption::listAvailableCiphers()`to receive an array of available ciphers. This list is an intersection of available ciphers from your system's installed version of Openssl and ciphers supported by this library.

**Total ciphers supported:** 139
**Default cipher:** AES-256-CBC (version 1)

AESAria/BlowfishCamellia/Cast5/SM4DES/Idea/RC2/RC4/Seedaes-128-cbcaria-128-cbccamellia-128-cbcdes-cbcaes-128-cbc-hmac-sha1aria-128-ccmcamellia-128-cfbdes-cfbaes-128-cbc-hmac-sha256aria-128-cfbcamellia-128-cfbdes-cfb1aes-128-ccmaria-128-cfb1camellia-128-cfbdes-cfb8aes-128-cfbaria-128-cfb8camellia-128-ctrdes-ecbaes-128-cfb1aria-128-ctrcamellia-128-ecbdes-edeaes-128-cfb8aria-128-ecbcamellia-128-ofbdes-ede3aes-128-ctraria-128-gcmcamellia-192-cbcdes-ede-cbcaes-128-ecbaria-128-ofbcamellia-192-cfbdes-ede-cfbaes-128-gcmaria-192-cbccamellia-192-cfbdes-ede-ofbaes-128-ofbaria-192-ccmcamellia-192-cfbdes-ede3-cbcaes-128-xtsaria-192-cfbcamellia-192-ctrdes-ede3-cfbaes-192-cbcaria-192-cfb1camellia-192-ecbdes-ede3-cfb1aes-192-ccmaria-192-cfb8camellia-192-ofbdes-ede3-cfb8aes-192-cfbaria-192-ctrcamellia-256-cbcdes-ede3-ofbaes-192-cfb1aria-192-ecbcamellia-256-cfbdes-ofbaes-192-cfb8aria-192-gcmcamellia-256-cfbdesx-cbcaes-192-ctraria-192-ofbcamellia-256-cfbid-aes128-ccmaes-192-ecbaria-256-cbccamellia-256-ctrid-aes128-gcmaes-192-gcmaria-256-ccmcamellia-256-ecbid-aes192-ccmaes-192-ofbaria-256-cfbcamellia-256-ofbid-aes192-gcmaes-256-cbcaria-256-cfb1cast5-cbcid-aes256-ccmaes-256-cbc-hmac-sha1aria-256-cfb8cast5-cfbid-aes256-gcmaes-256-cbc-hmac-sha256aria-256-ctrcast5-ecbidea-cbcaes-256-ccmaria-256-ecbcast5-ofbidea-cfbaes-256-cfbaria-256-gcmchacha20idea-ecbaes-256-cfb1aria-256-ofbchacha20-poly1305idea-ofbaes-256-cfb8bf-cbcseed-cbcrc2-40-cbcaes-256-ctrbf-cfbseed-cfbrc2-64-cbcaes-256-ecbbf-ecbseed-ecbrc2-cbcaes-256-gcmbf-ofbseed-ofbrc2-cfbaes-256-ofbsm4-cbcrc2-ecbaes-256-xtssm4-cfbrc2-ofbsm4-ctrrc4sm4-ecbrc4-40rc4-hmac-md5Notes
-----

[](#notes)

If the text to be encrypted contains trailing null characters they will be removed when decrypting those values.

Some ciphers may not work on your version of PHP. The newer your version of PHP (and its openssl extension), the more ciphers that will be available to you.

Support
-------

[](#support)

If you require assistance using this library start by viewing the [HELP.md](HELP.md) file included in this package. It includes common problems and their solutions.

If you need additional assistance, I can be found at Stack Overflow. Be sure when you [ask a question](http://stackoverflow.com/questions/ask?tags=php,encryption,openssl) pertaining to the usage of this library be sure to tag your question with the **PHP** and **encryption** tags. Make sure you follow their [guide for asking a good question](http://stackoverflow.com/help/how-to-ask) as poorly asked questions will be closed, and I will not be able to assist you.

A good question will include all the following:

- A description of the problem (what are you trying to do? what results are you expecting? what results are you actually getting?)
- The code you are using (only post the relevant code)
- Your unencrypted text
- The key you are using
- The IV you are using
- The output of your method call(s)
- Any error message(s) you are getting

**Do not use Stack Overflow to report bugs.** Bugs may be reported [here](https://github.com/stymiee/php-simple-encryption/issues/new).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.1% 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 ~233 days

Recently: every ~416 days

Total

9

Last Release

380d ago

Major Versions

1.0.7 → 2.0.0.x-dev2025-06-18

PHP version history (2 changes)1.0.0PHP &gt;=7.2.0

2.0.0.x-devPHP &gt;=8.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/557176f68c4c5c46271b70775fb6016a48d2ba51074cd2c72155c93b252a762c?d=identicon)[stymiee](/maintainers/stymiee)

---

Top Contributors

[![stymiee](https://avatars.githubusercontent.com/u/72497?v=4)](https://github.com/stymiee "stymiee (105 commits)")[![nclavaud](https://avatars.githubusercontent.com/u/1181770?v=4)](https://github.com/nclavaud "nclavaud (1 commits)")[![Tinywan](https://avatars.githubusercontent.com/u/14959876?v=4)](https://github.com/Tinywan "Tinywan (1 commits)")

---

Tags

encryptionopensslphpphp7phpencryptionopenssl

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/stymiee-php-simple-encryption/health.svg)

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

###  Alternatives

[acmephp/core

Raw implementation of the ACME protocol in PHP

411.0M8](/packages/acmephp-core)[poly-crypto/poly-crypto

High-level cryptographic functions that are interoperable between NodeJS and PHP 7.1+

128.1k1](/packages/poly-crypto-poly-crypto)[ukrbublik/openssl_x509_crl

Missing OpenSSL function on PHP to create CRL (certificate revocation list) for CA

182.1k](/packages/ukrbublik-openssl-x509-crl)

PHPackages © 2026

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