当前位置:Gxlcms > mysql > MYSQL加密SQL

MYSQL加密SQL

时间:2021-07-01 10:21:17 帮助过:62人阅读

INSERT INTO table1 (user, pw) VALUE ('user1', MD5('password1') ) INSERT INTO table1 (user, pw) VALUE ('user1', PASSWORD('password1') ) INSERT INTO table1 (user, pw) VALUE ('user1', SHA1 ('password1') ) 可以通过如下的语句进行密码验证: SELE


INSERT INTO table1 (user, pw) VALUE ('user1', MD5('password1') )

INSERT INTO table1 (user, pw) VALUE ('user1', PASSWORD('password1') )

INSERT INTO table1 (user, pw) VALUE ('user1', SHA1('password1') )


  可以通过如下的语句进行密码验证:

SELECT * FROM table1 WHERE pw = MD5('password1')

SELECT * FROM test.userpass WHERE pass = SHA1('dddd')

SELECT * FROM test.userpass WHERE pass = password('dddd')





















INSERT INTO test.userpass (name,pass,enpass) VALUE ('user3', 'dddd',AES_ENCRYPT('pass','key'));

上面的插入语句有三个字段,“用户名”、“密码”和“加密的密码”。AES_ENCRYPT()函数需要一个“key”来协助加密,同样,解密也需要它

SELECT aes_decrypt(enpass,'key') FROM test.userpass



人气教程排行