HeavenTang

导航

Base64加解密

package com.heaventang.util.encrypt;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import java.util.*;

/**

  • 编码工具类

  • 1.将byte[]转为各种进制的字符串

  • 2.base 64 encode

  • 3.base 64 decode

  • @author heaventang

  • @version 0.0.5.20140601
    */
    public class HeavenTangEncodeUtil {

    public static void main(String[] args) throws Exception {
    String s = "helloWord Java ";
    System.out.println("转换前:" + s);

     String encode =  new BASE64Encoder().encode("".getBytes());  
     System.out.println("加密后:" + encode);  
       
    String decodeStr = new BASE64Decoder().decodeBuffer( encode );
     System.out.println("解码后:" + decodeStr  );  
    

    }

}

posted on 2017-08-03 19:54  HeavenTang  阅读(230)  评论(0编辑  收藏  举报