<%@ page import="sun.misc.BASE64Decoder" %>
<%@ page import="sun.misc.BASE64Encoder" %>
// 将 s 进行 BASE64 编码
static String getBASE64(String s) {
if (s == null) return null;
return (new sun.misc.BASE64Encoder()).encode( s.getBytes() );
}
// 将 BASE64 编码的字符串 s 进行解码
static String decodeBASE64(String ss) {
BASE64Decoder decoder = new BASE64Decoder();
if(ss == null){
return null;
}else{
try{
byte[] b = decoder.decodeBuffer(ss);
return new String(b);
}catch(Exception e){
return null;
}
}
}
}
<%@ page import="sun.misc.BASE64Encoder" %>
// 将 s 进行 BASE64 编码
static String getBASE64(String s) {
if (s == null) return null;
return (new sun.misc.BASE64Encoder()).encode( s.getBytes() );
}
// 将 BASE64 编码的字符串 s 进行解码
static String decodeBASE64(String ss) {
BASE64Decoder decoder = new BASE64Decoder();
if(ss == null){
return null;
}else{
try{
byte[] b = decoder.decodeBuffer(ss);
return new String(b);
}catch(Exception e){
return null;
}
}
}
}