java——base64 加密和解密

base64

一.加密

*.若有要求输入字符必须为UTF-8:

则需str.getByte("utf-8");  //在getByte()中指定utf-8编码,否则中文字符将被加密成错乱的字符。

1     /**
2     * params base64加密
3     *
4     */
5        String strParams = new String(req.getParameter("note"));
6        //方法一,可直接使用
7        String enParams = Base64.encodeBase64String(strParams.getBytes()); 
8        //方法二  ,需简单配置一下,配置请看下图
9        String enParams = new BASE64Encoder().encode(strParams.getBytes());

*******配置讲解图*******

二.解密

(待填)

原文地址:https://www.cnblogs.com/helingjuan/p/7485832.html