org.apache.commons.codec.binary.Base64 加密解密

来源:互联网 发布:刘若英我知谁掌管明天 编辑:程序博客网 时间:2024/05/17 01:08
  1. /** 
  2.      * 解密 
  3.      *  
  4.      * @param pwd 
  5.      * @return 
  6.      * @see [类、类#方法、类#成员] 
  7.      */  
  8.     public static String decodeStr(String pwd)  
  9.     {  
  10.         Base64 base64 = new Base64();  
  11.         byte[] debytes = base64.decodeBase64(new String(pwd).getBytes());  
  12.         return new String(debytes);  
  13.     }  
  14.   
  15.     /** 
  16.      * 加密 
  17.      *  
  18.      * @param pwd 
  19.      * @return 
  20.      * @see [类、类#方法、类#成员] 
  21.      */  
  22.     public static String encodeStr(String pwd)  
  23.     {  
  24.         Base64 base64 = new Base64();  
  25.         byte[] enbytes = base64.encodeBase64Chunked(pwd.getBytes());  
  26.         return new String(enbytes);  
  27.     } 
0 0
原创粉丝点击