TextEncoder 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package TextEncoder --version 1.0.1
                    
NuGet\Install-Package TextEncoder -Version 1.0.1
                    
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="TextEncoder" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TextEncoder" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="TextEncoder" />
                    
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 TextEncoder --version 1.0.1
                    
#r "nuget: TextEncoder, 1.0.1"
                    
#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 TextEncoder@1.0.1
                    
#: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=TextEncoder&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=TextEncoder&version=1.0.1
                    
Install as a Cake Tool

TextEncoder

Build Status NuGet Version NuGet Downloads

Install-Package TextEncoder

This library contains a collection of text encoder algorithms, such as Base64.

Text encoding algorithms

Base64

The best known Base64 encoding is defined in RFC 4648. It is widely used in email and web applications. There is no real need for another implementation in .NET, because there is Convert.ToBase64String. However, there are several variants of Base64, which Convert does not cover. These variants are supported by this library and can be used to encode in special use cases, such as URLs, XML and RegEx patterns.

The implementation in this library might compete with the default implementation in .NET as effort is made to optimize the encoding process. There are benchmarks available in the repository.

Base32

Base32 is a binary-to-text encoding that uses an alphabet of 32 digits, each of which represents a different combination of 5 bits ($2^5$). The question of notation, i.e. which characters to use to represent the 32 digits and whether to pad the final encoding, is left to the application.

In this library, there are several character sets available:

  • as described in RFC 4648: letters from 'A' to 'Z' and digits from '2' to '7', padding applied at the end
  • Extended Hex aka Base32Hex: digits from '0' to '9', letters from 'A' to 'V', padding applied at the end
  • ZBase32: Includes 1, 8 and 9 but excludes l, v, 0 and 2. It also permutes the alphabet so that the easier characters are the ones that occur more frequently. Resulting in ybndrfg8ejkmcpqxot1uwisza345h769, without padding
  • Crockford's Base32: the characters 0123456789ABCDEFGHJKMNPQRSTVWXYZ, i.e., excludes the letters I, L, and O to avoid confusion with digits. It also excludes the letter U. No padding is applied.

Asci85, Z85

Ascii85, also called Base85, is a binary-to-text encoding using five ASCII characters to represent four bytes of binary data (making the encoded size 1⁄4 larger than the original, assuming eight bits per ASCII character). This is more efficient than Base64.

Z85 is a variant of Ascii85 developed by the ZeroMQ project more suitable for embedding binary data in source code, URLs, or JSON without requiring escaping.

Base62

Excluding the characters '+' and '/' from the Base64 alphabet, Base62 uses the 62 upper case and lower case letters as well as the 10 digits to encode binary data.

Base58

It is similar to Base64 but uses a different alphabet and fewer characters. It is more concerned with not confusing letters and digits that are looking similar. So Base58 retains the digit 1 and does not use the lower case letter l or the capital letter I. In mistaking the number 0 with the lower case letter o and the upper case letter O, Base58 keeps the lower case letter o but does not use the digit 0 or the capital letter O.

Base58 is used for Bitcoin addresses, which contain 200 Bit (i.e., 25 Byte) data, but it can be used for any binary data when avoiding confusion between letters and digits is required.

Base52

Base52 encoding is available using a character set of 52 characters, consisting of the 26 lowercase letters (a-z) and 26 uppercase letters (A-Z). Alternatively, there is a character set that excludes vowels to avoid offensive words when encoding but uses the 10 digits.

Number encoding algorithms

Although this library is not that concerned with the encoding of numbers, there are several number encoding algorithms available. Number encoding differs from text encoding in that it is not using arbitrary byte sequences
but encoding bits of the numbers directly.

Base2 through Base36

These number encoding schemes use the digits 0 to 9 and the letters A to Z. The base (also known as latin 'radix') determines the number of unique characters used to represent the numbers. There is the RadixEncoder class that covers all of these bases (radizes).

Base52, Radix52

Base52 exploits using a larger alphabet to encode numbers, resulting in shorter encoding. As there is no commonly used alphabet, the Base52Encoder alphabets are reused.

Base62, Radix62

Base62 uses even more characters. The used alphabet is taken from Base64 text encoding, but the characters '+' and '/' are excluded.

History

1.0.1

Just a documentation update (Readme)

1.0.0

Initial version

  • Base64 (multiple)

  • Base32 (multiple)

  • Ascii85, Z85 (ZeroMq)

Encoders with limited character set

  • Base52
  • Base58
  • Base62

Other elements

  • Base64 and Base32 value types

  • RadixEncoder

  • Nuget

  • Documentation

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 was computed.  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 was computed.  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 was computed.  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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETStandard 2.1

    • 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.1.0 392 12/11/2025
1.0.1 405 12/9/2025
1.0.0 391 12/8/2025

- Initial version
- Readme update