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

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

precision-soft/symfony-doctrine-encrypt
=======================================

doctrine encrypt type

v2.2.4(1mo ago)0471MITPHPPHP &gt;=8.2

Since Sep 17Pushed 1mo agoCompare

[ Source](https://github.com/precision-soft/symfony-doctrine-encrypt)[ Packagist](https://packagist.org/packages/precision-soft/symfony-doctrine-encrypt)[ Docs](https://github.com/precision-soft/symfony-doctrine-encrypt)[ RSS](/packages/precision-soft-symfony-doctrine-encrypt/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (16)Versions (9)Used By (0)

Symfony Doctrine Encrypt Bundle
===============================

[](#symfony-doctrine-encrypt-bundle)

Symfony bundle for transparent AES-256 field-level encryption of Doctrine ORM entity fields via custom Doctrine types.

**You may fork and modify it as you wish. Contributions are welcomed.**

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

[](#requirements)

- PHP 8.2+ with `ext-openssl`
- Doctrine ORM 3.\*
- Doctrine DBAL 4.\*
- Symfony 7.\*

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

[](#installation)

```
composer require precision-soft/symfony-doctrine-encrypt
```

Register the bundle in `config/bundles.php`:

```
return [
    PrecisionSoft\Doctrine\Encrypt\PrecisionSoftDoctrineEncryptBundle::class => ['all' => true],
];
```

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

[](#configuration)

Create `config/packages/precision_soft_doctrine_encrypt.yaml`:

```
precision_soft_doctrine_encrypt:
    # Required. Minimum 32 characters. Keep this secret and stable — changing it renders all encrypted data unreadable.
    salt: '%env(APP_ENCRYPTION_SALT)%'

    # Optional. Restrict which encryptors are active. When empty, all registered encryptors are enabled.
    # encryptors:
    #     - PrecisionSoft\Doctrine\Encrypt\Encryptor\Aes256Encryptor
    #     - PrecisionSoft\Doctrine\Encrypt\Encryptor\Aes256FixedEncryptor

    # Optional. Restrict which Doctrine types are registered. When empty, all types are registered.
    # enabled_types:
    #     - encryptedAes256
    #     - encryptedAes256fixed
```

Add the salt to your `.env`:

```
APP_ENCRYPTION_SALT=your-random-salt-of-at-least-32-characters
```

Encryption types
----------------

[](#encryption-types)

TypeDoctrine type nameUse case`Aes256Type``encryptedAes256`General encryption — different ciphertext each time (non-deterministic)`Aes256FixedType``encryptedAes256fixed`Deterministic encryption — same plaintext always produces the same ciphertext, enabling `WHERE` queriesUsage
-----

[](#usage)

### Entity mapping

[](#entity-mapping)

```
