Class Base64Encoding
- Namespace
- LibSodium
- Assembly
- LibSodium.Net.dll
Provides methods for Base64 encoding and decoding.
public static class Base64Encoding
- Inheritance
-
Base64Encoding
- Inherited Members
Methods
Base64ToBin(ReadOnlySpan<char>, Span<byte>, Base64Variant, string?)
Decodes a Base64 string into a binary representation.
public static Span<byte> Base64ToBin(ReadOnlySpan<char> b64, Span<byte> bin, Base64Variant variant, string? ignore = null)
Parameters
b64
ReadOnlySpan<char>The Base64 string to decode as a ReadOnlySpan.
bin
Span<byte>The span to store the decoded binary data.
variant
Base64VariantThe Base64 variant to use.
ignore
stringCharacters to ignore during decoding.
Returns
Base64ToBin(string, Span<byte>, Base64Variant, string?)
Decodes a Base64 string into a binary representation.
public static Span<byte> Base64ToBin(string b64, Span<byte> bin, Base64Variant variant, string? ignore = null)
Parameters
b64
stringThe Base64 string to decode.
bin
Span<byte>The span to store the decoded binary data.
variant
Base64VariantThe Base64 variant to use.
ignore
stringCharacters to ignore during decoding.
Returns
BinToBase64(ReadOnlySpan<byte>, Base64Variant)
Encodes binary data into a Base64 string.
public static string BinToBase64(ReadOnlySpan<byte> bin, Base64Variant variant)
Parameters
bin
ReadOnlySpan<byte>The binary data to encode.
variant
Base64VariantThe Base64 variant to use.
Returns
- string
A Base64 encoded string.
BinToBase64(ReadOnlySpan<byte>, Span<char>, Base64Variant)
Encodes binary data into a Base64 representation and stores it in a character span.
public static Span<char> BinToBase64(ReadOnlySpan<byte> bin, Span<char> b64, Base64Variant variant)
Parameters
bin
ReadOnlySpan<byte>The binary data to encode.
b64
Span<char>The span to store the Base64 encoded data.
variant
Base64VariantThe Base64 variant to use.
Returns
GetBase64DecodedMaxLen(int)
Calculates the maximum length of the decoded binary data from a Base64 string.
public static int GetBase64DecodedMaxLen(int base64Len)
Parameters
base64Len
intThe length of the Base64 string.
Returns
- int
The maximum length of the decoded binary data.
GetBase64EncodedLen(int, Base64Variant, bool)
Calculates the length of the Base64 encoded string for a given binary length.
public static int GetBase64EncodedLen(int binLen, Base64Variant variant, bool includeNullTerminator = true)
Parameters
binLen
intThe length of the binary data.
variant
Base64VariantThe Base64 variant to use.
includeNullTerminator
boolIndicates whether to include a null terminator in the length calculation.
Returns
- int
The length of the Base64 encoded string.