欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

Base64加密与解密,

来源: javaer 分享于  点击 16887 次 点评:33

Base64加密与解密,


[java] view plain copy
  1. <pre name="code" class="java"><pre name="code" class="java">import java.io.IOException;  
  2.   
  3. import sun.misc.BASE64Decoder;  
  4. import sun.misc.BASE64Encoder;  
  5.   
  6. public class Base64 {  
  7.   
  8.       
  9.     public static void main(String[] args) throws IOException {  
  10.         //加密  
  11.         String str="中华人民共和国";  
  12.         BASE64Encoder base = new BASE64Encoder();  
  13.         str = base.encode(str.getBytes("utf-8"));  
  14.         System.out.println("加密为:"+str);  
  15.         //解密  
  16.         BASE64Decoder bd = new BASE64Decoder();  
  17.         byte[] b = bd.decodeBuffer(str);  
  18.         String result = new String(b,"utf-8");  
  19.         System.out.println("解密为:"+result);  
  20.   
  21.     }  
  22.   
  23. }  


转载自:http://blog.csdn.net/zxdfc/article/details/39900025

相关文章

    暂无相关文章
相关栏目:

用户点评