I am new to encryption and I want to know whether the mysql predefined AES method or using php mcrypt_encrypt()
and openssl_encrypt()
is better.

- 277,958
- 43
- 419
- 720

- 158
- 2
- 10
2 Answers
I personally prefer php mcrypt_encrypt()& openssl_encrypt(), but this question is very opinion-based. I would recommend you to go online so that you can decide for yourself. (all the info is on the web!!!)

- 386
- 12
- 25
I'm not sure this this question is as subjective as it sounds.
Q: MySQL AES vs. php
A: For performance-sake, php. If you're using MVC, your models, being blind to the context of a data-request, are going to have to one of two things. Either they always request of MySQL to decrypt the data, even if it's not necessary. Or they don't, and they carry an additional method with which to run additional queries that do nothing but perform the decryption. In the interest of not making MySQL do more with than it has to or run more queries than it has to, I would just make Php handle it for you.
Q: mcrypt
vs. openssl
A: That's an easy one- mcrypt is deprecated. Go with openssl. For a solution that supports both, see my answer here: https://stackoverflow.com/a/49926582/2137316

- 2,659
- 1
- 19
- 20