MD5加密

CREATE TABLE `testmd5`(
`id` INT(4) NOT NULL,
`name` VARCHAR(20) NOT NULL,
`pwd` VARCHAR(20) NOT NULL,
PRIMARY KEY(`id`)
)ENGINE=INNODB DEFAULT CHARSET=utf8;

INSERT INTO testmd5 VALUES(1,'张三','123456'),(2,'张四','123456'),(3,'张五','123456')

-- 加密
UPDATE testmd5 SET pwd=MD5(pwd)

插入时就加密

INSERT INTO testmd5 VALUES(4,'李四',MD5('1234567'))

-- 如何校验:将用户传递进来的密码,进行md5加密,然后比对加密后的值
SELECT * FROM testmd5 WHERE `name`='李四' AND pwd=MD5('1234567')

 

 

 

 

posted @ 2022-01-17 13:40  朝阳的博客  阅读(14)  评论(0编辑  收藏  举报