AES encryption

This is a pure PHP implementation of the AES cipher, used by the U.S. government for its classified documents. AES is a beautiful cipher: secure (all known attacks are computationally infeasible), and fast in both hardware and software.

require 'aes.php';
require 'ctr.php';

$key = 'V<||5DK7KdRYyBLEtY^w~0yk1"#NCZ|N'; // (example 256-bit AES key)
$cipher = new CTR(new AES($key));

$text = 'Secret message';
$code = $cipher->encrypt($text);
$text = $cipher->decrypt($code);

echo "ciphertext: ", base64_encode($code), "<br>";
echo "plaintext: $text";
Fork me on GitHub