Skip to content
欢迎扫码关注公众号

JEP 135: Base64 Encoding & Decoding | Base64 编码与解码

摘要

为 Base64 编码和解码定义一个标准 API。

动机

Base64 编码方案 经常被用于将作为文本数据传输的二进制 / 八位字节序列进行编码。它通常被使用 MIME(多用途互联网邮件扩展)的应用程序、HTTP 头部密码编码、消息摘要等场景所采用。

JDK 长期以来一直缺少一个 Base64 编码和解码的标准 API。多年来,开发人员频繁请求此功能,许多开发人员不得不使用 JDK 的私有且不受支持的类,如 sun.misc.BASE64Encodersun.misc.BASE64Decoder

JDK 本身有几个内部实现:java.util.prefs.Base64com.sun.org.apache.xml.internal.security.utils.Base64com.sun.net.httpserver.Base64 等。一个标准 API 将使这些类型的实现得以淘汰。

描述

java.util 中定义一个用于 Base64 编码和解码的简单 API。

API 必须明确指定实现的 Base64 编码方案,可能是由 RFC 1521 指定的 Base64 内容传输编码。

API 应支持常见情况,如将字节数组中的二进制数据进行编码,或从输入流中读取数据进行编码,以及将字符串解码到字节数组或 ByteBuffer 中。

应检查 JDK 中 Base64 的现有用法和实现,以寻找替换和使用新 API 的机会。

测试

该 API 将需要与新实现一起开发的新单元测试。新的功能测试也将非常有用。

影响

  • TCK:需要新的测试。

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.