您的位置:首页 > 其它

BASE64 加密与解密的使用

2013-03-29 20:17 302 查看
package com.tonvc.util;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class BaseCyper {
/**
* 加密
* @by tonvc
*/
public String encode(byte[] str) throws Exception{

BASE64Encoder base64 = new BASE64Encoder();

return base64.encode(str);
}
/**
* 解密
* @by tonvc
*/
public String decode(String str) throws Exception {

BASE64Decoder decoder = new BASE64Decoder();
byte[] b = decoder.decodeBuffer(str) ;
return new String(b);

}

public static void main(String[] args) throws Exception {
new BaseCyper().decode("L1Rlc3RGaWxlL7LiytTOxLz+oaqhqjE");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: