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); } }