PHP Implementation of AES encryption in CTR mode (128-bit AES, 192-bit AES, or 256-bit AES)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
LICENSE Moved the license up one level. Jul 21, 2012
README Expanded the README a little. Jul 21, 2012
aes.php initial commit Jul 21, 2012
ctr.php initial commit Jul 21, 2012
index.php initial commit Jul 21, 2012


See the file "index.php" for a working example.


AES (Advanced Encryption Standard) is a cipher adopted by the U.S. government
for its classified documents. It's secure (all known attacks are computationally
infeasible), and fast in both hardware and software.

CTR (Counter) mode is a cryptographic mode that converts a block cipher like AES
into a stream cipher that can be used on any stream of data with arbitrary length.
CTR mode has a particularly elegant implementation, and has been widely adopted.


Before you can encrypt/decrypt messages, you'll need an encryption key.
AES supports encryption keys with three lengths, corresponding to increasing
levels of security.

NSA rating:   key length:            example key:
SECRET        128 bits (16 bytes*)   aN-zx:+_z)UP[`vz
TOP SECRET    192 bits (24 bytes)    Thl\TFvON6J"sb\(VGhw@gTr
TOP SECRET    256 bits (32 bytes)    V<||5DK7KdRYyBLEtY^w~0yk1"#NCZ|N

* In general: 1 byte = 1 ASCII character.

The Gibson Research Corporation provides an online tool that generates
cryptographically-strong (maximum entropy) keys:


AES encryption:

Counter (CTR) mode: