SpringBoot学习——MD5加密(DigestUtils工具类)

在使用Spring框架的时候,我们会对一些重要的密码进行加密可以使用MD5,其工具类是DigestUtils;

DigestUtils相同名字的工具类有两个:
1. Spring框架继承的:

import org.springframework.util.DigestUtils;
 String inputMD = "deqwfdeqe";
 DigestUtils.md5DigestAsHex(inputMD.getBytes());

2. apaceh commons-codec 加密工具类 DigestUtils 

依赖的maven:

<dependency>
	    <groupId>commons-codec</groupId>
	    <artifactId>commons-codec</artifactId>
</dependency>
<dependency>
	    <groupId>org.apache.commons</groupId>
	    <artifactId>commons-lang3</artifactId>
	    <version>3.6</version>
</dependency>
String src = "dklwhjwhv";
DigestUtils.md5Hex(src);


 

发布了159 篇原创文章 · 获赞 86 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/qq_40301026/article/details/104508335
今日推荐