• Base64转码和解码的帮助类


     /**
         * 将字符串进行Base64编码
         *
         * @param s 被编码的字符串
         * @return 编码后的字符串
         */
        public static String encoderBASE64(String s) {
            if (s == null) {
                return null;
            }
            try {
                return Base64.encodeBase64String(s.getBytes("utf-8"));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
                return null;
            }
        }
    
        /**
         * 将 BASE64 编码的字符串 s 进行解码
         *
         * @param s 被解码的字符串
         * @return 解码后的字符串
         */
        public static String decoderBASE64(String s) {
            String str = null;
            try {
                if (!StringUtils.isEmpty(s)) {
                    byte[] b = Base64.decodeBase64(s);
                    str = new String(b, "UTF-8");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return str;
        }
    

      

  • 相关阅读:
    迭代器和生成器
    20.03.23作业
    装饰器
    集合
    元组类型
    字典类型
    列表类型
    字符串类型
    for循环
    深浅copy与while循环
  • 原文地址:https://www.cnblogs.com/baizhanshi/p/6835981.html
Copyright © 2020-2023  润新知