java中一句代码使用md5加密、sha加密
需要引入commons-codec-xxxx.jar包
maven 工程使用下面方式引入
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
然后在代码中使用如下代码:
import org.apache.commons.codec.digest.DigestUtils;
// md5 加密
String str = DigestUtils.md5Hex("111111");
// sha1 加密
str = DigestUtils.shaHex("111111");
得到加密后的str