How does mysql-php binary encrypted data ensure data uniqueness?

Source: Internet
Author: User
Sensitive user data in the company's database needs to be encrypted into a binary ciphertext stored in the mysqlblob type field, and it is found that it is difficult to ensure the uniqueness of user data, because it seems that blob fields cannot be directly used for logical operations, and the ciphertext in the table cannot be fully read and decrypted again... sensitive user data in the company's database needs to be encrypted into a binary ciphertext stored in the mysql blob type field. it is found that it is difficult to ensure the uniqueness of user data, because it seems that blob fields cannot be directly used for logical operations, and the ciphertext in the table cannot be fully read and decrypted before logical operations.

Reply content:

Sensitive user data in the company's database needs to be encrypted into a binary ciphertext stored in the mysql blob type field. it is found that it is difficult to ensure the uniqueness of user data, because it seems that blob fields cannot be directly used for logical operations, and the ciphertext in the table cannot be fully read and decrypted before logical operations.

Cache ciphertext md5 based on user ID

I think we should do this:

  1. Add new data to perform md5 hash on plaintext before encryption, and then save a hash value (encrypted blob also needs to be stored)

  2. For some data, you need to find a time to decrypt all the md5 files, and then store the hash value.

In this way, you can determine the uniqueness of the hash value.

Md5 is not recommended for ciphertext unless you can ensure that the same plaintext is always generated after encryption. However, ciphertext will at least be affected by the key. after the key is changed, the ciphertext will definitely change... besides, some encryption methods have random initial vectors, and the ciphertext encrypted each time is different.

Direct mysql built-in method hex ()

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.