BASE64加密/解密

 1 import java.io.IOException;
 2 import sun.misc.BASE64Decoder;
 3 import sun.misc.BASE64Encoder;
 4 
 5 public class Base64Util {
 6     private static BASE64Encoder BASE64Encoder = new BASE64Encoder();
 7 
 8     private static BASE64Decoder BASE64Decoder = new BASE64Decoder();
 9 
10     /* 加密 */
11     public static String encoder( byte[] bytes) {
12         return BASE64Encoder.encode(bytes);
13     }
14 
15     /* 解密 */
16     public static String decoder(String str) throws IOException {
17         byte[] decodeBuffer = BASE64Decoder.decodeBuffer(str);
18         return new String(decodeBuffer);
19     }
20 
21     public static byte[] decoderByByte(String str) throws IOException {
22         return BASE64Decoder.decodeBuffer(str);
23     }
24 
25 }
posted @ 2012-10-20 20:17  将来的老大爷  阅读(194)  评论(0编辑  收藏  举报

如果本页面列出的内容侵犯了您的权益,请告知。
知识共享许可协议
996.icu