ZBase32 1.0.0
dotnet add package ZBase32 --version 1.0.0
NuGet\Install-Package ZBase32 -Version 1.0.0
<PackageReference Include="ZBase32" Version="1.0.0" />
<PackageVersion Include="ZBase32" Version="1.0.0" />
<PackageReference Include="ZBase32" />
paket add ZBase32 --version 1.0.0
#r "nuget: ZBase32, 1.0.0"
#:package ZBase32@1.0.0
#addin nuget:?package=ZBase32&version=1.0.0
#tool nuget:?package=ZBase32&version=1.0.0
ZBase32
A modern, high-performance .NET library for Z-Base-32 encoding and decoding.
This implementation is optimized for speed and low memory allocation by leveraging Span<T> and other modern .NET features.
What is Z-Base-32?
Z-Base-32 is a Base32 encoding variant designed by Zooko Wilcox-O'Hearn to be more human-friendly. It uses a custom alphabet that minimizes visual ambiguity between characters (e.g., 1, l, i) and is case-insensitive. It is a great choice for generating short, memorable, and easily transcribable identifiers.
Features
- Fast and Efficient: Optimized for high throughput and minimal memory usage.
- Modern API: Uses
Span<T>andReadOnlySpan<T>for zero-allocation operations where possible. - Simple Static Methods: A straightforward
ZBase32Encoderclass with staticEncodeandDecodemethods. - Case-Insensitive Decoding: Adheres to the Z-Base-32 specification by treating uppercase and lowercase characters as equivalent during decoding.
- Convenience Methods: Includes helpers for encoding/decoding UTF-8 strings directly.
- Supports: .NET 8, 9 and 10
Installation
Install the package from NuGet using the .NET CLI:
dotnet add package ZBase32
Usage
The library exposes a single static class ZBase32.ZBase32Encoder.
Basic Encoding and Decoding
To encode a byte array into a Z-Base-32 string:
using ZBase32;
byte[] data = { 0xF8, 0x3E, 0x7A, 0x13, 0x8D, 0x95, 0x3E, 0x56 };
string encoded = ZBase32Encoder.Encode(data);
Console.WriteLine(encoded);
To decode a Z-Base-32 string back into a byte array:
using ZBase32;
string encoded = "64385t78983xyr4o";
byte[] decoded = ZBase32Encoder.Decode(encoded);
Working with UTF-8 Strings
The library includes helper methods to work directly with UTF-8 strings.
using System.Text;
using ZBase32;
// Encoding a string
string originalText = "Hello, World!";
string encodedText = ZBase32Encoder.EncodeUtf8String(originalText);
Console.WriteLine(encodedText);
// Decoding back to a string
string decodedText = ZBase32Encoder.DecodeToUtf8String(encodedText);
Console.WriteLine(decodedText);
High-Performance Usage with Span<T>
For performance-critical scenarios, you can use the Span<T>-based overloads to avoid array allocations.
using ZBase32;
// Encoding from a ReadOnlySpan<byte>
ReadOnlySpan<byte> dataSpan = new byte[] { 0xDE, 0xAD, 0xBE, 0xEF };
string encoded = ZBase32Encoder.Encode(dataSpan);
Console.WriteLine(encoded);
// Decoding to a byte[] from a ReadOnlySpan<char>
ReadOnlySpan<char> encodedSpan = "tuex3z61".AsSpan();
byte[] decoded = ZBase32Encoder.Decode(encodedSpan);
Performance
This library was designed with performance as a primary goal.
- Span-Based Core: The core logic operates on spans to eliminate unnecessary memory allocations and copies.
- Array Pooling: For encoding larger data sets,
ArrayPool<T>is used to rent and return buffers, reducing GC pressure. - Optimized Lookups: Decoding uses a pre-computed array for O(1) character-to-value lookups.
License
This library is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 144 | 11/8/2025 |