Encrypting/decrypting without mcrypt
It is a little-known fact among members of the general PHP community that the mcrypt
extension, the core of most PHP-based encryption considered secure, is anything but secure. One of the biggest issues, from a security perspective, is that the mcrypt
extension requires advanced knowledge of cryptography to successfully operate, which few programmers have. This leads to gross misuse and ultimately problems such as a 1 in 256 chance of data corruption. Not good odds. Furthermore, developer support for libmcrypt
, the core library upon which the mcrypt
extension is based, was abandoned in 2007, which means the code base is out-of-date, bug-ridden, and has no mechanism to apply patches. Accordingly, it is extremely important to understand how to perform strong encryption/decryption without using mcrypt
!
How to do it...
- The solution to the problem posed previously, in case you're wondering, is to use
openssl
. This extension is well maintained, and has...