java 加密
一、md5加密
1、spring自带的工具DigestUtils实现
org.springframework.util.DigestUtils
DigestUtils.md5DigestAsHex(“1234”.getBytes())
2、第三方包加密
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.9</version> </dependency>
DigestUtils.md5DigestAsHex(userPwd.getBytes());
2、sha1加密
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.9</version> </dependency>
String sign = DigestUtils.sha1Hex(str.getBytes());