In MySQL, The AES_ENCRYPT ('Password', 'key') function can encrypt field values.

Source: Internet
Author: User
AES_ENCRYPT (

AES_ENCRYPT (

In MySQL, The AES_ENCRYPT ('Password', 'key') function can encrypt field values.

AES_DECRYPT (Table field name, 'key') function decryption

For example, table structure:

Insert a piece of data to encrypt the passwd password field.

Insert into credit_card (cid, NAME, email, passwd)

VALUES (101, 'hechunyang', 'hechunyang @ 163.com ', AES_ENCRYPT ('20140901', 'hechunyang '));

, Successfully inserted. Let's take a look at the effect of database encryption:

We can see that it is encrypted and garbled.

The user needs to perform verification when logging on, and the program needs to be decrypted, through the AES_DECRYPT function (the Field name of the table, 'key ')

SELECT cid, NAME, email, AES_DECRYPT (passwd, 'hechunyang') as passwd FROM credit_card

WHERE;

As you can see, it has been decrypted.

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.