Java BASE64 编码和解码

代码:

        String str="123456";
        String encode = new BASE64Encoder().encode(str.getBytes());
        System.out.println("编码过后:"+encode);
        byte[] bytes = new BASE64Decoder().decodeBuffer(encode);
        String decode = new String(bytes, "UTF-8");
        System.out.println("解码过后:"+decode);


输出结果:

编码过后:MTIzNDU2
解码过后:123456

 注意解码后的编码格式。。

原文:https://blog.csdn.net/weixin_42172528/article/details/81034946 

猜你喜欢

转载自blog.csdn.net/yan88888888888888888/article/details/88014471