PHPackages                             iserranodev/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. iserranodev/encrypt-bundle

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

iserranodev/encrypt-bundle
==========================

A Symfony bundle for encrypting entity properties in Database

1.3.1(5mo ago)078MITPHPPHP &gt;=8.1

Since Feb 14Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/ISerranoDev/Encrypt-Bundle)[ Packagist](https://packagist.org/packages/iserranodev/encrypt-bundle)[ RSS](/packages/iserranodev-encrypt-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (10)Versions (6)Used By (0)

Encrypt Bundle
==============

[](#encrypt-bundle)

[![en](https://camo.githubusercontent.com/9687410941adb91c2f673c9d50ef38544f3e9a38a6b9f9367cac918a8d3e2a41/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c616e672d656e2d7265642e737667)](https://github.com/ISerranoDev/Encrypt-Bundle/blob/main/README.en.md)[![es](https://camo.githubusercontent.com/836476cfed52d44b1c1aab20b7c942af38e6f73421e52eba781ee89904ec919a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c616e672d65732d79656c6c6f772e737667)](https://github.com/ISerranoDev/Encrypt-Bundle/blob/main/README.md)

Este bundle proporciona funcionalidad de encriptación para entidades de Doctrine en aplicaciones Symfony.

Instalación
-----------

[](#instalación)

1. Instala el bundle usando Composer:

```
composer require iserranodev/encrypt-bundle
```

2. Habilita el bundle en `config/bundles.php`:

```
return [
    // ...
    ISerranoDev\EncryptBundle\ISerranoDevEncryptBundle::class => ['all' => true],
];
```

Configuración
-------------

[](#configuración)

### Variables de Entorno

[](#variables-de-entorno)

El bundle utiliza las siguientes variables que puedes configurar en tu archivo `.env`:

```
# Valores por defecto proporcionados
ISD_ENCRYPT_HASH_KEY=UsLN^Dc6x9xP7n924NJoffw4$6p*9SNg#r0Qql#^bNusXh4dKU
ISD_ENCRYPT_METHOD=AES-128-CBC
ISD_ENCRYPT_IV=5414358938341622
```

### Configuración del Bundle

[](#configuración-del-bundle)

Puedes personalizar la configuración en `config/packages/i_serrano_dev_encrypt.yaml`:

```
i_serrano_dev_encrypt:
    encryption_key_path: '%kernel.project_dir%/encryption/encryption.key'  # Ruta por defecto
    hash_key: 'TuNuevaClaveHash'    # Opcional: sobreescribe ISD_ENCRYPT_HASH_KEY
    method: 'TuNuevoMetodo'         # Opcional: sobreescribe ISD_ENCRYPT_METHOD
    iv: 'TuNuevoIV'                 # Opcional: sobreescribe ISD_ENCRYPT_IV
```

Uso
---

[](#uso)

1. Genera la clave de encriptación (esto creará el archivo en la ruta configurada):

```
php bin/console iserranodev:encrypt-bundle:generate-key
```

2. Usa el atributo `#[Encrypted]` en las propiedades que desees encriptar:

```
use ISerranoDev\EncryptBundle\Attribute\Encrypted;
use App\EventListener\EncryptListener;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity()]
#[ORM\Table(name: 'users')]
#[ORM\EntityListeners([EncryptListener::class])]
class User
{
    #[ORM\Column(type: 'string', length: 255)]
    #[Encrypted]
    private ?string $sensitiveData = null;
}
```

3. Usa el atributo `#[Hashed]` en las propiedades que desees hashear y poder buscar en base de datos:

```
use ISerranoDev\EncryptBundle\Attribute\Hashed;
use App\EventListener\HashListener;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity()]
#[ORM\Table(name: 'users')]
#[ORM\EntityListeners([HashListener::class])]
class User
{
    #[ORM\Column(type: 'string', length: 255)]
    #[Hashed]
    private ?string $sensitiveData = null;
}
```

4. El bundle automáticamente:
    - Encriptará o aplicará un hash los datos antes de guardarlos en la base de datos
    - Desencriptará los datos cuando los recuperes
    - Manejará las migraciones de Doctrine correctamente

Uso de EncryptService
---------------------

[](#uso-de-encryptservice)

Puedes usar dicho servicio para encriptar o hashear diferentes textos. El atributo Encrypted usa los métodos hashData y unHashData para poder buscar en base de datos, pero si fuese necesario, también existe el método encryptData y decryptData, el cual no es recomendable para el uso de campos que se pretenden buscar.

En caso de usar los métodos de encrypt, consultar la librería , ya que el cifrado de los datos con estos métodos están desarrollados mediante dicha librería.

Ubicación de la Clave de Encriptación
-------------------------------------

[](#ubicación-de-la-clave-de-encriptación)

Por defecto, el archivo de clave se guarda en:

```
tu-proyecto/
├── encryption/
│   └── encryption.key

```

Puedes cambiar esta ubicación en la configuración del bundle.

Seguridad
---------

[](#seguridad)

- No subas el archivo de clave (`encryption.key`) a tu repositorio
- Asegúrate de incluir `encryption/` en tu `.gitignore`
- Mantén una copia segura de tu clave de encriptación
- Considera usar variables de entorno en producción

Soporte para Migraciones
------------------------

[](#soporte-para-migraciones)

El bundle incluye soporte para migraciones de Doctrine. Para usarlo en tus migraciones:

```
use ISerranoDev\EncryptBundle\Interface\EncryptAwareMigrationInterface;

final class Version20240214123456 extends AbstractMigration implements EncryptAwareMigrationInterface
{
    private EncryptService $encryptService;

    public function setEncryptService(EncryptService $encryptService): void
    {
        $this->encryptService = $encryptService;
    }

    public function up(Schema $schema): void
    {
        // Usa $this->encryptService para encriptar/desencriptar datos
    }
}
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance70

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

Total

5

Last Release

174d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/59bd73f3f27830942aa9f6eac12ef58a913054827a215108b807e08fd0449565?d=identicon)[ISerranoDev](/maintainers/ISerranoDev)

---

Top Contributors

[![ISerranoDev](https://avatars.githubusercontent.com/u/147074538?v=4)](https://github.com/ISerranoDev "ISerranoDev (26 commits)")

---

Tags

symfonybundleencryptiondoctrine

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

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

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1022.4k](/packages/rcsofttech-audit-trail-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

813.1k](/packages/ahmed-bhs-doctrine-doctor)[huluti/doctrine-relations-analyser

A Symfony bundle that provides tools for analyzing Doctrine relationships

145.3k](/packages/huluti-doctrine-relations-analyser)

PHPackages © 2026

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