Simple PHP Encryption and Decryption
The need for encryption and decryption in general day-to-day Web programming is quite rare. But it can crop up from every now and again. I use a class that handles both encryption and decryption using mcrypt and the Rijndael algorithm (AES) and a 256 bit key size.
An important notes to make about encryption (especially this class) is that the output is binary, so you need to make sure if you’re storing it in a database that you use the correct data type, or if you are storing it in a file then give it a correct file extension (alternatively you can just not give it an extension). This is important as storing as, for instance, a .txt will contaminate the cipher text.