`
Pringles
  • 浏览: 50560 次
  • 来自: capital of china
最近访客 更多访客>>
社区版块
存档分类
最新评论

BASE64对字符串的加密(解密)方法

SUN 
阅读更多
<%@ 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;
}
}
}
  }
分享到:
评论
1 楼 xinyu391 2011-03-03  
又是加密。。。。

相关推荐

Global site tag (gtag.js) - Google Analytics