public class B64Demo {
publicstatic String getBASE64(String s){
if (s == null)
return null;
return (newsun.misc.BASE64Encoder()).encode(s.getBytes());
}
// 将 BASE64编码的字符串 s 进行解码 解密
publicstatic String getFromBASE64(String s){
if (s == null)
return null;
sun.misc.BASE64Decoder decoder = newsun.misc.BASE64Decoder();
try {
byte[] b =decoder.decodeBuffer(s);
return new String(b);
} catch (Exception e) {
return null;
}
}
publicstatic String mTOa(Object ming){
returnB64Demo.getBASE64(B64Demo.getBASE64(B64Demo.getBASE64((String)ming)));
}
publicstatic String aTOm(String an){
returnB64Demo.getFromBASE64(B64Demo.getFromBASE64(B64Demo.getFromBASE64(an)));
}
publicstatic void main(String[] args) {
String a = mTOa("100000.89".toString());
System.out.println(a);//加密
System.out.println(aTOm(a));//解密
}
}