Base64加密与解密,
分享于 点击 16887 次 点评:33
Base64加密与解密,
[java] view plain copy- <pre name="code" class="java"><pre name="code" class="java">import java.io.IOException;
- import sun.misc.BASE64Decoder;
- import sun.misc.BASE64Encoder;
- public class Base64 {
- public static void main(String[] args) throws IOException {
- //加密
- String str="中华人民共和国";
- BASE64Encoder base = new BASE64Encoder();
- str = base.encode(str.getBytes("utf-8"));
- System.out.println("加密为:"+str);
- //解密
- BASE64Decoder bd = new BASE64Decoder();
- byte[] b = bd.decodeBuffer(str);
- String result = new String(b,"utf-8");
- System.out.println("解密为:"+result);
- }
- }
转载自:http://blog.csdn.net/zxdfc/article/details/39900025
相关文章
- 暂无相关文章
用户点评