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

ActiveSymfony-bundle[Security](/categories/security)

cleverage/encryption-bundle
===========================

The EncryptionBundle allows you to store encrypted files and data in Doctrine's entity in a very simple way

v1.5.1(5y ago)09612MITPHPPHP ^7.4

Since Nov 13Pushed 3y agoCompare

[ Source](https://github.com/cleverage/SidusEncryptionBundle)[ Packagist](https://packagist.org/packages/cleverage/encryption-bundle)[ RSS](/packages/cleverage-encryption-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (21)Used By (0)

Sidus/EncryptionBundle
======================

[](#sidusencryptionbundle)

Easy entity and file encryption for Symfony.

We wanted to be able to store encrypted data in our Symfony2 applications and we realized that there were no simple way to do it.

In our solution, a malicious user will have a really hard time to steal data from our server.

- The data will not be compromised by an SQL Injection or by a remote include attack.
- If no end users are connected, no one can decrypt the data, not even the root user.
- Only users from the same organization can share data between each other.

The idea is to store the cipher key inside the database in the user table but encrypted with the user's plaintext password. This way each user from the same organization can share the same cipher key to encrypt and decrypt data but each user can only decrypt it's own encrypted key at login time.

The main weakness of this system is that the cipher key is stored temporarly in PHP's session, however, the only way to overcome this problem would be to use a pretty complex asymmetric encryption system between the client and the server which could only be done properly using a rich client.

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

[](#installation)

```
composer require cleverage/encryption-bundle
```

Usage
-----

[](#usage)

```
use Doctrine\ORM\Mapping as ORM;

class MyEntity {

    /**
     * @ORM\Column(type="encrypt_string")
     */
    private string $myField;

    /**
     * @ORM\Column(type="encrypt_text")
     */
    private string $myFieldText;
}
```

Helpers
-------

[](#helpers)

This bundle comes with an EncryptionManager class which can be used in standalone to encrypt and decrypt data and files. There's also a DecryptFileResponse which allows you to directly stream an encrypted file to the client while deciphering it.

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

[](#installation-1)

You just require the package `sidus/encryption-bundle` either directly in your composer.json or by command line :

```
$ composer require sidus/encryption-bundle ~0.1.0

```

Update your `AppKernel.php`

```
public function registerBundles()
{
    $bundles = array(
        ...
        new Sidus\EncryptionBundle\SidusEncryptionBundle(),
    );

    ...
}

```

Implements the interfaces
-------------------------

[](#implements-the-interfaces)

You should implements the UserEncryptionProviderInterface on your user entity and the CryptableInterface on each entity that will contains encrypted data.

Don't forget to update the model, the encryptedCipherKey must be persisted to the database !

Configuration
-------------

[](#configuration)

If you need to share encrypted data between users you need to generate each encrypted cipher key with the same cipher key which can prove to be tricky, especially if users already have accounts and passwords.

If each user encrypts it's own data however, you can just use the automatic encryption key generation in your config.yml:

```
sidus_encryption:
    encryption_key:
        auto_generate: false
        throw_exceptions: true # Do not throw an exception when an error occurred when decrypting a value
```

This will tell the system to automatically generate a new encryption key if the user doesn't have any.

In case of password recovery, the user won't be able to retrieve any of the encrypted data because he would be the only one able to decrypt the cipher key.

Disable Encryption
------------------

[](#disable-encryption)

The encryption can be temporary disabled on an encrypted type (in a command for example). This can be achieved using the `Sidus\EncryptionBundle\Encryption\Enabler\EncryptionEnablerInterface` service:

```
// ...
$encryptionEnabler->disableEncryption();

// Starting from here, data will not be decrypted
$encryptionManager->decryptString($value); // The value will not be decrypted
$encryptionManager->encryptString($value); // The value will not be encrypted and store as is

$encryptionEnabler->enableEncryption();
// Now the encryption is re-enabled and works normally
```

Apache License
--------------

[](#apache-license)

@todo

Authors
-------

[](#authors)

The bundle was originally created by [Vincent Chalnot](https://github.com/VincentChalnot).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 85.3% 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 ~110 days

Recently: every ~8 days

Total

18

Last Release

1957d ago

Major Versions

v0.2.3 → v1.0.02018-11-12

PHP version history (3 changes)v0.1.0PHP &gt;=5.3.3

v1.0.0PHP &gt;=7.2

v1.1PHP ^7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/4d408c6ae2e5f73eff1f279b35eb21009d7ded0b4c1f97f8ca45dca4a21f3911?d=identicon)[Clever Age](/maintainers/Clever%20Age)

---

Top Contributors

[![johnkrovitch](https://avatars.githubusercontent.com/u/1202965?v=4)](https://github.com/johnkrovitch "johnkrovitch (29 commits)")[![VincentChalnot](https://avatars.githubusercontent.com/u/1535893?v=4)](https://github.com/VincentChalnot "VincentChalnot (4 commits)")[![roincent](https://avatars.githubusercontent.com/u/6852155?v=4)](https://github.com/roincent "roincent (1 commits)")

---

Tags

encryptionmcrypt

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

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