当前位置:网站首页>MySQL storage data encryption

MySQL storage data encryption

2022-07-04 22:13:00 CodingSir

There are two mainstream encryption methods

ENCODE And DECODE

#  Build a test sheet 
create table users(
    username varchar(128), #  The user nickname 
    password blob # password 
) engine=innodb default charset=utf8;

#  Insert a test statement 
INSERT INTO users (username, password) VALUES ('john', ENCODE('guessme', 'salt')); 
commit;

#  Inquire about john Password ( With mysql workbench)
select t.username, DECODE(t.password,'salt') as password from users t where t.username = 'john';
#  In the query structure password Value up , Right click ,'open value in viewer'. You can see text TAB Password plaintext under .

AES_ENCRYPT And AES_DECRYPT

 The security level of this encryption method is better than encode high , It has been deprecated in the new version of the database encode And decode.
#  The test table , Also use users

#  Insert a statement 
INSERT INTO users (username, password) VALUES ('steven', aes_encrypt('password', 'salt')); 
commit;

#  Inquire about steven Password ( With mysql workbench)
select t.username, aes_decrypt(t.password,'salt') as password from users t where t.username = 'steven';
原网站

版权声明
本文为[CodingSir]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207042137273017.html