Search code examples
phpsecurityencryptioncryptographyencryption-symmetric

Simplest two-way encryption using PHP


What is the simplest way of doing two way encryption in common PHP installs?

I need to be able to encrypt data with a string key, and use the same key to decrypt on the other end.

The security isn't as big of a concern as the portability of the code, so I'd like to be able to keep things as simple as possible. Currently, I am using an RC4 implementation, but if I can find something natively supported I figure I can save a lot of unnecessary code.


Solution

  • Edited:

    You should really be using openssl_encrypt() & openssl_decrypt()

    As Scott says, Mcrypt is not a good idea as it has not been updated since 2007.

    There is even an RFC to remove Mcrypt from PHP - https://wiki.php.net/rfc/mcrypt-viking-funeral