MD5加密和Bcrypt加密 分手后的思念是犯贱 2022-04-03 09:49 309阅读 0赞 ### 一、MD5加密 ### //引入包 import org.springframework.util.DigestUtils; @Controller @RequestMapping("/resetpwd") public class ResetpwdController { @RequestMapping("/resetpassword") @ResponseBody public int resetpassword(Member member, String username, String pwd) { //加密 pwd = DigestUtils.md5DigestAsHex(pwd.getBytes()); member.setPassword(pwd); int i = memberService.resetPasswordByUsername(member, username); return i; } } ### 二、Bcrypt加密 ### 由于现在彩虹表的出现,使得即使不可逆的MD5加密也变得伪可逆(大数据存储,然后查询),所以采用更为安全的Bcrypt加密。 #### jar包下载 #### 百度云 [https://pan.baidu.com/s/1RU2ptA6uq4LrRuFqUhZ5bw][https_pan.baidu.com_s_1RU2ptA6uq4LrRuFqUhZ5bw] maven存储库 [https://mvnrepository.com/artifact/org.mindrot/jbcrypt][https_mvnrepository.com_artifact_org.mindrot_jbcrypt] #### pom.xml #### <!-- https://mvnrepository.com/artifact/org.mindrot/jbcrypt --> <dependency> <groupId>org.mindrot</groupId> <artifactId>jbcrypt</artifactId> <version>0.4</version> </dependency> package test; import org.mindrot.jbcrypt.BCrypt; public class Test1 { public static void main(String[] args) { String password = "123456";//$2a$10$GRS6nKF9Fp6ie7Vkj4KHI.LBQZDhzgQ2OcIu8sI90ucaL/wJ0D7He //加密 String pwt = BCrypt.hashpw(password, BCrypt.gensalt()); //解密 boolean pswFlag = BCrypt.checkpw(password,"$2a$10$GRS6nKF9Fp6ie7Vkj4KHI.LBQZDhzgQ2OcIu8sI90ucaL/wJ0D7He"); System.out.println(pwt+"===="+pswFlag); } } 实验效果: ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM3Nzk2MDE3_size_16_color_FFFFFF_t_70] [https_pan.baidu.com_s_1RU2ptA6uq4LrRuFqUhZ5bw]: https://pan.baidu.com/s/1RU2ptA6uq4LrRuFqUhZ5bw [https_mvnrepository.com_artifact_org.mindrot_jbcrypt]: https://mvnrepository.com/artifact/org.mindrot/jbcrypt [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM3Nzk2MDE3_size_16_color_FFFFFF_t_70]: /images/20220403/dbe9590eeff64a1b9fd687e516b5340f.png
相关 MD5加盐加密和Spring Security 使用BCrypt加密密码 文链接:[https://liuyanzhao.com/7569.html][https_liuyanzhao.com_7569.html] 1、MD5加盐加密... Love The Way You Lie/ 2024年04月19日 11:20/ 0 赞/ 16 阅读
相关 MD5加密 MD5是不可逆的,无解密一说 只有通过MD5将要比较的字符串加密后,与该字符串进行比较 由于MD5是不可逆的,所以后台比对也是直接拿着MD5加密后的密文进行对比的 示例 喜欢ヅ旅行/ 2022年06月04日 10:17/ 0 赞/ 200 阅读
相关 MD5加密 1. package com.nebula.app.app.common.utils; 2. 3. import java.math.BigInteger; 古城微笑少年丶/ 2022年05月23日 07:56/ 0 赞/ 223 阅读
相关 MD5加密和Bcrypt加密 一、MD5加密 //引入包 import org.springframework.util.DigestUtils; @Controll 分手后的思念是犯贱/ 2022年04月03日 09:49/ 0 赞/ 310 阅读
相关 MD5加密 ![ContractedBlock.gif][] ![ExpandedBlockStart.gif][] Code 1.Default.aspx <html> 深藏阁楼爱情的钟/ 2021年12月22日 22:27/ 0 赞/ 382 阅读
相关 MD5加密 UTIL工具类 MD5Util package com.kude.util; import org.springframework.uti 悠悠/ 2021年11月22日 10:22/ 0 赞/ 376 阅读
相关 md5加密 import java.security.MessageDigest; import java.security.NoSuchAlgorithmExceptio 快来打我*/ 2021年09月26日 09:48/ 0 赞/ 374 阅读
相关 MD5加密 import java.security.MessageDigest; import java.security.NoSuchAlgorithmExceptio 水深无声/ 2021年09月26日 06:22/ 0 赞/ 512 阅读
还没有评论,来说两句吧...