AES Class
Introduction:
This is an implementation of AES (Advanced Encryption Standard) algoritm that can easyly encrypt/decrypt data without external liblary.
Install:
To install this class just copy the file AES.class.php to your php liblary or scripts execution directory.
Configuration:
There are no configuration options. However during the object creation You can choose the length of key using: AES::AES128, AES::AES192, or AES::AES256 values.
Cipher functions:
This functions are used to crypt data:
Examples:
Testing:
require_once('./AES.class.php');
$Cipher = new AES(AES::AES128);
$Cipher->selfTest();
Basic use (128bit):
require_once('./AES.class.php');
$Cipher = new AES();
$key_128bit = '2b7e151628aed2a6abf7158809cf4f3c';

// Encryption
$cryptext = $Cipher->encrypt($Cipher->stringToHex('Alice has a cat'), $key_128bit);
print $cryptext;

// Decryption
$result = $Cipher->encrypt($cryptext, $key_128bit);
print $Cipher->hexToString($result);
Custom key strength:
require_once('./AES.class.php');
$Cipher = new AES(AES::AES256);
$key_256bit = '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4';

// Encryption
$cryptext = $Cipher->encrypt($Cipher->stringToHex('Alice has a cat'), $key_256bit);
print $cryptext;

// Decryption
$result = $Cipher->encrypt($cryptext, $key_256bit);
print $Cipher->hexToString($result);
© 2007 Marcin F. Wisniowski