PHP code example of snicco / encryption-bundle

1. Go to this page and download the library: Download snicco/encryption-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/ */

    

snicco / encryption-bundle example snippets



// /path/to/configuration/bundles.php

use Snicco\Bundle\Encryption\EncryptionBundle;

return [
    
    'bundles' => [
        Snicco\Component\Kernel\ValueObject\Environment::ALL => [
           EncryptionBundle::class
        ]   
    ]   
];


use Snicco\Bundle\Encryption\DefuseEncryptor;
use Snicco\Component\Kernel\Kernel;

/**
* @var Kernel $kernel
*/
$kernel->boot();

$defuse = $kernel->container()->make(DefuseEncryptor::class);

$plaintext = 'snicco.io';

$ciphertext = $defuse->encrypt($plaintext);

var_dump($plaintext === $ciphertext); // false 

$plain2 = $defuse->decrypt($ciphertext);

var_dump($plaintext === $plain2); // true