admin管理员组

文章数量:1794759

Base64编码和解码字符串

Base64编码和解码字符串

代码语言:javascript代码运行次数:0运行复制
package com.example.core.mydemo.cpic;

import org.apachemons.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));

    }
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2023-06-30,如有侵权请联系 cloudcommunity@tencent 删除字符串base64charstring编码

本文标签: Base64编码和解码字符串