惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
IT之家
IT之家
B
Blog RSS Feed
罗磊的独立博客
GbyAI
GbyAI
博客园 - Franky
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
博客园 - 聂微东
N
Netflix TechBlog - Medium
博客园 - 三生石上(FineUI控件)
人人都是产品经理
人人都是产品经理
U
Unit 42
博客园 - 叶小钗
Jina AI
Jina AI
MyScale Blog
MyScale Blog
雷峰网
雷峰网
B
Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
Recent Announcements
Recent Announcements
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - 筱老邪

2026年读书清单,及java技术的巩固 请求处理 图片转为为流的处理 SHA1签名算法,JAVA和C# C#与Java互通AES算法加密解密 在Java和C#中计算SHA-1哈希 .net5读取xml文件 部署linux 踩坑 多线程 .net知识点 下载文件,204问题 debug和release的web.config分开配置 数据库的索引查找 sql 查询出符合条件的表增加字段 HTTP状态码:400\500 错误代码 - 筱老邪 - 博客园 linq 两个list交集差集处理 rabbitMQ的使用 rabbitMQ的部署安装 sql 游标循环
编码和解码
筱老邪 · 2025-05-19 · via 博客园 - 筱老邪
public static String toBase64String(String value) throws UnsupportedEncodingException {
if (value == null || value.isEmpty()) {
return "";
}
byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
return java.net.URLEncoder.encode(new String(Base64.getEncoder().encode(bytes)), "UTF-8");
}

public static String UnBase64String(String value) throws UnsupportedEncodingException {
if (value == null || value.isEmpty()) {
return "";
}
String decodeValue= java.net.URLDecoder.decode(value, "UTF-8");
byte[] decodedBytes = Base64.getDecoder().decode(decodeValue);
return new String(decodedBytes,StandardCharsets.UTF_8);
}