A single, zero-config service with encrypt() and decrypt() methods to safely share or expose confidential data
symfony composer require turbolabit/php-encryptor:dev-main
<?php
use TurboLabIt\Encryptor\Encryptor;
class Property
{
protected string $bookingToken = '12345678';
public function __construct(protected Encryptor $encryptor)
{}
public function getBookingData() : string
{
$arrData = [
"name" => 'aabbcc',
"bookingToken" => $this->bookingToken;
]
return $this->encryptor->encrypt($arrData);
}
public function decodeBookingData(string $text) : array
{
return $this->encryptor->decrypt($text);
}
}
See: Usage
# config/services.yaml
TurboLabIt\Encryptor\Encryptor:
arguments:
$secretKey: '%env(APP_SECRET)%'
See: services.yaml
git clone [email protected]:TurboLabIt/php-encryptor.git
cd php-encryptor
bash script/symfony-bundle-tester.sh