### Install SimpleBase via NuGet Source: https://github.com/ssg/simplebase/blob/main/README.md This command installs the SimpleBase NuGet package into your .NET project, making its encoding and decoding functionalities available for use. ```nuget Install-Package SimpleBase ``` -------------------------------- ### TryEncode/TryDecode with Pre-allocated Buffers Source: https://github.com/ssg/simplebase/wiki/Home Demonstrates using `TryEncode` and `TryDecode` methods to encode/decode data into pre-allocated buffers, avoiding GC allocations. Includes examples for Base58 encoding and decoding with buffer size calculation. ```csharp byte[] input = [1, 2, 3, 4, 5]; int outputBufferSize = Base58.Bitcoin.GetSafeCharCountForEncoding(input); var output = new char[outputBufferSize]; if (Base58.Bitcoin.TryEncode(input, output, out int numCharsWritten)) { // there you go } ``` ```csharp string input = "... some bitcoin address ..."; int outputBufferSize = Base58.Bitcoin.GetSafeByteCountForDecoding(output); var output = new byte[outputBufferSize]; if (Base58.Bitcoin.TryDecode(input, output, out int bytesWritten)) { // et voila! } ``` -------------------------------- ### Base85 Encoding and Decoding Source: https://github.com/ssg/simplebase/wiki/Home Provides examples for encoding byte arrays to Ascii85 strings and decoding Ascii85 strings back to byte arrays. Supports Ascii85 and Z85 flavors, including 'zero' and 'space' shortcuts for Ascii85. ```csharp byte[] myBuffer = ... string result = Base85.Ascii85.Encode(myBuffer); // you can also use Z85 as a flavor ``` ```csharp string encodedString = ... byte[] result = Base85.Ascii85.Decode(encodedString); ``` -------------------------------- ### Base32 Encoding Example (Crockford) Source: https://github.com/ssg/simplebase/blob/main/README.md Demonstrates how to encode a byte buffer into a Base32 string using the Crockford alphabet with padding enabled. This snippet shows the basic usage pattern for encoding with SimpleBase. ```csharp using SimpleBase; byte[] myBuffer; string result = Base32.Crockford.Encode(myBuffer, padding: true); // you can also use "ExtendedHex" or "Rfc4648" as encoder flavors ``` -------------------------------- ### Asynchronous Stream Mode Encoding/Decoding Source: https://github.com/ssg/simplebase/wiki/Home Shows how to perform asynchronous encoding and decoding operations on streams, suitable for non-blocking I/O. Examples cover asynchronous Base85 encoding and Base32 decoding. ```csharp using (var input = File.Open("somefile.bin")) using (var output = File.Create("somefile.ascii85")) using (var writer = new TextWriter(output)) // you can specify encoding here { await Base85.Ascii85.EncodeAsync(input, writer); } ``` ```csharp using (var input = File.Open("somefile.b32")) using (var output = File.Create("somefile.bin")) using (var reader = new TextReader(input)) // specify encoding here { await Base32.Crockford.DecodeAsync(reader, output); } ``` -------------------------------- ### Base32 Decoding Example (Crockford) Source: https://github.com/ssg/simplebase/blob/main/README.md Illustrates how to decode a Base32 encoded string back into a byte array using the Crockford alphabet. This snippet shows the basic usage pattern for decoding with SimpleBase. ```csharp using SimpleBase; string myText = ...; byte[] result = Base32.Crockford.Decode(myText); ``` -------------------------------- ### Stream Mode Encoding/Decoding Source: https://github.com/ssg/simplebase/wiki/Home Illustrates using stream modes for encoding and decoding large data without consuming excessive memory. Examples show file-to-file encoding with Base85 and file decoding with Base32, using TextReader/TextWriter. ```csharp using (var input = File.Open("somefile.bin")) using (var output = File.Create("somefile.ascii85")) using (var writer = new TextWriter(output)) // you can specify encoding here { Base85.Ascii85.Encode(input, writer); } ``` ```csharp using (var input = File.Open("somefile.b32")) using (var output = File.Create("somefile.bin")) using (var reader = new TextReader(input)) // specify encoding here { Base32.Crockford.Decode(reader, output); } ``` -------------------------------- ### Get Base62Alphabet Length Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base62alphabet.md Gets the total number of characters in the Base62 alphabet. This property is useful for understanding the radix of the encoding scheme. ```csharp public int Length { get; } ``` -------------------------------- ### Get Base62Alphabet Value Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base62alphabet.md Gets the string representation of the Base62 alphabet characters. This property exposes the actual characters used for encoding and decoding. ```csharp public string Value { get; } ``` -------------------------------- ### CodingAlphabet Constructor Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.codingalphabet.md Initializes a new instance of the CodingAlphabet class. It requires an integer for the length and a string for the alphabet characters. ```csharp public CodingAlphabet(int length, string alphabet) ``` -------------------------------- ### CodingAlphabet Properties Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.codingalphabet.md Details the properties of the CodingAlphabet class: Length (gets the alphabet's length) and Value (gets the alphabet's characters). Both properties have private setters, indicating they are set during initialization. ```csharp public int Length { get; private set; } ``` ```csharp public string Value { get; private set; } ``` -------------------------------- ### Base45 Constructor Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base45.md Initializes a new instance of the Base45 class with a specified alphabet. ```APIDOC Base45 Constructor public Base45(Base45Alphabet alphabet) Parameters: alphabet: Base45Alphabet - The alphabet to use for encoding and decoding. ``` -------------------------------- ### Base16 Alphabet Property Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base16.md Gets the alphabet used by the Base16 encoder. ```csharp public Base16Alphabet Alphabet { get; } ``` -------------------------------- ### Base16 UpperCase Property Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base16.md Gets the static upper case Base16 encoder instance. ```csharp public static Base16 UpperCase { get; } ``` -------------------------------- ### MoneroBase58 API Reference Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.monerobase58.md Provides a comprehensive reference for the MoneroBase58 class methods and properties, detailing their functionality, parameters, and return values. ```APIDOC MoneroBase58: Description: Monero variant of Base58 Encoding/Decoding algorithm. Encodes using 8-byte blocks into 11-byte blocks, making it less algorithmically complex than byte-by-byte methods. Pads with encoded zeroes ('1') if block size is less than 11 bytes. Inheritance: Object -> MoneroBase58 Implements: IBaseCoder, INonAllocatingBaseCoder Properties: Alphabet: Base58Alphabet Gets the encoding alphabet. Returns the Base58Alphabet used for encoding/decoding. ZeroChar: char Gets the character representing zero in the Base58 alphabet. Constructors: MoneroBase58(Base58Alphabet alphabet) Monero variant of Base58 Encoding/Decoding algorithm. Allows specifying a custom alphabet. Parameters: alphabet [Base58Alphabet]: An optional custom alphabet to use. Defaults to Bitcoin alphabet. MoneroBase58() Initializes a new instance of the MoneroBase58 class with the default alphabet. Methods: GetSafeByteCountForDecoding(ReadOnlySpan text) -> int Calculates the safe byte count required for decoding a Base58 string. Parameters: text [ReadOnlySpan]: The Base58 encoded string to analyze. Returns: The estimated byte count for the decoded data. GetSafeCharCountForEncoding(ReadOnlySpan bytes) -> int Calculates the safe character count required for encoding a byte array into Base58. Parameters: bytes [ReadOnlySpan]: The byte array to encode. Returns: The estimated character count for the Base58 encoded string. Encode(ReadOnlySpan bytes) -> string Encodes a byte array into its Base58 string representation. Parameters: bytes [ReadOnlySpan]: The bytes to encode. Returns: The Base58 encoded string. Decode(ReadOnlySpan text) -> byte[] Decodes a Base58 encoded string back into a byte array. Parameters: text [ReadOnlySpan]: The Base58 encoded text to decode. Returns: The decoded byte array. TryEncode(ReadOnlySpan input, Span output, out int numCharsWritten) -> bool Attempts to encode a byte span into a character span without allocating. Parameters: input [ReadOnlySpan]: The bytes to encode. output [Span]: The span to write the encoded characters into. numCharsWritten [out int]: The number of characters written to the output span. Returns: True if the encoding was successful, false otherwise (e.g., output span too small). TryDecode(ReadOnlySpan input, Span output, out int bytesWritten) -> bool Attempts to decode a character span (Base58 string) into a byte span without allocating. Parameters: input [ReadOnlySpan]: The Base58 encoded text to decode. output [Span]: The span to write the decoded bytes into. bytesWritten [out int]: The number of bytes written to the output span. Returns: True if the decoding was successful, false otherwise (e.g., output span too small or invalid input). ``` -------------------------------- ### Base16 LowerCase Property Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base16.md Gets the static lower case Base16 encoder instance. ```csharp public static Base16 LowerCase { get; } ``` -------------------------------- ### Base85Alphabet Class Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base85alphabet.md Documentation for the Base85Alphabet class, including its properties and constructors. ```APIDOC Base85Alphabet Class Documentation: Class Signature: public sealed class Base85Alphabet : CodingAlphabet, ICodingAlphabet - Represents a Base85 alphabet, supporting custom settings and providing predefined alphabets like Z85, Ascii85, and RFC1924. Properties: - Z85: Gets ZeroMQ Z85 Alphabet. - Returns: Base85Alphabet - Ascii85: Gets Adobe Ascii85 Alphabet (each character is directly produced by raw value + 33), also known as "btoa" encoding. - Returns: Base85Alphabet - Rfc1924: Gets Base85 encoding defined in RFC 1924. - Returns: Base85Alphabet - AllZeroShortcut: Gets the character to be used for "all zeros". - Returns: Nullable - AllSpaceShortcut: Gets the character to be used for "all spaces". - Returns: Nullable - HasShortcut: Gets a value indicating whether the alphabet uses one of shortcut characters for all spaces or all zeros. - Returns: bool - Length: Gets the length of the alphabet. - Returns: int - Value: Gets the characters of the alphabet. - Returns: string Constructors: - Base85Alphabet(string alphabet, Nullable allZeroShortcut, Nullable allSpaceShortcut) - Description: Initializes a new instance of the Base85Alphabet class using custom settings. - Parameters: - alphabet: string - Alphabet to use. - allZeroShortcut: Nullable - Character to substitute for all zero. - allSpaceShortcut: Nullable - Character to substitute for all space. ``` -------------------------------- ### SimpleBase Base32 Class API Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base32.md API documentation for the Base32 class, detailing its properties, constructors, and methods for Base32 encoding and decoding. Includes support for various Base32 variants like Crockford, RFC4648, Bech32, and more. ```APIDOC Base32 Class Documentation Namespace: SimpleBase Provides Base32 encoding and decoding functionality. Class Signature: public sealed class Base32 : IBaseCoder, IBaseStreamCoder, INonAllocatingBaseCoder, INumericBaseCoder Properties: - Crockford: Base32 Gets Douglas Crockford's Base32 flavor with substitution characters. - Rfc4648: Base32 Gets RFC 4648 variant of Base32 coder. - ExtendedHex: Base32 Gets Extended Hex variant of Base32 coder (RFC 4648). - ExtendedHexLower: Base32 Gets Extended Hex variant of Base32 coder (RFC 4648, lowercase). - ZBase32: Base32 Gets z-base-32 variant of Base32 coder. Used in Mnet, ZRTP and Tahoe-LAFS. - Geohash: Base32 Gets Geohash variant of Base32 coder. - Bech32: Base32 Gets Bech32 variant of Base32 coder. - FileCoin: Base32 Gets FileCoin variant of Base32 coder. Also known as RFC 4648 lowercase. - Alphabet: Base32Alphabet Gets the encoding alphabet used by this Base32 instance. Constructors: - Base32(Base32Alphabet alphabet) Initializes a new instance of the Base32 class with a custom alphabet. Parameters: alphabet [Base32Alphabet]: The alphabet to use for encoding/decoding. Methods: - GetSafeByteCountForDecoding(ReadOnlySpan text): int Calculates the safe byte count required for decoding a Base32 string. Parameters: text [ReadOnlySpan]: The Base32 encoded string. Returns: [int]: The number of bytes required for decoding. - GetSafeCharCountForEncoding(ReadOnlySpan buffer): int Calculates the safe character count required for encoding a byte buffer into Base32. Parameters: buffer [ReadOnlySpan]: The byte buffer to encode. Returns: [int]: The number of characters required for encoding. - Encode(long number): string Encodes a 64-bit signed integer into its Base32 string representation. Parameters: number [long]: The integer to encode. Returns: [string]: The Base32 encoded string. - Encode(ulong number): string Encodes a 64-bit unsigned integer into its Base32 string representation. Parameters: number [ulong]: The unsigned integer to encode. Returns: [string]: The Base32 encoded string. - DecodeUInt64(string text): ulong Decodes a Base32 encoded string into a 64-bit unsigned integer. Parameters: text [string]: The Base32 encoded string. Returns: [ulong]: The decoded unsigned integer. - TryDecodeUInt64(string text, out ulong number): bool Attempts to decode a Base32 encoded string into a 64-bit unsigned integer. Parameters: text [string]: The Base32 encoded string. number [out ulong]: When this method returns, contains the decoded unsigned integer, if the conversion succeeded. Returns: [bool]: true if the string was decoded successfully; otherwise, false. - DecodeInt64(string text): long Decodes a Base32 encoded string into a 64-bit signed integer. Parameters: text [string]: The Base32 encoded string. Returns: [long]: The decoded signed integer. ``` -------------------------------- ### Base16 ModHex Property Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base16.md Gets the static ModHex (lower case) Base16 encoder instance. ```csharp public static Base16 ModHex { get; } ``` -------------------------------- ### Base36Alphabet Value Property (C#) Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base36alphabet.md Gets the string representation of the Base36 alphabet characters. This is a read-only string property. ```csharp public string Value { get; } ``` -------------------------------- ### Base16 Constructor Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base16.md Initializes a new instance of the Base16 class with a specified alphabet. ```csharp public Base16(Base16Alphabet alphabet) ``` -------------------------------- ### Base36Alphabet Length Property (C#) Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base36alphabet.md Gets the total number of characters in the Base36 alphabet. This is a read-only integer property. ```csharp public int Length { get; } ``` -------------------------------- ### Base32 Encoding and Decoding Source: https://github.com/ssg/simplebase/wiki/Home Demonstrates encoding byte arrays to Base32 strings and decoding Base32 strings back to byte arrays using SimpleBase. Supports Crockford, ExtendedHex, and Rfc4648 flavors with optional padding. ```csharp using SimpleBase; byte[] myBuffer; string result = Base32.Crockford.Encode(myBuffer, padding: true); // you can also use "ExtendedHex" or "Rfc4648" as encoder flavors ``` ```csharp using SimpleBase; string myText = ... byte[] result = Base32.Crockford.Decode(myText); ``` -------------------------------- ### DividingCoder Alphabet Property Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.dividingcoder-1.md Gets the alphabet used by the encoder/decoder. This property is read-only and is set during the construction of the DividingCoder instance. ```csharp public TAlphabet Alphabet { get; } ``` -------------------------------- ### Base45Alphabet Constructor - C# Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base45alphabet.md Initializes a new instance of the Base45Alphabet class with a custom alphabet string. This allows for creating alphabets with different character sets. ```csharp public Base45Alphabet(string alphabet) ``` -------------------------------- ### Get Default Base62Alphabet Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base62alphabet.md Retrieves the standard, most common Base62 alphabet. This property provides access to a pre-defined, widely used alphabet for Base62 encoding. ```csharp public static Base62Alphabet Default { get; } ``` -------------------------------- ### Initialize SimpleBase CodingAlphabet Source: https://github.com/ssg/simplebase/blob/main/src/PublicAPI.Shipped.txt This constructor initializes the CodingAlphabet class. It requires a length for the alphabet and the alphabet string itself. An optional boolean parameter controls case sensitivity. ```C# SimpleBase.CodingAlphabet.CodingAlphabet(int length, string! alphabet, bool caseInsensitive = false) -> void ``` -------------------------------- ### Get Alternative Base62Alphabet Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base62alphabet.md Retrieves an alternative Base62 alphabet. This property offers a different set of characters for Base62 encoding, potentially for specific use cases. ```csharp public static Base62Alphabet Alternative { get; } ``` -------------------------------- ### Base58 Encoding and Decoding Source: https://github.com/ssg/simplebase/wiki/Home Shows how to encode byte arrays to Base58 strings and decode Base58 strings to byte arrays using SimpleBase. Supports Bitcoin, Ripple, and Flickr flavors. ```csharp byte[] myBuffer = ... string result = Base58.Bitcoin.Encode(myBuffer); // you can also use "Ripple" or "Flickr" as encoder flavors ``` ```csharp string myText = ... byte[] result = Base58.Bitcoin.Decode(myText); ``` -------------------------------- ### PaddingPosition Enum Definition Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.paddingposition.md Defines the position of padding within an encoder output. This C# enum specifies whether padding is applied at the start or end of the encoded buffer. ```csharp public enum PaddingPosition { Start = 0, // Padding appears at the start of the encoded buffer. End = 1 // Padding appears at the end of the buffer. } ``` -------------------------------- ### Base45Alphabet Length Property - C# Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base45alphabet.md Gets the total number of characters in the Base45 alphabet. This property indicates the size of the character set used for encoding and decoding. ```csharp public int Length { get; } ``` -------------------------------- ### Base85 Constructor Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base85.md Defines the constructor for the Base85 class, allowing initialization with a custom Base85Alphabet. This enables flexible configuration of the encoding/decoding process. ```APIDOC Constructor: Base85(Base85Alphabet alphabet) Description: Initializes a new instance of the Base85 class using a custom alphabet. Parameters: alphabet [Base85Alphabet]: Alphabet to use. ``` -------------------------------- ### SimpleBase.Base36 API Documentation Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base36.md Documentation for the Base36 class, which implements Base36 encoding and decoding. It provides static properties for uppercase and lowercase encoders, and allows initialization with a custom alphabet. Remarks indicate limitations regarding stream-based operations. ```APIDOC SimpleBase.Base36 Class Documentation: Description: Base36 Encoding/Decoding implementation. Inheritance: [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [DividingCoder<Base36Alphabet>](./simplebase.dividingcoder-1.md) → [Base36](./simplebase.base36.md) Implements: [IBaseCoder](./simplebase.ibasecoder.md), [INonAllocatingBaseCoder](./simplebase.inonallocatingbasecoder.md) Attributes: [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) Remarks: Base36 doesn't implement a Stream-based interface because it's not feasible to use on large buffers. Properties: UpperCase: Signature: public static Base36 UpperCase { get; } Description: Gets the uppercase Base36 encoder. Return Value: [Base36](./simplebase.base36.md) LowerCase: Signature: public static Base36 LowerCase { get; } Description: Gets the lowercase Base36 encoder. Return Value: [Base36](./simplebase.base36.md) Alphabet: Signature: public Base36Alphabet Alphabet { get; } Description: Gets the encoding alphabet. Return Value: [Base36Alphabet](./simplebase.base36alphabet.md) Constructors: Base36(Base36Alphabet alphabet): Signature: public Base36(Base36Alphabet alphabet) Description: Base36 Encoding/Decoding implementation. Parameters: alphabet [Base36Alphabet](./simplebase.base36alphabet.md): Alphabet to use. Remarks: Base36 doesn't implement a Stream-based interface because it's not feasible to use on large buffers. ``` -------------------------------- ### Base36Alphabet Constructor (C#) Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base36alphabet.md Initializes a new instance of the Base36Alphabet class with a specified alphabet string. This constructor takes one string parameter. ```csharp public Base36Alphabet(string alphabet) ``` -------------------------------- ### Base85 Class Overview Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base85.md Provides an overview of the Base85 class, its inheritance, interfaces, and attributes. It serves as the main entry point for Base85 encoding and decoding operations. ```APIDOC Namespace: SimpleBase Class: Base85 Description: Base85 encoding/decoding class. Inheritance: Object → Base85 Implements: IBaseCoder, IBaseStreamCoder, INonAllocatingBaseCoder Attributes: NullableContextAttribute, NullableAttribute Remarks: Initializes a new instance of the Base85 class using a custom alphabet. ``` -------------------------------- ### Base58Check Encoding and Decoding Source: https://github.com/ssg/simplebase/wiki/Home Demonstrates encoding and decoding Base58Check addresses, including versioning for P2PKH addresses. Uses `EncodeCheck` and `TryDecodeCheck` methods for robust address handling. ```csharp byte[] address = ... byte version = 1; // P2PKH address string result = Base58.Bitcoin.EncodeCheck(address, version); ``` ```csharp string address = ... Span buffer = new byte[maxAddressLength]; if (Base58.Bitcoin.TryDecodeCheck(address, buffer, out byte version, out int bytesWritten)); buffer = buffer[..bytesWritten]; // use only the written portion of the buffer ``` -------------------------------- ### IBaseCoder API Documentation Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.ibasecoder.md API reference for the IBaseCoder interface, detailing its encoding and decoding methods, parameters, and return types. ```APIDOC IBaseCoder: Interface for basic encoding and decoding operations. Encode(ReadOnlySpan bytes): string Encodes a buffer to a base-encoded representation. Parameters: bytes: ReadOnlySpan - Bytes to encode. Returns: string - Base16 string. Decode(ReadOnlySpan text): Byte[] Decodes base-encoded text into bytes. Parameters: text: ReadOnlySpan - Base16 text. Returns: Byte[] - Decoded bytes. ``` -------------------------------- ### Base32Alphabet Constructors Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base32alphabet.md Provides constructors for creating `Base32Alphabet` instances. One constructor takes only the alphabet string, while another allows specifying the alphabet, padding character, and padding position. ```csharp public Base32Alphabet(string alphabet) // Initializes a new instance of the Base32Alphabet class with the specified alphabet characters. // Parameters: // alphabet [String]: The characters to use for the encoding alphabet. public Base32Alphabet(string alphabet, char paddingChar, PaddingPosition paddingPosition) // Initializes a new instance of the Base32Alphabet class with the specified alphabet, padding character, and padding position. // Parameters: // alphabet [String]: The encoding alphabet to use. // paddingChar [Char]: The padding character to use. // paddingPosition [PaddingPosition]: The position of the padding characters in the encoder output. ``` -------------------------------- ### Base85IPv6 Class and IPv6 Methods Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base85ipv6.md Documentation for the Base85IPv6 class, including its constructor, properties, and methods for encoding and decoding IPv6 addresses using RFC 1924 Base85. ```APIDOC SimpleBase.Base85IPv6 Class Namespace: SimpleBase Inheritance: Object -> Base85 -> Base85IPv6 Implements: IBaseCoder, IBaseStreamCoder, INonAllocatingBaseCoder Attributes: NullableContextAttribute, NullableAttribute Remarks: RFC 1924 sucks, arguably because it's a very early proposal in the history of IPv6: - It contains special chars: It's prone to be confused with other syntactical elements. It can even cause security issues due to poor escaping, let alone UX problems. - Length gains are usually marginal: IPv6 uses zero elimination to reduce the address representation. - Slow. The algorithm is division based, instead of faster bitwise operations. So, that's why I only included a proof of concept implementation instead of working on optimizing it. RFC 1924 should die, and this code should only be used to support some obscure standard or code somewhere. Properties: Alphabet Gets the encoding alphabet. Signature: public Base85Alphabet Alphabet { get; } Return Value: Base85Alphabet - The encoding alphabet. Constructors: Base85IPv6(Base85Alphabet alphabet) Base85 implementation with additional IPv6 coding functions. Parameters: alphabet: Base85Alphabet - Coding alphabet. Methods: EncodeIPv6(IPAddress ip) Encode IPv6 address into RFC 1924 Base85 text. Parameters: ip: IPAddress - IPv6 address. Returns: string - Encoded text. DecodeIPv6(string text) Decode an RFC 1924 encoded text into an IPv6 address. Parameters: text: string - Encoded text. Returns: IPAddress - Decoded IPv6 address. TryDecodeIPv6(string text, IPAddress& ip) Try decoding an RFC 1924 encoded text into an IPv6 address. Parameters: text: string - Encoded text. ip: IPAddress& - Resulting IPv6 address. Returns: bool - True if successful, false otherwise. ``` -------------------------------- ### Create Base62Alphabet with Custom String Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base62alphabet.md Initializes a new instance of the Base62Alphabet class using a custom alphabet string. This allows for flexibility in defining the character set for encoding. ```csharp public Base62Alphabet(string alphabet) ``` -------------------------------- ### Base58 Flavors and Properties Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base58.md Provides static properties for accessing different Base58 encoding flavors (Bitcoin, Ripple, Flickr, Monero) and configuration details like the encoding alphabet and the character representing zero. The Monero flavor uses a distinct algorithm. ```csharp public static Base58 Bitcoin { get; } public static Base58 Ripple { get; } public static Base58 Flickr { get; } public static MoneroBase58 Monero { get; } public Base58Alphabet Alphabet { get; } public char ZeroChar { get; } ``` -------------------------------- ### Avalanche CB58 Encoding and Decoding Source: https://github.com/ssg/simplebase/wiki/Home Illustrates encoding and decoding Avalanche CB58 addresses, which do not have a separate version field. Uses `EncodeCb58` and `TryDecodeCb58` methods. ```csharp byte[] address = ... byte version = 1; string result = Base58.Bitcoin.EncodeCb58(address); ``` ```csharp string address = ... Span buffer = new byte[maxAddressLength]; if (Base58.Bitcoin.TryDecodeCb58(address, buffer, out int bytesWritten)); buffer = buffer[..bytesWritten]; // use only the written portion of the buffer ``` -------------------------------- ### Base85 Alphabet Configuration Source: https://github.com/ssg/simplebase/blob/main/src/PublicAPI.Shipped.txt Defines configurations for Base85 alphabets, including custom alphabets and optional shortcuts for all-zero or all-space sequences. ```APIDOC SimpleBase.Base85Alphabet: Base85Alphabet(string alphabet, char? allZeroShortcut = null, char? allSpaceShortcut = null) Constructs a new Base85 alphabet with optional shortcuts. Parameters: alphabet: The string defining the 85 characters used for encoding. allZeroShortcut: An optional character to represent sequences of zeros. allSpaceShortcut: An optional character to represent sequences of spaces. AllSpaceShortcut.get -> char? Gets the shortcut character for all-space sequences, if defined. AllZeroShortcut.get -> char? Gets the shortcut character for all-zero sequences, if defined. HasShortcut.get -> bool Indicates whether the alphabet has any defined shortcuts. ``` -------------------------------- ### TryEncode Methods Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base32.md Provides methods for encoding byte spans into character spans. The overloads allow for specifying whether to use padding characters. ```csharp public bool TryEncode(ReadOnlySpan bytes, Span output, Int32& numCharsWritten) { // Implementation details... return false; } ``` ```csharp public bool TryEncode(ReadOnlySpan bytes, Span output, bool padding, Int32& numCharsWritten) { // Implementation details... return false; } ``` -------------------------------- ### Base16 ToString Method Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base16.md Returns a string representation of the Base16 instance. ```csharp public string ToString() ``` -------------------------------- ### Base58 Encoding/Decoding Variants Source: https://github.com/ssg/simplebase/blob/main/src/PublicAPI.Shipped.txt Provides static access to common Base58 encoding schemes like Bitcoin and Flickr, along with a utility for calculating safe buffer sizes. ```APIDOC SimpleBase.Base58: Bitcoin.get -> SimpleBase.Base58 Gets a Base58 encoder/decoder for the Bitcoin standard. Flickr.get -> SimpleBase.Base58 Gets a Base58 encoder/decoder for the Flickr standard. Ripple.get -> SimpleBase.Base58 Gets a Base58 encoder/decoder for the Ripple standard. GetSafeByteCountForDecoding(int textLen, int numZeroes) -> int Calculates the required byte buffer size for decoding Base58, considering leading zeros. SimpleBase.Base58Alphabet: Bitcoin.get -> SimpleBase.Base58Alphabet Gets the Bitcoin Base58 alphabet. Flickr.get -> SimpleBase.Base58Alphabet Gets the Flickr Base58 alphabet. Ripple.get -> SimpleBase.Base58Alphabet Gets the Ripple Base58 alphabet. ``` -------------------------------- ### Base58Alphabet Class API - SimpleBase Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.base58alphabet.md API documentation for the SimpleBase Base58Alphabet class, detailing its properties like Bitcoin, Ripple, Flickr, Length, Value, and its constructor for custom alphabet initialization. ```csharp Base58Alphabet Class API - SimpleBase Namespace: SimpleBase Language: C# Description: Represents a Base58 alphabet, implementing ICodingAlphabet. This class provides static properties for common Base58 alphabets like Bitcoin and Ripple, as well as properties to access the alphabet's length and characters. Inheritance: Object -> CodingAlphabet -> Base58Alphabet Implements: ICodingAlphabet Attributes: NullableContextAttribute, NullableAttribute Properties: - Bitcoin: Base58Alphabet Gets the Bitcoin alphabet. Monero also uses this alphabet but only works with MoneroBase58 encoding. Returns: Base58Alphabet - Ripple: Base58Alphabet Gets the Ripple alphabet. Returns: Base58Alphabet - Flickr: Base58Alphabet Gets the Flickr alphabet. Returns: Base58Alphabet - Length: int Gets the length of the alphabet. Returns: int - Value: string Gets the characters of the alphabet. Returns: string Constructors: - Base58Alphabet(string alphabet) Initializes a new instance of the Base58Alphabet class using a custom alphabet. Parameters: alphabet (string): The alphabet to use. Returns: void ``` -------------------------------- ### Base16 Encoding and Decoding Source: https://github.com/ssg/simplebase/wiki/Home Demonstrates encoding byte arrays to hexadecimal strings (uppercase or lowercase) and decoding hex strings back to byte arrays. The decode method handles both cases. ```csharp byte[] myBuffer = ... string result = Base16.EncodeUpper(myBuffer); // encode to uppercase // or string result = Base16.EncodeLower(myBuffer); // encode to lowercase ``` ```csharp string text = ... byte[] result = Base16.Decode(text); // decodes both upper and lowercase ``` -------------------------------- ### CodingAlphabet ToString Method Source: https://github.com/ssg/simplebase/blob/main/docs/simplebase.codingalphabet.md Provides the string representation of the encoding alphabet. This method returns the characters that make up the alphabet. ```csharp public string ToString() ``` -------------------------------- ### Base58 Monero Accessor Source: https://github.com/ssg/simplebase/blob/main/src/PublicAPI.Shipped.txt Provides access to the Monero-specific Base58 implementation. ```APIDOC SimpleBase.Base58 static Monero.get -> SimpleBase.MoneroBase58! Gets an instance of the Monero Base58 encoder/decoder. ``` -------------------------------- ### SimpleBase Base45 Encoding Source: https://github.com/ssg/simplebase/blob/main/src/PublicAPI.Shipped.txt Provides access to the Base45 encoding implementation, typically via a default instance. ```APIDOC SimpleBase.Base45: Default.get -> SimpleBase.Base45! Provides a default instance of the Base45 encoder/decoder. ``` -------------------------------- ### Base32 Decoding (UInt64) Source: https://github.com/ssg/simplebase/blob/main/src/PublicAPI.Shipped.txt Specific method for decoding Base32 strings into unsigned 64-bit integers. ```APIDOC SimpleBase.Base32 TryDecodeUInt64(string! text, out ulong number) -> bool Attempts to decode a Base32 encoded string into an unsigned 64-bit integer. Parameters: text: The Base32 encoded string. number: Output parameter for the decoded ulong value. Returns: True if decoding was successful, false otherwise. ``` -------------------------------- ### Base32 and Base32Alphabet Accessors Source: https://github.com/ssg/simplebase/blob/main/src/PublicAPI.Shipped.txt Provides access to specific Base32 implementations and their corresponding alphabets. ```APIDOC SimpleBase.Base32 static ExtendedHexLower.get -> SimpleBase.Base32! Gets an instance of the Base32 encoder/decoder using the Extended Hex Lowercase alphabet. SimpleBase.Base32Alphabet static ExtendedHexLower.get -> SimpleBase.Base32Alphabet! Gets the Base32 alphabet for Extended Hex Lowercase. ``` -------------------------------- ### Monero Base58 Encoding and Decoding Source: https://github.com/ssg/simplebase/blob/main/src/PublicAPI.Shipped.txt Provides methods for encoding and decoding data using the Monero Base58 alphabet. Includes functions for safe byte count estimation and direct decoding/encoding operations. ```APIDOC SimpleBase.MoneroBase58 MoneroBase58() Constructs a MoneroBase58 encoder/decoder with the default alphabet. MoneroBase58(SimpleBase.Base58Alphabet! alphabet) Constructs a MoneroBase58 encoder/decoder with a custom alphabet. Parameters: alphabet: The Base58 alphabet to use. Alphabet.get -> SimpleBase.Base58Alphabet! Gets the default Base58 alphabet used by Monero. Decode(System.ReadOnlySpan text) -> byte[]! Decodes a Base58 encoded string into a byte array. Parameters: text: The Base58 encoded string to decode. Returns: The decoded byte array. Encode(System.ReadOnlySpan bytes) -> string! Encodes a byte array into a Base58 string. Parameters: bytes: The byte array to encode. Returns: The Base58 encoded string. GetSafeByteCountForDecoding(System.ReadOnlySpan text) -> int Calculates the maximum safe size for the output byte array when decoding. Parameters: text: The Base58 encoded string. Returns: The estimated safe byte count. GetSafeCharCountForEncoding(System.ReadOnlySpan bytes) -> int Calculates the maximum safe size for the output character array when encoding. Parameters: bytes: The byte array to encode. Returns: The estimated safe character count. TryDecode(System.ReadOnlySpan input, System.Span output, out int bytesWritten) -> bool Attempts to decode a Base58 string into a byte span, writing the result to the output span. Parameters: input: The Base58 encoded string to decode. output: The span to write the decoded bytes into. bytesWritten: Output parameter indicating the number of bytes written to the output span. Returns: True if decoding was successful, false otherwise. TryEncode(System.ReadOnlySpan input, System.Span output, out int numCharsWritten) -> bool Attempts to encode a byte span into a Base58 string, writing the result to the output span. Parameters: input: The byte span to encode. output: The span to write the encoded characters into. numCharsWritten: Output parameter indicating the number of characters written to the output span. Returns: True if encoding was successful, false otherwise. ZeroChar.get -> char Gets the character used to represent zero in the Monero Base58 alphabet. ```