日期:2014-05-20 浏览次数:20744 次
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);
}
}