`
mzh_2008beijing
  • 浏览: 230371 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

BASE64加密解密

 
阅读更多
BASE64工具类,你懂得:

package test;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
    
/**   
 * BASE64加密解密   
 */    
public class BASE64     
{     
    /**    
     * 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 = BASE64.encryptBASE64("".getBytes());     
        System.out.println("解密前:"+data);     
             
        byte[] byteArray = BASE64.decryptBASE64(data);     
        System.out.println("解密后:"+new String(byteArray));     
    }     
} 
分享到:
评论
1 楼 di1984HIT 2013-09-17  
不错,不错,用了、

相关推荐

Global site tag (gtag.js) - Google Analytics