PHP code example of nawawi / base64-encryption
1. Go to this page and download the library: Download nawawi/base64-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/ */
nawawi / base64-encryption example snippets
if ( file_exists(__DIR__.'/vendor/autoload.php') ) {
cryption = new Base64Encryption();
$encrypted = $encryption->encrypt('test123');
$decrypted = $encryption->decrypt($encrypted);
echo "\$encrypted = $encrypted\n";
echo "\$decrypted = $decrypted\n";
// Set key on initiation
$encryption = new Base64Encryption('encryption_key');
$encrypted = $encryption->encrypt('test123');
$decrypted = $encryption->decrypt($encrypted);
echo "\$encrypted = $encrypted\n";
echo "\$decrypted = $decrypted\n";
// Set key with set_key method
$encryption = new Base64Encryption();
$encryption->set_key('encryption_key');
$encrypted = $encryption->encrypt('test123');
$decrypted = $encryption->decrypt($encrypted);
echo "\$encrypted = $encrypted\n";
echo "\$decrypted = $decrypted\n";
// Set key on call
$encryption = new Base64Encryption();
$encrypted = $encryption->encrypt('test123', 'encryption_key');
$decrypted = $encryption->decrypt($encrypted, 'encryption_key');
echo "\$encrypted = $encrypted\n";
echo "\$decrypted = $decrypted\n";
// Constant
define('BASE64_ENCRYPTION_KEY', 'encryption_key');