PHPackages                             xorgxx/doctrine-encryptor-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. xorgxx/doctrine-encryptor-bundle

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

xorgxx/doctrine-encryptor-bundle
================================

This bundle provides Encrypt/Decrypt data sensible in a Db system in your application.Its main goal is to make it simple for you to manage encrypt &amp; decrypt sensible data into Db!This bundle is to refresh the old bundle \[DoctrineEncryptBundle\]

0.1.0(2y ago)41211proprietaryPHPPHP &gt;=8.1

Since Mar 22Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (19)Versions (2)Used By (0)

DoctrineEncryptorBundle { Symfony 6/7 }
=======================================

[](#doctrineencryptorbundle--symfony-67-)

This bundle provides Encrypt/Decrypt data sensible in a Db system in your application. Its main goal is to make it simple for you to manage encrypt &amp; decrypt sensible data into Db! This bundle is to refresh the old bundle [DoctrineEncryptBundle](https://github.com/absolute-quantum/DoctrineEncryptBundle)

The aim of this bundle is to establish, in an automatic and transparent manner, a robust encryption and decryption system by externalizing data, in strict compliance with European recommendations and the directives of the General Data Protection Regulation (GDPR).

PSR-12

[![Doctrineencryptor-schema.png](https://camo.githubusercontent.com/438b86d539e51cc8396352d9844635560b6de4eb419e5fe5709098ef050e4b32/68747470733a2f2f692e706f7374696d672e63632f4e473430384e386a2f446f637472696e65656e63727970746f722d736368656d612e706e67)](https://postimg.cc/0rzxP0HT)

[![cryptor.png](https://camo.githubusercontent.com/8ab3f7b68427f66793f4be7b409bfce05a44052418458ffdaab4c798590c5246/68747470733a2f2f692e706f7374696d672e63632f464b51394e7142582f63727970746f722e706e67)](https://postimg.cc/sMwFJnzT)

Installation RELEASE !
----------------------

[](#installation-release-)

Install the bundle for Composer

```
  composer require xorgxx/doctrine-encryptor-bundle:^0.1 or dev-master

```

Doctrine migrations
-------------------

[](#doctrine-migrations)

🚨 You will have to make migration to add NeoxEncryptor in your entities. 🚨

```
  symfony make:migration
  symfony doctrine:migrations:migrate

```

Install, setup, folder, .pem .key
---------------------------------

[](#install-setup-folder-pem-key)

- You may have to create manual folder: config/doctrine-encryptor
- `php bin/console neox:encryptor:install` follow instruction (this command will setup config files : doctrine-encryptor &amp; gaufrette for you).
- `php bin/console neox:encryptor:openssl` follow instruction.

**NOTE:** *You may need to use \[ symfony composer dump-autoload \] to reload autoload*

..... Done 🎈
------------

[](#-done-)

Config file
-----------

[](#config-file)

doctrine\_encryptor.yaml file

```
  doctrine_encryptor:
    # (default)false or true | it will turn off the bundle. by aware that it will render nothing !! field on front will by empty!!
    # this is only for testing purpose in Development mode !!!
    nencryptor_off: false
    encryptor_cipher_algorithm: AES-256-CBC  # AES-256-CBC | !!! Camellia-256-CBC !!!
    encryptor_system: halite # halite | openSSLSym | !!! DEPRECIATED openSSLAsym !!! (das not support advance typing (obejt, array, ...) yet)
    encryptor_storage: 'gaufrette:local' # name of filesystems in you config/gaufrette.yaml
    encryptor_cache: false # use true for ussing cache system. you will have to setup your application before

```

We recommended setting up your cache system [symfony cache](https://symfony.com/doc/current/components/cache.html)

More security getting key form external store
---------------------------------------------

[](#more-security-getting-key-form-external-store)

🚨 We use [KnpGaufrette](https://github.com/KnpLabs/KnpGaufretteBundle) . In this setup, all keys are stored externally and are not accessible from within your website. This means that even if someone gains access to your code, they won't be able to access the keys, providing an additional layer of security for your encryption system. In order, you have to configure at liste one "adapter": config/gaufrette.yaml

```
  knp_gaufrette:
      adapters:
          local_adapter:
              local:
                  directory: '%kernel.project_dir%/config/doctrine-encryptor/'

      filesystems:
          local:
              adapter: local_adapter

```

```
/**
* ===== openSSLSym is match faster !! | ======
* openSSLAsym because is Asymetric we cant put macth data in encrypte SO it's not working well yet!!
* 🚨 Due to instability issues (after ~100 caractes), it is advisable not to use
* the openSSLAsym encryptor for handling advanced data typing (obejt, array, ...).!!
**/

```

- [Cipher Algorithm list](doc/cipherAlgorithm.md)
- [Encryptor list](doc/encryptor.md)
- [Logs &amp; reversing](doc/logger.md)

Usage !
-------

[](#usage-)

In entity, you want to secure field (data) in Entity

```
  use DoctrineEncryptor\DoctrineEncryptorBundle\Attribute\NeoxEncryptor;
  ....

    #[ORM\Column(type: Types::TEXT, nullable: true)]
    #[neoxEncryptor(build: "out", facker : )]
    private ?string $content = null;

    #[ORM\Column(type: Types::TEXT, nullable: true)]
    #[neoxEncryptor(build: "in")]
    private ?string $description = null;

    /** =======   note that by default #[neoxEncryptor]
    * Attribute : build: "in". be default  in / out
    * Attribute : facker: PhoneFacker::class. be default This give possibility to customize the "facker" for ex: type phoneNumber it's not buildin bundle, but hee you can make service.
    **/

  ....
```

Custom facker
-------------

[](#custom-facker)

This is special to manage typing and want to be shown in a database. Most of the attributes are recognized be the bundle string, int, date ...., But in some cas as PhoneNumber, \[...\] bundle will not recognized! So you will need to add service.

```
