Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql field encryption

Shulou Source: shulou.com Published: 2022-06-01 10:12:40 10月06日 Update

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.

Tags: Data type encryption function maximum two-way size result storage test field different normal between binary unit item byte that is file Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MariaDB Docker Microsoft MySQL