MCrypt can be your friend here. However, keep in mind that for every public (and useful) encryption method, a key is required. If AES encryption or 3DES encryption did not require a key during the encryption process, then breaking the encryption would be just an attempt at every standard decryption method until you get a meaningful result. Thus, storing a key for your payment gateway carries the same risks as storing a key for your encryption. Regardless of how many encryption layers you want to add, at some level there should be a key stored in plain text, usually hardcoded in PHP and often in the included config.php , in order to simplify its change into the future.
The only option to safely store information without the need for a key is to create your own encryption method. The security of this method lies exclusively in the fact that no one knows the means by which you encrypt the string, so they do not have a phased template to just go back. If you ever told someone how your encryption works, then security will be denied. In addition, there are many algorithmic ways to break simple encryption (for example, replacing letters). That's why mathematicians get a lot of money to develop things like AES.
It is best to look into MCrypt Encrypt and MCrypt Decrypt . That way, if only your PHP is compromised, then they know the key you used for encryption, but they have no data. If only the database is compromised, then they have data, but not the key that you used for encryption. If both are compromised, you are screwed. But if both of them are compromised, you are screwed up no matter what you do so that there is a fairly safe route.
stevendesu
source share