随笔 - 547  文章 - 1  评论 - 295  阅读 - 33万

Base64编码和解码字符串

Base64编码和解码字符串

复制代码
package com.example.core.mydemo.cpic;

import org.apache.commons.codec.binary.Base64;

/**
 * strEncode=aGVsbG8gd29ybGQ=
 * strDecode=hello world
 */
public class BizRequestBase64Test {
    private static final String CHAR_SET_UTF_8 = "UTF-8";

    public static void main(String[] args) throws Exception{
        String str = "hello world";
        String strEncode = new Base64().encodeToString(str.getBytes(CHAR_SET_UTF_8));
        System.out.println("strEncode=" + strEncode);

        byte[] biz_request = new Base64().decode(strEncode.getBytes(CHAR_SET_UTF_8));
        System.out.println("strDecode=" + new String(biz_request));

    }
}
复制代码

 

posted on   oktokeep  阅读(35)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
历史上的今天:
2022-06-30 nested exception is java.lang.StackOverflowError解析
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示