Base64
简介:用于传输8bit字节代码的编程方式之一。
使用说明:
需使用jar包:xmlbeans2.0.x.jar。
使用:
1、编码
<span style="white-space:pre"> </span>public static String encodeBase64URL(String arg) throws Exception {
String content = new String(Base64.encode(URLEncoder.encode(arg, "UTF-8").getBytes()));
return content;
}
2、解码
<span style="white-space:pre"> </span>public static String decodeBase64URL(String arg) throws Exception {
String content = URLDecoder.decode(new String(Base64.decode(arg.getBytes())), "UTF-8");
return content;
}
更多关于URLEncoder与URLDecoder参见:
http://www.java3z.com/cwbwebhome/article/article2/2414.html。
更多Base64详解参见:
http://www.ruanyifeng.com/blog/2008/06/base64.html。