MD5 encrypted database level
What is MD5?
Mainly enhancement algorithm complexity and irreversibility.
MD5 irreversible, specific MD5 is worth the same
MD5 crack the principle site, behind a dictionary (MD5 encrypted value, value before encryption)
create table testmd5(
id int(4) PRIMARY KEY not null,
name varchar(20) not null,
pwd varchar(50) not null
)
-- 明文密码
INSERT into testmd5 VALUES(1,'张三','13246'),(2,'李四','451323'),(3,'王五','156')
-- 加密
UPDATE testmd5 set pwd = MD5(pwd) where id = 1
-- 加密所有密码(测试第二次加密会更改MD5值)
UPDATE testmd5 set pwd = MD5(pwd)
-- 插入的时候加密
INSERT into testmd5 VALUES(4,'赵六',MD5('4554645656'))
-- 如何校验:将用户传递进来的密码,进行md5加密,然后比对加密后的值
SELECT * FROM testmd5 WHERE name = '赵六' AND pwd = MD5('4554645656')
SELECT * from testmd5