PHP code example of davidecaruso / crypt
1. Go to this page and download the library: Download davidecaruso/crypt 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/ */
davidecaruso / crypt example snippets
$passphrase = '1765f3de9cb961bfed77a8ec222a3a4948bc269730fb8cd10ef3645b371f589c';
$vector = 'f3bb46ceb0e30b88';
$crypt = new Crypt(new Idempotent($passphrase, $vector));
$encrypted = $crypt->encrypt('foobar');
$decrypted = $crypt->decrypt($encrypted);
echo "{$encrypted}\n";
echo "{$decrypted}\n";
// 472c66cde1310e7990ae9afaba8bf44a
// foobar
$passphrase = '1765f3de9cb961bfed77a8ec222a3a4948bc269730fb8cd10ef3645b371f589c';
$crypt = new Crypt(new NonIdempotent($passphrase));
$encrypted = $crypt->encrypt('foobar');
$decrypted = $crypt->decrypt($encrypted);
echo "{$encrypted}\n";
echo "{$decrypted}\n";
// 29162d5b677312fa8b0039dfd72150e01510a1a1cd628671ea12da178672dcd7
// foobar