- <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);
-
- }
-
- }


转载自:https://i-blog.csdnimg.cn/blog_migrate/b97f521e90cd4e0d94e43e86062903c8.png