package com.qxueyou.scc.base.util;
|
|
import sun.misc.BASE64Decoder;
|
import sun.misc.BASE64Encoder;
|
|
@SuppressWarnings("restriction")
|
public class Base64Utils {
|
|
private static final String UTF8 = "utf-8";
|
|
/**
|
* BASE64±àÂë
|
* @param src
|
* @return
|
* @throws Exception
|
*/
|
public static String base64Encoder(String src) throws Exception {
|
BASE64Encoder encoder = new BASE64Encoder();
|
return encoder.encode(src.getBytes(UTF8));
|
}
|
|
/**
|
* BASE64½âÂë
|
* @param dest
|
* @return
|
* @throws Exception
|
*/
|
public static String base64Decoder(String dest) throws Exception {
|
BASE64Decoder decoder = new BASE64Decoder();
|
return new String(decoder.decodeBuffer(dest), UTF8);
|
}
|
|
}
|