@Test
public void base64() throws Exception{
String str="中国合伙人";
byte[] encodeBase64 = Base64.encodeBase64(str.getBytes());
System.out.println(new String(encodeBase64));
byte[] bytes = Base64.decodeBase64(encodeBase64);
System.out.println(new String(bytes));
String string = org.apache.commons.net.util.Base64.encodeBase64String(str.getBytes());
System.out.println(string);
byte[] bytes1 = Base64.decodeBase64(string);
System.out.println(new String(bytes1));
}
@Test
public void bCodec() throws Exception{
String str="中国合伙人";
BCodec bCodec = new BCodec();
String encode = bCodec.encode(str);
System.out.println(encode);
String decode = bCodec.decode(encode);
System.out.println(decode);
}
@Test
public void md5(){
String str="中国合伙人";
String md5Hex = DigestUtils.md5Hex(str);
System.out.println(md5Hex);
}
Apache-commons:codec编解码(Base64 | MD5)
最新推荐文章于 2024-09-03 07:04:34 发布