Mysql encryption or php application layer encryption

Source: Internet
Author: User
Is mysql encrypted or php application-layer encryption? is mysql encrypted or php application-layer encryption for user sensitive information such as passwords or ID cards?


Reply to discussion (solution)

I don't understand what you mean.

In fact, I think the effect of encryption through MySQL and php is to encrypt and store plain text information, which is the same for individual users.

I don't understand what you mean.


Well, one is to encrypt data with aes or other algorithms in php, and the other is to encrypt data with the built-in aes function in mysql when saving data to mysql.

In fact, I think the effect of encryption through MySQL and php is to encrypt and store plain text information, which is the same for individual users.


Is there a difference?

If you only use MySQL (will not be promoted in the future), you can use AES_ENCRYPT (str, key_str), AES_DECRYPT (crypt_str, key_str), ENCODE (str, pass_str), DECODE (str, pass_str)
Encryption, but the encryption result is binary data, should be saved using blob type field

Otherwise, you should use php for encryption

If you only use MySQL (will not be promoted in the future), you can use AES_ENCRYPT (str, key_str), AES_DECRYPT (crypt_str, key_str), ENCODE (str, pass_str), DECODE (str, pass_str)
Encryption, but the encryption result is binary data, should be saved using blob type field

Otherwise, you should use php for encryption


Thank you for your reply.
If php and mysql are used together, you are advised to use php for encryption.
In fact, I also tend to encrypt data in php. it seems that I have never seen anyone encrypt data in mysql during php.
But I want to know why?

Forward compatibility

Forward compatibility


It's too short.


In fact, I think the effect of encryption through MySQL and php is to encrypt and store plain text information, which is the same for individual users.


Is there a difference?


If you use MySQL to encrypt your database, it may be difficult for you to replace the database later. if you use php for general purposes, it will be better.

Flexible encryption using php

I personally think: the database should do the data access work, and the encryption should be handed over to PHP.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.