SimpleBase

February 10, 2026 · View on GitHub

NuGet Version Build Status

This is my own take for exotic base encodings like Base32, Base58 and Base85. I started to write it in 2013 as coding practice and kept it as a small pet project. I suggest anyone who wants to brush up their coding skills to give those encoding problems a shot. They turned out to be more challenging than I expected. To grasp the algorithms I had to get a pen and paper to see how the math worked.

Features

  • Multibase: All formats covered by SimpleBase including a few Base64 variants are supported. Base2, Base8, and Base10 are also supported.
  • Base32: RFC 4648, BECH32, Crockford, z-base-32, Geohash, FileCoin and Extended Hex (BASE32-HEX) flavors with Crockford character substitution, or any other custom flavors.
  • Base36: Both lowercase and uppercase alphabets are supported.
  • Base45: RFC 9285 is supported.
  • Base58: All the standard (Bitcoin (BTC), Ripple (XRP), Monero (XMR)) and custom Base58 encoding methods are supported. Also provides Base58Check and Avalanche (AVAX) CB58 encoding/decoding helpers.
  • Base62: The standard Base62 encoding/decoding supported along with a custom alphabet.
  • Base85: Ascii85, Z85 and custom flavors. IPv6 encoding/decoding support.
  • Base16: UpperCase, LowerCase and ModHex flavors. An experimental hexadecimal encoder/decoder just to see how far I can take the optimizations compared to .NET's implementations. It's quite fast now, but .NET has Convert.FromHexString() method since .NET 5. This is mostly a baseline implementation now (except for when you need ModHex).
  • Base256 Emoji🚀: Supported by Multibase, and can also be used individually.
  • One-shot memory buffer based APIs for simple use cases.
  • Stream-based async APIs for more advanced scenarios.
  • Lightweight: No dependencies.
  • Support for big-endian CPUs like IBM s390x (zArchitecture).
  • Thread-safe.
  • Simple to use.

NuGet

To install it from NuGet:

Install-Package SimpleBase

If you need .NET Standard 2.0 compatible version for targeting older .NET Framework or .NET Core, use the 2.x release line instead. It's missing newer features, but still supported:

Install-Package SimpleBase -MaximumVersion 2.999.0

Usage

The basic usage for encoding a buffer into, say, Base32, is as simple as:

using SimpleBase;

byte[] myBuffer;
string result = Base32.Crockford.Encode(myBuffer, padding: true);
// you can also use "ExtendedHex" or "Rfc4648" as encoder flavors

Decoding is also similar:

using SimpleBase;

string myText = ...
byte[] result = Base32.Crockford.Decode(myText);

See the wiki for more types of examples and full documentation.

Benchmark Results

Small buffer sizes are used (64 characters). They are closer to real life applications. Base58 performs really bad in decoding of larger buffer sizes, due to polynomial complexity of numeric base conversions.

BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.7705/25H2/2025Update/HudsonValley2) AMD Ryzen 9 5950X 4.00GHz, 1 CPU, 32 logical and 16 physical cores .NET SDK 10.0.102 [Host] : .NET 10.0.2 (10.0.2, 10.0.225.61305), X64 RyuJIT x86-64-v3 DefaultJob : .NET 10.0.2 (10.0.2, 10.0.225.61305), X64 RyuJIT x86-64-v3

MethodMeanErrorStdDevGen0Allocated
DotNet_Base6422.93 ns0.413 ns0.345 ns0.0120200 B
Base2_Default269.93 ns5.336 ns5.240 ns0.06251048 B
Base8_Default133.93 ns2.183 ns1.823 ns0.0219368 B
Base16_UpperCase85.39 ns0.642 ns0.600 ns0.0167280 B
Multibase_Base16_UpperCase96.92 ns1.783 ns3.260 ns0.0334560 B
Base32_CrockfordWithPadding136.41 ns1.744 ns1.632 ns0.0138232 B
Base36_LowerCase8,297.76 ns12.181 ns10.172 ns-224 B
Base45_Default119.01 ns2.155 ns2.725 ns0.0129216 B
Base58_Bitcoin7,333.59 ns46.523 ns43.518 ns0.0076200 B
Base58_Monero180.92 ns1.260 ns1.117 ns0.0119200 B
Base62_Default7,210.10 ns11.733 ns10.975 ns0.0076192 B
Base85_Z85138.75 ns0.786 ns0.735 ns0.0110184 B
Base256Emoji_Default215.19 ns3.288 ns2.915 ns0.0162272 B

Decoding (80 character string, except Base45 which must use an 81 character string)

MethodMeanErrorStdDevGen0Gen1Allocated
DotNet_Base64104.14 ns1.107 ns1.035 ns0.0052-88 B
Base2_Default94.64 ns0.598 ns0.559 ns0.0024-40 B
Base8_Default94.38 ns1.376 ns1.149 ns0.0024-40 B
Base16_UpperCase48.49 ns0.128 ns0.107 ns0.0038-64 B
Base16_UpperCase_TextReader251.52 ns4.994 ns10.642 ns0.49660.01558312 B
Multibase_Base16_UpperCase51.67 ns0.143 ns0.126 ns0.0038-64 B
Multibase_TryDecode_Base16_UpperCase45.49 ns0.090 ns0.075 ns---
Base32_Crockford96.56 ns0.793 ns0.619 ns0.0048-80 B
Base36_LowerCase3,167.34 ns22.424 ns18.725 ns0.0038-80 B
Base45_Default65.67 ns0.699 ns0.654 ns0.0048-80 B
Base58_Bitcoin3,545.49 ns11.770 ns9.829 ns0.0038-88 B
Base58_Monero75.63 ns1.222 ns1.083 ns0.0052-88 B
Base62_Default3,759.70 ns63.712 ns59.596 ns0.0038-88 B
Base85_Z85237.43 ns0.770 ns0.601 ns0.0052-88 B
Base256Emoji_Default273.74 ns2.261 ns1.888 ns0.0062-104 B

Notes

I'm sure there are areas for improvement. I didn't want to go further in optimizations which would hurt readability and extensibility. I might experiment on them in the future.

Test suite for Base32 isn't complete, I took most of it from RFC4648. Base58 really lacks a good spec or test vectors needed. I had to resort to using online converters to generate preliminary test vectors.

Base85 tests are also makseshift tests based on what output Cryptii produces. Contribution to missing test cases are greatly appreciated.

It's interesting that I wasn't able to reach .NET Base64's performance with Base16 with a straightforward managed code despite that it's much simpler. I was only able to match it after I converted Base16 to unsafe code with good independent interleaving so CPU pipeline optimizations could take place. Still not satisfied though. Is .NET's Base64 implementation native? Perhaps.

Thanks

Thanks to all contributors who provided patches, and reported bugs.

Chatting about this pet project with my friends @detaybey, @vhallac, @alkimake and @Utopians at one of our friend's birthday encouraged me to finish this. Thanks guys.