PHPackages                             x69420/doctrine-encrypt-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. [Database &amp; ORM](/categories/database)
4. /
5. x69420/doctrine-encrypt-bundle

ActiveLibrary[Database &amp; ORM](/categories/database)

x69420/doctrine-encrypt-bundle
==============================

Symfony 5 bundle which allows to encrypt data in database with some encrypt algorithm, this fork make use of open ssl

v5.0.0(4y ago)07MITPHPPHP &gt;=7.0

Since Nov 14Pushed 4y agoCompare

[ Source](https://github.com/x69420/DoctrineEncryptBundle)[ Packagist](https://packagist.org/packages/x69420/doctrine-encrypt-bundle)[ RSS](/packages/x69420-doctrine-encrypt-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (33)Used By (0)

\#DoctrineEncryptBundle version 3.0

Bundle allows to create doctrine entities with fields that will be protected with help of some encryption algorithm in database and it will be clearly for developer, because bundle is uses doctrine life cycle events

This is an fork from the original bundle created by vmelnik-ukrain (Many thanks to him) which can be found here: [vmelnik-ukraine/DoctrineEncryptBundle](https://github.com/vmelnik-ukraine/DoctrineEncryptBundle)this is again a fork from the bundle [nepda/doctrine-encrypt](https://github.com/nepda/doctrine-encrypt) from Marcel van Nuil.

goal of this fork
-----------------

[](#goal-of-this-fork)

My main goal is to improve the Encryptor : multiple existed but they where base on mcrypt and had flaws. I replaced them with an openssl alternative, found partly from this fork (again!) : If the author accept to merge my change, I will probably close this fork.

I also borrowed the "SensitiveValue" and "Mask" class from the great [payum](https://github.com/Payum/Payum) library in order to prevent the secret key to be printed (for more information, see [payum doc](https://github.com/Payum/Payum/blob/master/src/Payum/Core/Resources/docs/working-with-sensitive-information.md)).

I added a twig extension in case of the need to decode the data only on display. (need additional work to be fully satisfying, like optionally do ont decode in the entity)

The encryptor also throw verbose errors and handle a simple integrity check (the length of the data is stored with the data in a json string, and is verified on the decrypt side).

scope of this fork
------------------

[](#scope-of-this-fork)

The rest of this file anf of the doc will probably remain the forked content. Exept for the namespaces and the authors list that I changed (the search &amp; replace way).

\###What does it do exactly

It gives you the opportunity to add the @Encrypt annotation above each string property

```
    /**
     * @var string
     * @ORM\Column(name="host", type="string", length=255)
     * @Encrypted
     */
    private $host;
    /** @var string store the decryptedVersion of $host */
    private $hostDecrypted;

        /**
         * Set host
         *
         * You MUST assign null to the decryped var
         *
         *
         * @param string $host
         *
         * @return ItopUser
         */
        public function setHost($host)
        {
            $this->host             = $host;
            $this->hostDecrypted    = null;//mandatory if you want your host to be encoded again!
            return $this;
        }

        /**
         * Get host
         *
         * You MUST return the decryped var if it is set
         *
         * @return string
         */
        public function getHost()
        {
            if (!empty($this->hostDecrypted)) {
                return $this->hostDecrypted;
            }
            return $this->host;
        }

        /**
         * INTERNAL
         * Set hostDecrypted
         *
         * @param string $host
         *
         * @return ItopUser
         */
        public function setHostDecrypted($hostDecrypted)
        {
            $this->hostDecrypted = $hostDecrypted;

            return $this;
        }

        /**
         * INTERNAL
         * Get hostDecrypted
         *
         * @return string
         */
        public function getHostDecrypted()
        {
            return $this->hostDecrypted;
        }
```

The bundle uses doctrine his life cycle events to encrypt the data when inserted into the database and decrypt the data when loaded into your entity manager. It is only able to encrypt string values at the moment, numbers and other fields will be added later on in development. You NEED to add the \*Decrypt field, it MUST not be persisted, the gettter/setter MUST exists and have standard names, the getter/setter of the encrypted propterties must follow the pattern above

this verstion 3.0 drop support from many functionnalities of the 2.0 :
----------------------------------------------------------------------

[](#this-verstion-30-drop-support-from-many-functionnalities-of-the-20-)

many unused features was removed for the sake of performance and readability :

- EmbeddedAnnotation are no more supported (I don't ever know what it is so... if you'r curious, google for `Doctrine\ORM\Mapping\Embedded`)
- the annotation only mode is no more tested, use it knowing the risk ;)

an almost total rework of the event listener has been done, it now use a cache for most of the time consuming operations and listen to many less events. It do no more need an update on each flush.

\###Advantages and disadvantaged of an encrypted database

\####Advantages

- Information is stored safely
- Not worrying about saving backups at other locations
- Unreadable for employees managing the database

\####Disadvantages

- Can't use ORDER BY on encrypted data
- In SELECT WHERE statements the where values also have to be encrypted
- When you lose your key you lose your data (Make a backup of the key on a safe location)

\###Documentation

This bundle is responsible for encryption/decryption of the data in your database. All encryption/decryption work on the PHP's server side.

The following documents are available:

- [Installation](https://github.com/combodo/DoctrineEncryptBundle/blob/master/Resources/doc/installation.md)
- [Configuration](https://github.com/combodo/DoctrineEncryptBundle/blob/master/Resources/doc/configuration.md)
- [Usage](https://github.com/combodo/DoctrineEncryptBundle/blob/master/Resources/doc/usage.md)
- [Console commands](https://github.com/combodo/DoctrineEncryptBundle/blob/master/Resources/doc/commands.md)
- [Custom encryption class](https://github.com/combodo/DoctrineEncryptBundle/blob/master/Resources/doc/custom_encryptor.md)

\###License

This bundle is under the MIT license. See the complete license in the bundle

\###Versions

I'm using Semantic Versioning like described [here](http://semver.org)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~436 days

Total

32

Last Release

1597d ago

Major Versions

1.0.0 → 2.0.02012-11-17

v2.6.5.3 → 3.02017-03-17

3.0.4 → v5.0.02021-12-24

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

2.4.1PHP &gt;=5.4

v5.0.0PHP &gt;=7.0

### Community

Maintainers

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

---

Top Contributors

[![dev-marcel](https://avatars.githubusercontent.com/u/11071510?v=4)](https://github.com/dev-marcel "dev-marcel (33 commits)")[![vmelnik-ukraine](https://avatars.githubusercontent.com/u/1994051?v=4)](https://github.com/vmelnik-ukraine "vmelnik-ukraine (23 commits)")[![michaelfeinbier](https://avatars.githubusercontent.com/u/503543?v=4)](https://github.com/michaelfeinbier "michaelfeinbier (6 commits)")[![ambta](https://avatars.githubusercontent.com/u/10357868?v=4)](https://github.com/ambta "ambta (4 commits)")[![mkraemer](https://avatars.githubusercontent.com/u/1070200?v=4)](https://github.com/mkraemer "mkraemer (2 commits)")[![maks-rafalko](https://avatars.githubusercontent.com/u/3725595?v=4)](https://github.com/maks-rafalko "maks-rafalko (2 commits)")[![jr-k](https://avatars.githubusercontent.com/u/3283866?v=4)](https://github.com/jr-k "jr-k (1 commits)")[![benr77](https://avatars.githubusercontent.com/u/2156742?v=4)](https://github.com/benr77 "benr77 (1 commits)")[![odain-cbd](https://avatars.githubusercontent.com/u/56586767?v=4)](https://github.com/odain-cbd "odain-cbd (1 commits)")[![PH-Lars](https://avatars.githubusercontent.com/u/10357876?v=4)](https://github.com/PH-Lars "PH-Lars (1 commits)")[![Valegar](https://avatars.githubusercontent.com/u/658117?v=4)](https://github.com/Valegar "Valegar (1 commits)")[![BboyKeen](https://avatars.githubusercontent.com/u/1192309?v=4)](https://github.com/BboyKeen "BboyKeen (1 commits)")[![wassafr](https://avatars.githubusercontent.com/u/10235180?v=4)](https://github.com/wassafr "wassafr (1 commits)")[![wcoppens](https://avatars.githubusercontent.com/u/181460?v=4)](https://github.com/wcoppens "wcoppens (1 commits)")[![emotigroup](https://avatars.githubusercontent.com/u/96598368?v=4)](https://github.com/emotigroup "emotigroup (1 commits)")[![westinpigott](https://avatars.githubusercontent.com/u/1909859?v=4)](https://github.com/westinpigott "westinpigott (1 commits)")[![jongotlin](https://avatars.githubusercontent.com/u/165154?v=4)](https://github.com/jongotlin "jongotlin (1 commits)")

---

Tags

symfonybundledoctrineencryptdecryptopensslaes256

### Embed Badge

![Health badge](/badges/x69420-doctrine-encrypt-bundle/health.svg)

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

###  Alternatives

[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M155](/packages/sonata-project-doctrine-orm-admin-bundle)[fresh/doctrine-enum-bundle

Provides support of ENUM type for Doctrine2 in Symfony applications.

4636.8M12](/packages/fresh-doctrine-enum-bundle)[michaeldegroot/doctrine-encrypt-bundle

Encrypted symfony entity's by verified and standardized libraries

1521.0M1](/packages/michaeldegroot-doctrine-encrypt-bundle)[doctrineencryptbundle/doctrine-encrypt-bundle

Encrypted symfony entity's by verified and standardized libraries

29415.1k](/packages/doctrineencryptbundle-doctrine-encrypt-bundle)[ambta/doctrine-encrypt-bundle

Symfony 2 bundle which allows to encrypt data in database with some encrypt algorithm

77275.7k](/packages/ambta-doctrine-encrypt-bundle)

PHPackages © 2026

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