Base64 算法

1
2
3
4
5
6
7
8
9
10
11
12
/**
* 测试 Base64 转码与解码
* @author 张振伟 (2013-7-24)
*/
public static void base64CoderTest() {
String str = "张振伟";
System.out.println("转码前:" + str);
byte[] bs = Base64.encodeBase64(str.getBytes());
System.out.println("转码后:" + new String(bs));
byte[] bs2 = Base64.decodeBase64(bs);
System.out.println("解码后:" + new String(bs2));
}