MD5 不可逆
CREATE TABLE `testmd5`(
`id` INT(4) NOT NULL,
`name` VARCHAR(20) NOT NULL,
`pwd` VARCHAR(50) NOT NULL,
PRIMARY KEY(`id`)
)ENGINE = INNODB DEFAULT CHARSET = utf8
-- 明文密码
INSERT INTO `testmd5` VALUES(1,'zhangsan','123456'),(2,'lisi','123456'),(3,'wangwu','123456')
-- 加密
UPDATE testmd5 SET pwd = MD5(pwd) WHERE `id`=1 -- 加密id为1的
UPDATE testmd5 SET pwd = MD5(pwd) -- 加密所有ID的
INSERT INTO `testmd5` VALUES(4,'zhaoliu', MD5('123456')) -- 在插入时就加密
-- 如何校验 将用户传进来的值进行MD5加密,然后比对加密后的值
SELECT * FROM `testmd5` WHERE `name` = 'zhaoliu' AND pwd = MD5('123456')