-
Notifications
You must be signed in to change notification settings - Fork 0
berry.encryption.AES128Encryption
Nikos Siatras edited this page Oct 2, 2022
·
6 revisions
The AES128Encryption class provides methods to encrypt and decrypt Stings using the famous AES 128bit encyption algorithm.
static function encrypt(string $key, string $data): string
Encrypts a string using AES Cipher (CBC) with an 16bytes key
static function decrypt(string $key, string $data): string
Decrypts string data using AES Cipher (CBC) with 16bytes key
require_once(__DIR__ . "/berry/encryption.php"); // Include berry encryption package
$encryptionKey = "%u#bmQjfhTws&(y%"; // 16-characters encryption key
$stringToEncrypt = "Hello World!";
print "Original String: " . $stringToEncrypt."<br>";
$encryptedString = AES128Encryption::encrypt($encryptionKey,$stringToEncrypt);
print "Encrypted String: " . $encryptedString."<br>";
$descryptedString = AES128Encryption::decrypt($encryptionKey, $encryptedString);
print "Decrypted String: " . $descryptedString."<br>";