1. Go to this page and download the library: Download specshaper/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/ */
...
use SpecShaper\EncryptBundle\Annotations\Encrypted;
/**
* A PPS number is always 7 numbers followed by either one or two letters.
*
* @ORM\Column(type="string")
*/
#[Encrypted]
protected string $taxNumber;
/**
* True if the user is self employed.
*
* @ORM\Column(type="string", nullable=true)
*/
#[Encrypted]
protected ?bool $isSelfEmployed;
/**
* Date of birth
*
* @Encrypted
* Note that the above Encrypted property is a legacy annotation, and while
* it still is supported, it will be deprecated in favour of Attributes.
*
* @ORM\Column(type="string", nullable=true)
*/
protected ?String $dob;
/**
* Get isSelfEmployed
*
* @return boolean
*/
public function isSelfEmployed(): bool
{
return $this->isSelfEmployed;
}
/**
* Get isSelfEmployed
*
* @return boolean
*/
public function isSelfEmployed(): bool
{
return ($this->isSelfEmployed == 1 ? true: false);
}
use SpecShaper\EncryptBundle\Encryptors\EncryptorInterface;
...
/**
* @var SpecShaper\EncryptBundle\Encryptors\EncryptorInterface;
*/
private $encryptor;
...
// Inject the Encryptor from the service container at class construction
public function __construct(EncryptorInterface $encryptor)
{
$this->encryptor = $encryptor;
}
// Inject the Encryptor in controller actions.
public function editAction(EncryptorInterface $encryptor)
{
...
// An example encrypted value, you would get this from your database query.
$encryptedValue = "3DDOXwqZAEEDPJDK8/LI4wDsftqaNCN2kkyt8+QWr8E=<ENC>";
$decrypted = $encryptor->decrypt($encryptedValue);
...
}
...
use SpecShaper\EncryptBundle\Event\EncryptEvent;
use SpecShaper\EncryptBundle\Event\EncryptEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
...
public function indexAction(EventDispatcherInterface $dispatcher)
{
...
// An example encrypted value, you would get this from your database query.
$event = new EncryptEvent("3DDOXwqZAEEDPJDK8/LI4wDsftqaNCN2kkyt8+QWr8E=<ENC>");
$dispatcher->dispatch(EncryptEvents::DECRYPT, $event);
$decrypted = $event->getValue();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.