package cn.test;
import sun.misc.BASE64Decoder;
public class Test {
public static void main(String[] args) {
System.out.println(getBASE64("fffdsd"));
System.out.println(getFormBASE64("ZmZmZHNk"));
}
public static String getBASE64(String s) {
if (s==null) return null;
return (new sun.misc.BASE64Encoder()).encode(s.getBytes());
}
// 将BASE64编码的字符进行解码处理
public static String getFormBASE64(String s) {
if (s == null) {
return null;
}
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] b = decoder.decodeBuffer(s);
return new String(b);
} catch (Exception e) {
return null;
}
}
}
阅读(737) | 评论(0) | 转发(0) |