public static String getBASE64(String s) {
String ret = null;
if (s == null) {
return null;
}
try{
ret = (new BASE64Encoder()).encode( s.getBytes("UTF-8") );
} catch(Exception e){
ret = null;
}
return ret;
}
public static String getFromBASE64(String s) {
String ret;
if (s == null) {
return null;
}
System.out.println("getFromBASE64 s = " + s);
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] b = decoder.decodeBuffer(s);
ret = new String(b, "UTF-8");
} catch (Exception e) {
ret = null;
}
return ret;
}
base64编码转化
最新推荐文章于 2024-06-13 13:32:22 发布