Base58Encoding 1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Base58Encoding --version 1.0.0
NuGet\Install-Package Base58Encoding -Version 1.0.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="Base58Encoding" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Base58Encoding" Version="1.0.0" />
<PackageReference Include="Base58Encoding" />
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 Base58Encoding --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Base58Encoding, 1.0.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 Base58Encoding@1.0.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=Base58Encoding&version=1.0.0
#tool nuget:?package=Base58Encoding&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Base58 Encoding Library
A .NET 10.0 Base58 encoding and decoding library with support for multiple alphabet variants.
Features
- Multiple Alphabets: Built-in support for Bitcoin(IFPS/Sui/Solana), Ripple, and Flickr alphabets
- Memory Efficient: Uses stackalloc operations when possible to minimize allocations
- Type Safe: Leverages ReadOnlySpan and ReadOnlyMemory for safe memory operations
- Intrinsics: Uses SIMD
Vector128/Vector256and unrolled loop for counting leading zeros - Optimized Hot Paths: Fast fixed-length encode/decode for 32-byte and 64-byte inputs using Firedancer-like optimizations
Usage
using Base58Encoding;
// Encode bytes to Base58 Bitcoin(IFPS/Sui) alphabet
byte[] data = { 0x01, 0x02, 0x03, 0x04 };
string encoded = Base58.Bitcoin.Encode(data);
// Decode Base58 string back to bytes
byte[] decoded = Base58.Bitcoin.Decode(encoded);
// Ripple / Flickr
Base58.Ripple.Encode(data);
Base58.Flickr.Encode(data);
Performance
The library automatically uses optimized fast paths for common fixed-size inputs:
- 32-byte inputs (Bitcoin/Solana addresses, SHA-256 hashes): 8.5x faster encoding
- 64-byte inputs (SHA-512 hashes): Similar performance improvements
These optimizations are based on Firedancer's specialized Base58 algorithms and are transparent to the user. Unlike Firedancer however, we fallback to the generic approach in case of edge-cases.
Algorithm Details:
- Uses Mixed Radix Conversion (MRC) with intermediate base 58^5 representation
- Precomputed multiplication tables replace expensive division operations
- Converts binary data to base 58^5 limbs, then to raw base58 digits
- Matrix multiplication approach processes 5 base58 digits simultaneously
- Separate encode/decode tables for 32-byte and 64-byte fixed sizes
- Achieves ~2.5x speedup through table-based optimizations vs iterative division
References:
Benchmarks
BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.7462/25H2/2025Update/HudsonValley2)
13th Gen Intel Core i7-13700KF 3.40GHz, 1 CPU, 24 logical and 16 physical cores
.NET SDK 10.0.101
[Host] : .NET 10.0.1 (10.0.1, 10.0.125.57005), X64 RyuJIT x86-64-v3
DefaultJob : .NET 10.0.1 (10.0.1, 10.0.125.57005), X64 RyuJIT x86-64-v3
Job=DefaultJob
| Method | VectorType | Mean | Ratio | Gen0 | Allocated | Alloc Ratio |
|---|---|---|---|---|---|---|
| 'Our Base58 Encode' | BitcoinAddress | 537.07 ns | 1.00 | 0.0057 | 96 B | 1.00 |
| 'SimpleBase Base58 Encode' | BitcoinAddress | 782.31 ns | 1.46 | 0.0057 | 96 B | 1.00 |
| 'Our Base58 Decode' | BitcoinAddress | 168.95 ns | 0.31 | 0.0033 | 56 B | 0.58 |
| 'SimpleBase Base58 Decode' | BitcoinAddress | 352.63 ns | 0.66 | 0.0033 | 56 B | 0.58 |
| 'Our Base58 Encode' | SolanaAddress | 93.41 ns | 1.00 | 0.0070 | 112 B | 1.00 |
| 'SimpleBase Base58 Encode' | SolanaAddress | 1,430.37 ns | 15.31 | 0.0057 | 112 B | 1.00 |
| 'Our Base58 Decode' | SolanaAddress | 181.71 ns | 1.95 | 0.0035 | 56 B | 0.50 |
| 'SimpleBase Base58 Decode' | SolanaAddress | 837.03 ns | 8.96 | 0.0019 | 56 B | 0.50 |
| 'Our Base58 Encode' | SolanaTx | 252.31 ns | 1.00 | 0.0124 | 200 B | 1.00 |
| 'SimpleBase Base58 Encode' | SolanaTx | 7,247.09 ns | 28.73 | 0.0076 | 200 B | 1.00 |
| 'Our Base58 Decode' | SolanaTx | 178.05 ns | 0.71 | 0.0055 | 88 B | 0.44 |
| 'SimpleBase Base58 Decode' | SolanaTx | 2,379.54 ns | 9.43 | 0.0038 | 88 B | 0.44 |
| 'Our Base58 Encode' | IPFSHash | 1,096.58 ns | 1.00 | 0.0076 | 120 B | 1.00 |
| 'SimpleBase Base58 Encode' | IPFSHash | 1,644.83 ns | 1.50 | 0.0076 | 120 B | 1.00 |
| 'Our Base58 Decode' | IPFSHash | 287.87 ns | 0.26 | 0.0038 | 64 B | 0.53 |
| 'SimpleBase Base58 Decode' | IPFSHash | 643.63 ns | 0.59 | 0.0038 | 64 B | 0.53 |
| 'Our Base58 Encode' | MoneroAddress | 4,998.35 ns | 1.00 | 0.0076 | 216 B | 1.00 |
| 'SimpleBase Base58 Encode' | MoneroAddress | 8,585.92 ns | 1.72 | - | 216 B | 1.00 |
| 'Our Base58 Decode' | MoneroAddress | 1,173.48 ns | 0.23 | 0.0057 | 96 B | 0.44 |
| 'SimpleBase Base58 Decode' | MoneroAddress | 3,716.38 ns | 0.74 | 0.0038 | 96 B | 0.44 |
License
This project is available under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.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.