package com.suning.security;
import java.io.IOException;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class EdptByBase64 {
/**
* BASE64 解密
* @param args
* @throws IOException
*/
public static String decryptBase64(String key) throws IOException{
byte[] output=(new BASE64Decoder()).decodeBuffer(key);
String outputStr=new String(output);
return outputStr;
}
/**
* BASE64 加密
* @param args
*/
public static String encryptBASE64(String inputStr){
byte[] inputData=inputStr.getBytes();
return (new BASE64Encoder()).encodeBuffer(inputData);
}
public static void main(String[] args) throws Exception {
String a=EdptByBase64.encryptBASE64("123456");
System.out.println("a ="+a);
String b=EdptByBase64.decryptBase64(a);
System.out.println("b ="+b);
}
}
BASE64加密后可以解密!