common-codec加解密base64
public class Base64 {
@org.junit.Test
public void encodeStr(){
String str="Hello";
org.apache.commons.codec.binary.Base64 base64=new org.apache.commons.codec.binary.Base64();
String base64Str=new String(base64.encode(str.getBytes()));
System.out.println(base64Str);
}
@org.junit.Test
public void decodeStr(){
String base64Str="SGVsbG8=";
org.apache.commons.codec.binary.Base64 base64=new org.apache.commons.codec.binary.Base64();
String str=new String(base64.decode(base64Str.getBytes()));
System.out.println(str);
}
}