commons-codec-1.9.jar 是做什么用的?

commons-codec用来处理常用的编码方法的工具类包,例如DES、SHA1、MD5、Base64,URL,Soundx等等。

示例:

不可逆算法

1.MD5

String str = "abc";

DigestUtils.md5Hex(str);

2.SHA1

String str = "abc";

DigestUtils.shaHex(str);

可逆算法

常规加密解密算法:BASE64

加密

String str= "abc";

byte[] b = Base64.encodeBase64(str.getBytes(), true);

System.out.println(new String(b));

解密

String str = "YWJj";

byte[] b = Base64.decodeBase64(str.getBytes());

System.out.println(new String(b));

采集自:https://zhidao.baidu.com/question/2142158180769989268.html

原文地址:https://www.cnblogs.com/rongyao/p/7843985.html