无法解析 Base64这个是什么意思啊。是要导入jar包吗。

解决方案 »

  1.   

     Base64自己写也简单,原理就是一个字符占7位,高位没有使用,也有压缩之意。
      

  2.   

    org.apache.commons.codec.binary.Base64
      

  3.   

    以前用过BouncyCastle,线面参考《Java 加解密艺术》import org.bouncycastle.util.encoders.Base64;
    /**
     * 
     * @author Administrator
     *
     */
    public abstract class Base64Code {

    public final static String ENCODEING = "UTF-8";
    /**
     * 
     * @param data need base64 encode
     * @return the value of base64
     * @throws Exception
     */
    public static String encode(String data)throws Exception{
    byte[] b = Base64.encode(data.getBytes(ENCODEING));
    return new String(b, ENCODEING);
    }

    /**
     * 
     * @param data
     * @return
     * @throws Exception
     */
    public static String decode(String data)throws Exception{
    byte[] b = Base64.decode(data.getBytes(ENCODEING));
    return new String(b, ENCODEING);
    }
    }