Decode Method
Decode(ReadOnlySpan<Char>, Span<Byte>)
Decode the string into data
.
public void Decode(ReadOnlySpan<char> encoded, Span<byte> data)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Char> | encoded | Encoded text. |
System.Span<System.Byte> | data | A System.Span<> to decode the data to. |
Implements
Remarks
When decoding sensitive data that should not be in an immutable object, this method gives you the ability to decode directly to a char System.Span<>.
The point of this method is to allow you to decode data to a char collection that you own. Therefore, you must allocate this collection before calling this method.
For Base16 and ModHex, it is one character per four bits of information, so two characters per byte.
For Base32, it is more complicated. Each character hold five bits of data. Plus, you must account for padding at the end of the encoded data. There is a method to calculate the space needed called GetDecodedSize(ReadOnlySpan<Char>) that will tell you how many bytes you need.
Decode(String)
Decode the string into a byte array.
public byte[] Decode(string encoded)
Parameters
Type | Name | Description |
---|---|---|
System.String | encoded | A string encoded with data to be decoded. |
Returns
A byte collection resulting from decoding encoded
.