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);


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章