PHP code example of rodrigonull / doctrine-encrypt
1. Go to this page and download the library: Download rodrigonull/doctrine-encrypt 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/ */
rodrigonull / doctrine-encrypt example snippets
//You should pick your own hexadecimal secret
$secret = pack("H*", "dda8e5b978e05346f08b312a8c2eac03670bb5661097f8bc13212c31be66384c");
$subscriber = new DoctrineEncryptSubscriber(
new \Doctrine\Common\Annotations\AnnotationReader,
new \DoctrineEncrypt\Encryptors\AES256Encryptor($secret)
);
$eventManager = $em->getEventManager();
$eventManager->addEventSubscriber($subscriber);
namespace Your\Namespace;
use Doctrine\ORM\Mapping as ORM;
use DoctrineEncrypt\Configuration\Encrypted;
/**
* @ORM\Entity
*/
class Entity
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
* @var int
*/
protected $id;
/**
* @ORM\Column(type="text")
* @Encrypted
* @var string
*/
protected $secret_data;
}