PHP code example of iserranodev / encrypt-bundle

1. Go to this page and download the library: Download iserranodev/encrypt-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

iserranodev / encrypt-bundle example snippets


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

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;
}

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;
}

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
    }
}
bash
php bin/console iserranodev:encrypt-bundle:generate-key