TNT blog  
日历
<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
统计
  • 随笔 - 5
  • 文章 - 40
  • 评论 - 7
  • 引用 - 0

导航

常用链接

留言簿(2)

随笔分类

随笔档案

文章分类

文章档案

收藏夹

home

搜索

  •  

最新随笔

最新评论

阅读排行榜

 
/**
    * Encode a string using Base64 encoding. Used when storing passwords
    * as cookies.
    *
    * This is weak encoding in that anyone can use the decodeString
    * routine to reverse the encoding.
    *
    * @param str
    * @return String
    */
   public static String encodeString(String str)  {
       sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
       return encoder.encodeBuffer(str.getBytes()).trim();
   }

   /**
    * Decode a string using Base64 encoding.
    *
    * @param str
    * @return String
    */
   public static String decodeString(String str) {
       sun.misc.BASE64Decoder dec = new sun.misc.BASE64Decoder();
       try {
           return new String(dec.decodeBuffer(str));
       } catch (IOException io) {
               throw new RuntimeException(io.getMessage(), io.getCause());
       }
    }

posted on 2006-06-01 10:40 TNT 阅读(195) 评论(0)  编辑  收藏 所属分类: JAVA

只有注册用户登录后才能发表评论。


网站导航:
 
 
Copyright © TNT Powered by: 博客园 模板提供:沪江博客