首页>代码>java项目常用开发工具类>/新建文件夹 (4)/Base64Utils.java
package com.ylpw.utils;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

/** * BASE64加密解密 */
@SuppressWarnings("restriction")
public class Base64Utils {
	/** * BASE64解密 * @param key * @return * @throws Exception */
	public static byte[] decryptBASE64(String key) throws Exception {
		return (new BASE64Decoder()).decodeBuffer(key);
	}

	/** * BASE64加密 * @param key * @return * @throws Exception */
	public static String encryptBASE64(byte[] key) throws Exception {
		return (new BASE64Encoder()).encodeBuffer(key);
	}

	public static void main(String[] args) throws Exception {
		String data = Base64Utils.encryptBASE64("http://aub.iteye.com/".getBytes());
		System.out.println("加密前:" + data);
		byte[] byteArray = Base64Utils.decryptBASE64(data);
		System.out.println("解密后:" + new String(byteArray));
	}
}
最近下载更多
一个好人520  LV10 2021年9月29日
叽哩咕噜  LV2 2020年12月24日
wangdongtai  LV31 2020年11月6日
xcj456  LV8 2020年9月12日
moomin709  LV24 2020年7月6日
Gyq灬ming  LV11 2020年6月4日
xuyongff  LV24 2019年11月19日
托马斯奎  LV6 2019年8月5日
qq1453363097  LV13 2019年3月26日
高利杰  LV5 2018年12月19日
最近浏览更多
wenpeng182013  LV7 1月6日
清清河边草 2023年10月11日
暂无贡献等级
漫步的海星  LV4 2023年3月14日
菜鸟666  LV2 2022年8月10日
17782780328  LV1 2022年7月21日
ewan007  LV30 2022年7月8日
a3870764722a  LV22 2022年6月7日
喃喵xxxx  LV6 2022年4月20日
crosa_Don  LV18 2022年4月1日
nbzhou2013  LV14 2022年3月18日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友