Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql field encryption

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

First of all, let's take a look at data of type blob.

Fields of type BLOB are used to store binary data in MySQL. BLOB is a family of types, including TinyBlob, Blob, MediumBlob, and LongBlob. The only difference between these types is in the maximum size of the storage file. Four BLOB type sizes of MySQL (in bytes) TinyBlob Max. 255K Blob Max. 65K Medium.

Create test encryption table data

two。 Single encryption test of data

You can also use this function ENCRYPT

SQL

INSERT pwn VALUES ("Lucy", ENCRYPT ("tttt", "abcd"))

Use the query results of this function to explain NULL, as shown in the figure

We can also use this function:

INSERT pwn VALUES ("Jack", AES_ENCRYPT ("jack", "ccdd"))

You can also use this function AES_DECRYPT (crypt_str,key_str)

SQL:INSERT pwn VALUES ("Pual", AES_DECRYPT ("jack", "ccdd"))

3. Two-way encryption

We insert a piece of data into it:

INSERT INTO pwn (NAME, VALUE) VALUES ('worker', ENCODE (' pual', 'abcd')); 1

View the record as usual:

What can we do to see the value we just saved?

SELECT name, DECODE (VALUE, 'abcd') as value FROM pwn WHERE name='worker'

Results:

This is the so-called two-way encryption, which can encrypt and decrypt data.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report