PHP code example of ericledberg / php-encryption

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

    

ericledberg / php-encryption example snippets



// Alter path to where test.php script resides
$autoloader = env";

$objENC = new \clsEncryption\clsEncryption($aOptions);
echo "<h2>objENC() created</h2>";

// Encrypt data
$data = 'Hello, world!';
$encryptedData = $objENC->encrypt($data);

// Decrypt data
$decryptedData = $objENC->decrypt($encryptedData);

// Display results
echo "Original data: $data\n";
echo "Encrypted data: $encryptedData\n";
echo "Decrypted data: $decryptedData\n";



// --------------------------------------------
// encryption
// APP does not have knowledge about about internal operations of clsEncryption, including keys
// --------------------------------------------
$aOptions = array();
$aOptions['ENVKEYFILE'] = __DIR__ . $config['folderSep'] . ".envENCRYPTION";
cho "Original data: $data\n";
echo "Encrypted data: $encryptedData\n";
echo "Decrypted data: $decryptedData\n";