ZBase32 1.1.0

dotnet add package ZBase32 --version 1.1.0
                    
NuGet\Install-Package ZBase32 -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZBase32" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZBase32" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ZBase32" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZBase32 --version 1.1.0
                    
#r "nuget: ZBase32, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ZBase32@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZBase32&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ZBase32&version=1.1.0
                    
Install as a Cake Tool

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> and ReadOnlySpan<T> for zero-allocation operations where possible.
  • Simple Static Methods: A straightforward ZBase32Encoder class with static Encode and Decode methods.
  • 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.

Changes

  • 1.1.0 - Added support for netstandard2.0
  • 1.0.0 - Initial version
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ZBase32:

Package Downloads
FluentCss.Core

Fluent strongly typed CSS for Blazor, MVC and Razor Pages

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 278 10/13/2026
1.0.0 210 11/8/2025