1. Go to this page and download the library: Download dbublik/cryptography 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/ */
dbublik / cryptography example snippets
use DBublik\Cryptography\Encrypter;
$secretKey = 'your_secret_key';
$encrypter = Encrypter::create($secretKey);
final readonly class ExampleService
{
public function __construct(
private \DBublik\Cryptography\Encrypter $encrypter,
) {}
public function save(#[\SensitiveParameter] string $sensitiveValue): void
{
$encryptedValue = $this->encrypter->encrypt($sensitiveValue);
// Don't forget to save $encryptedValue somewhere
}
}
final readonly class ExampleService
{
public function __construct(
private \DBublik\Cryptography\Encrypter $encrypter,
) {}
public function doSomething(string $encryptedValue): mixed
{
$sensitiveValue = $this->encrypter->decrypt($encryptedValue);
// Be careful! Do not show $sensitiveValue to anyone
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.