首頁 >資料庫 >mysql教程 >MYSQL 加密SQL

MYSQL 加密SQL

WBOY
WBOY原創
2016-06-07 15:47:171100瀏覽

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




陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn