[API Proposal]: String-to-String Base64 Encode/Decode
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start by reviewing the proposed APIs for System.Convert, System.Buffers.Text.Base64, and Base64Url, along with the existing Base64 APIs they extend. The issue does not name files or tests; the first step is to determine whether the proposed signatures and behavior fit the project’s API conventions. Done means the proposal has a clear design decision, including the Encoding parameters.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Background and Motivation
Today, .NET's Base64 APIs have a gap: there is no direct way to encode a string to a Base64 string, or decode a Base64 string back to a string. Every existing method either accepts byte[] / ReadOnlySpan<byte> as input (encode side) or returns byte[] (decode side).
This pattern is extremely common across the .NET ecosystem. It appears in CI/CD tooling, configuration loaders, certificate handling, token encoding, and countless other packages. In many cases the Base64-encoded values are stored as strings in configuration files, databases, or API responses and need to be decoded back to strings when consumed later.
var certPem = Encoding.UTF8.GetString(Convert.FromBase64String(configuration.ClientCertificateData));
var releaseBuildBase64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(releaseBuild));
This is verbose, does not have easy discoverability and allocates an intermediate byte[] that could be avoided internally.
Proposed API
All methods accept ReadOnlySpan<char> rather than string — callers can pass a string directly thanks to the implicit conversion.
namespace System;
public static partial class Convert
{
public static string ToBase64String(ReadOnlySpan<char> source, Encoding encoding);
public static string ToBase64String(ReadOnlySpan<char> source, Encoding encoding, Base64FormattingOptions options);
}
namespace System.Buffers.Text;
public static partial class Base64
{
public static string EncodeToString(ReadOnlySpan<char> source, Encoding encoding);
public static string DecodeToString(ReadOnlySpan<char> source, Encoding encoding);
}
public static partial class Base64Url
{
public static string EncodeToString(ReadOnlySpan<char> source, Encoding encoding);
public static string DecodeToString(ReadOnlySpan<char> source, Encoding encoding);
}
API Usage
// Encode a connection string for safe storage in a config file
string encoded = Convert.ToBase64String("Server=prod;Database=App;User=admin;", Encoding.UTF8);
// Decode it back when reading the config
string connectionString = Convert.FromBase64ToString(encoded, Encoding.UTF8);
Edit: Added Encoding parameters
- Ngôn ngữ chính
- C#
- Star
- 18.4k
- Fork
- 5.8k
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 581
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/runtime
-
Incorrect loop bound in SizeOptIListSelectIterator.ToListCó thể đã có người làm @equmagg đã nhận 1 ngày trước. Đang mởarea-System.Collections untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
dotnet/runtime#137126 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DbTransaction.SupportsSavepoints docs say Release/ReleaseAsync are expected to throw, but they are no-ops by designCó thể đã có người làm @alaricd đã nhận 2 ngày trước. Đang mởarea-System.Transactions untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dotnet/runtime#137040 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
FileSystemGlobbing: Matcher throws ArgumentOutOfRangeException when the rootDir is the same value as the fileCó thể đã có người làm @makazeu đã nhận 2 ngày trước. Đang mởarea-Extensions-FileSystem
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/runtime#136989 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Configuration binder source generator emits unqualified List<T> when binding arrays without implicit usingsCó thể đã có người làm @makazeu đã nhận 2 ngày trước. Đang mởarea-Extensions-Configuration bug source-generator
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/runtime#136972 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[wasi] .NET 10: WasmEnableSIMD with AOT fails because WasiApp.targets has -msimd128 commented outĐang mởarea-Build-mono untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của dotnet/runtime
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
juandresrodca/AdminForge#54 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[辞書] C/C++のプリプロセッサ指令名を英字のままにするĐang mở要トリアージ 辞書
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
yksr-melt/Meltype#1625 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Docs typoĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
MonoGame/docs.monogame.github.io#328 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
space-wizards/RobustToolbox#7197 ·
Maintainer thường phản hồi trong vòng 1 ngày