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编码发布者:admin,转转请注明出处:http://www.yc00.com/web/1754978009a5223685.html
评论列表(0条)