PHP code example of maatify / crypto
1. Go to this page and download the library: Download maatify/crypto 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/ */
maatify / crypto example snippets
use Maatify\Crypto\DX\CryptoProvider;
use Maatify\Crypto\Reversible\DTO\ReversibleCryptoMetadataDTO;
$crypto = $container->get(CryptoProvider::class);
$service = $crypto->context("user:email:v1");
$encrypted = $service->encrypt("hello world");
$metadata = new ReversibleCryptoMetadataDTO(
$encrypted['result']->iv,
$encrypted['result']->tag
);
$plain = $service->decrypt(
$encrypted['result']->cipher,
$encrypted['key_id'],
$encrypted['algorithm'],
$metadata
);
$crypto->context("user:email:v1");