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

ActiveLibrary[Security](/categories/security)

fyre/encryption
===============

An encryption library.

v6.0.1(7mo ago)08712MITPHP

Since Oct 26Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreEncryption)[ Packagist](https://packagist.org/packages/fyre/encryption)[ RSS](/packages/fyre-encryption/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (6)Versions (47)Used By (2)

FyreEncryption
==============

[](#fyreencryption)

**FyreEncryption** is a free, open-source encryption library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Encrypters](#encrypters)
    - [OpenSSL](#openssl)
    - [Sodium](#sodium)

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

[](#installation)

**Using Composer**

```
composer require fyre/encryption

```

In PHP:

```
use Fyre\Encryption\EncryptionManager;
```

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

[](#basic-usage)

- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).
- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).

```
$encryptionManager = new EncryptionManager($container, $config);
```

Default configuration options will be resolved from the "*Encryption*" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).

**Autoloading**

It is recommended to bind the *EncryptionManager* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(EncryptionManager::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$encryptionManager = $container->use(EncryptionManager::class);
```

Methods
-------

[](#methods)

**Build**

Build an [*Encrypter*](#encrypters).

- `$options` is an array containing configuration options.

```
$encrypter = $encryptionManager->build($options);
```

[*Encrypter*](#encrypters) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).

**Clear**

Clear all instances and configs.

```
$encryptionManager->clear();
```

**Get Config**

Get an [*Encrypter*](#encrypters) config.

- `$key` is a string representing the [*Encrypter*](#encrypters) key.

```
$config = $encryptionManager->getConfig($key);
```

Alternatively, if the `$key` argument is omitted an array containing all configurations will be returned.

```
$config = $encryptionManager->getConfig();
```

**Has Config**

Determine whether an [*Encrypter*](#encrypters) config exists.

- `$key` is a string representing the [*Encrypter*](#encrypters) key, and will default to `EncryptionManager::DEFAULT`.

```
$hasConfig = $encryptionManager->hasConfig($key);
```

**Is Loaded**

Determine whether an [*Encrypter*](#encrypters) instance is loaded.

- `$key` is a string representing the [*Encrypter*](#encrypters) key, and will default to `EncryptionManager::DEFAULT`.

```
$isLoaded = $encryptionManager->isLoaded($key);
```

**Set Config**

Set the [*Encrypter*](#encrypters) config.

- `$key` is a string representing the [*Encrypter*](#encrypters) key.
- `$options` is an array containing configuration options.

```
$encryptionManager->setConfig($key, $options);
```

**Unload**

Unload an [*Encrypter*](#encrypters).

- `$key` is a string representing the [*Encrypter*](#encrypters) key, and will default to `EncryptionManager::DEFAULT`.

```
$encryptionManager->unload($key);
```

**Use**

Load a shared [*Encrypter*](#encrypters) instance.

- `$key` is a string representing the [*Encrypter*](#encrypters) key, and will default to `EncryptionManager::DEFAULT`.

```
$encrypter = $encryptionManager->use($key);
```

[*Encrypter*](#encrypters) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).

Encrypters
----------

[](#encrypters)

You can load a specific encrypter by specifying the `className` option of the `$options` variable above.

Custom encrypters can be created by extending `\Fyre\Encryption\Encrypter`, ensuring all below methods are implemented.

**Decrypt**

Decrypt data.

- `$data` is the encrypted data.
- `$key` is a string representing the encryption key.

```
$decrypted = $encrypter->decrypt($data, $key);
```

**Encrypt**

Encrypt data.

- `$data` is the data to encrypt.
- `$key` is a string representing the encryption key.

```
$encrypted = $encrypter->encrypt($data, $key);
```

**Generate Key**

Generate an encryption key.

```
$key = $encrypter->generateKey();
```

### OpenSSL

[](#openssl)

The OpenSSL encrypter can be loaded using default configuration using the "*openssl*" key.

```
$encrypter = $encryptionManager->use('openssl');
```

You can also load the OpenSSL encrypter using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Encryption\Handlers\OpenSSLEncrypter::class`.
    - `cipher` is a string representing the cipher, and will default to "*AES-256-CTR*".
    - `digest` is a string representing the digest, and will default to "*SHA512*".

```
$container->use(Config::class)->set('Encryption.openssl', $options);
```

### Sodium

[](#sodium)

The Sodium encrypter is the default handler.

```
$encrypter = $encryptionManager->use();
```

You can also load the Sodium encrypter using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Encryption\Handlers\SodiumEncrypter::class`.
    - `blockSize` is a number representing the block size, and will default to *16*.
    - `digest` is a string representing the digest, and will default to "*SHA512*".

```
$container->use(Config::class)->set('Encryption.default', $options);
```

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance62

Regular maintenance activity

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Total

46

Last Release

233d ago

Major Versions

v1.1.4 → v2.02023-07-18

v2.0 → v3.02023-07-23

v3.0.10 → v4.02024-10-31

v4.0.3 → v5.02024-11-02

v5.0.10 → v6.02025-10-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/fad81fd5941e3a637c8a5749d05ae3ed9314d5e2fee57f59c3d9ec3b41259c6b?d=identicon)[elusivecodes](/maintainers/elusivecodes)

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (36 commits)")

---

Tags

encryptionlibraryopensslphpsodium

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k18.0M134](/packages/mews-purifier)[paragonie/ecc

PHP Elliptic Curve Cryptography library

24772.0k35](/packages/paragonie-ecc)

PHPackages © 2026

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