ITeye博客

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

Pringles · 2007-04-29 13:50 · Java se · Markdown

<%@ 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)

  1. #1 楼 · xinyu391 · 2011-03-03 11:08

    又是加密。。。。

评论功能维护中,当前仅展示历史评论。