Home >Database >Mysql Tutorial >MYSQL 加密SQL

MYSQL 加密SQL

WBOY
WBOYOriginal
2016-06-07 15:47:171096browse

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




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:MySQL搜索:WHERENext article:mysql 主键自动增长