PHP code example of blackplatinum / encryption

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

    

blackplatinum / encryption example snippets


use BlackPlatinum\Encryption\Crypto\Symmetric\Crypto;
use BlackPlatinum\Encryption\KeyManager\KeyManager;

$cipher = (new Crypto('CAST5-CBC'))->setKey(KeyManager::getKey())->encrypt(
    [
        'Name' => 'John',
        'LastName' => 'LastName',
        'Age' => 22,
        'IsStudent' => true,
        'Courses' => ['Math', 'Economy', 'Chemistry']
    ]
);
print $cipher;

$plainText = (new Crypto('BF-CBC'))->setKey(KeyManager::getKey())->decrypt('eyJpdiI6Ik05RE9...');
print_r($plainText);


use BlackPlatinum\Encryption\Crypto\Asymmetric\Crypto;
$crypto = new Crypto();

$cipher = $crypto->publicKeyEncrypt(
    [
        'Name' => 'John',
        'LastName' => 'LastName',
        'Age' => 22,
        'IsStudent' => true,
        'Courses' => ['Math', 'Economy', 'Chemistry']
    ], KeyManager::getRSAPublicKey()
);
print $cipher . "\n";

print_r($crypto->privateKeyDecrypt($cipher, KeyManager::getRSAPrivateKey()));