BASE64 加密与解密的使用

来源:互联网 发布:淘宝挂起是什么意思 编辑:程序博客网 时间:2024/05/17 04:54
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");}}