欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

MYSQL 加密SQL

程序员文章站 2024-02-19 10:35:46
...

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