Java Base64
2021-10-28 本文已影响0人
还是那个没头脑
public static String encode(byte[] bstr) {
/**
* 编码
* @param byte[]
* @return string
*/
return new sun.misc.BASE64Encoder().encode(bstr);
}
public static byte[] decode(String str){
/**
* 解码
* @param str
* @return string
*/
byte[] bt = null;
try {
sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
bt = decoder.decodeBuffer(str);
} catch (IOException e) {
e.printStackTrace();
}
return bt;
}