Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Buffers.​Text.​Base64Url

Assembly: System.Runtime

Inheritance: object → Base64Url

Converts between binary data and URL-safe ASCII encoded text that's represented in Base64Url characters.

Methods

public static byte[]
DecodeFromChars​(ReadOnlySpan<​char> source)
Decodes the span of unicode ASCII chars represented as Base64Url into binary data.
Returns A byte array which contains the result of the decoding operation.
source The input span which contains ASCII chars in Base64Url that needs to be decoded.
public static int
DecodeFromChars​(ReadOnlySpan<​char> source, Span<​byte> destination)
Decodes the span of unicode ASCII chars represented as Base64Url into binary data.
Returns The number of bytes written into the output span. This can be used to slice the output for subsequent calls, if necessary.
source The input span which contains ASCII chars in Base64Url that needs to be decoded.
destination The output span which contains the result of the operation, i.e. the decoded binary data.
public static OperationStatus
DecodeFromChars​(ReadOnlySpan<​char> source, Span<​byte> destination, Int32& charsConsumed, Int32& bytesWritten, bool isFinalBlock = true)
public static byte[]
DecodeFromUtf8​(ReadOnlySpan<​byte> source)
Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.
Returns &gt;A byte array which contains the result of the decoding operation.
source The input span which contains UTF-8 encoded text in Base64Url that needs to be decoded.
public static int
DecodeFromUtf8​(ReadOnlySpan<​byte> source, Span<​byte> destination)
Decodes the span of UTF-8 encoded text represented as Base64Url into binary data.
Returns The number of bytes written into <paramref name="destination" /> . This can be used to slice the output for subsequent calls, if necessary.
source The input span which contains UTF-8 encoded text in Base64Url that needs to be decoded.
destination The output span which contains the result of the operation, i.e. the decoded binary data.
public static OperationStatus
DecodeFromUtf8​(ReadOnlySpan<​byte> source, Span<​byte> destination, Int32& bytesConsumed, Int32& bytesWritten, bool isFinalBlock = true)
public static int
DecodeFromUtf8InPlace​(Span<​byte> buffer)
<para>Decodes the span of UTF-8 encoded text in Base64Url into binary data, in-place.</para> <para>The decoded binary output is smaller than the text data contained in the input (the operation deflates the data).</para>
Returns The number of bytes written into <paramref name="buffer" /> . This can be used to slice the output for subsequent calls, if necessary.
buffer The input span which contains the base 64 text data that needs to be decoded.
public static char[]
EncodeToChars​(ReadOnlySpan<​byte> source)
Encodes the span of binary data into unicode ASCII chars represented as Base64Url.
Returns A char array which contains the result of the operation, i.e. the ASCII chars in Base64Url.
source The input span which contains binary data that needs to be encoded.
public static int
EncodeToChars​(ReadOnlySpan<​byte> source, Span<​char> destination)
Encodes the span of binary data into Unicode ASCII chars represented as Base64Url.
Returns The number of bytes written into the destination span. This can be used to slice the output for subsequent calls, if necessary.
source The input span which contains binary data that needs to be encoded.
destination The output span which contains the result of the operation, i.e. the ASCII chars in Base64Url.
public static OperationStatus
EncodeToChars​(ReadOnlySpan<​byte> source, Span<​char> destination, Int32& bytesConsumed, Int32& charsWritten, bool isFinalBlock = true)
public static string
EncodeToString​(ReadOnlySpan<​byte> source)
Encodes the span of binary data into Unicode string represented as Base64Url ASCII chars.
Returns A string that contains the result of the operation, i.e. the ASCII string in Base64Url.
source The input span that contains binary data that needs to be encoded.
public static byte[]
EncodeToUtf8​(ReadOnlySpan<​byte> source)
Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.
Returns The output byte array which contains the result of the operation, i.e. the UTF-8 encoded text in Base64Url.
source The input span which contains binary data that needs to be encoded.
public static int
EncodeToUtf8​(ReadOnlySpan<​byte> source, Span<​byte> destination)
Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.
Returns The number of bytes written into the destination span. This can be used to slice the output for subsequent calls, if necessary.
source The input span which contains binary data that needs to be encoded.
destination The output span which contains the result of the operation, i.e. the UTF-8 encoded text in Base64Url.
public static OperationStatus
EncodeToUtf8​(ReadOnlySpan<​byte> source, Span<​byte> destination, Int32& bytesConsumed, Int32& bytesWritten, bool isFinalBlock = true)
public static int
GetEncodedLength​(int bytesLength)
Returns the length (in bytes) of the result if you were to encode binary data within a byte span of size <paramref name="bytesLength" /> .
Returns The length (in bytes) of the encoded result.
bytesLength The size of the input span.
public static int
GetMaxDecodedLength​(int base64Length)
Returns the maximum length (in bytes) of the result if you were to decode base 64 encoded text from a span of size <paramref name="base64Length" /> .
Returns The maximum length (in bytes) of the decoded result.
base64Length The size of the input span.
public static bool
IsValid​(ReadOnlySpan<​byte> utf8Base64UrlText)
Validates that the specified span of UTF-8 text is comprised of valid base-64 encoded data.
Returns <see langword="true" /> if <paramref name="utf8Base64UrlText" /> contains a valid, decodable sequence of base-64 encoded data; otherwise, <see langword="false" /> .
utf8Base64UrlText A span of UTF-8 text to validate.
public static bool
IsValid​(ReadOnlySpan<​byte> utf8Base64UrlText, Int32& decodedLength)
public static bool
IsValid​(ReadOnlySpan<​char> base64UrlText)
Validates that the specified span of text is comprised of valid base-64 encoded data.
Returns <see langword="true" /> if <paramref name="base64UrlText" /> contains a valid, decodable sequence of base-64 encoded data; otherwise, <see langword="false" /> .
base64UrlText A span of text to validate.
public static bool
IsValid​(ReadOnlySpan<​char> base64UrlText, Int32& decodedLength)
public static bool
TryDecodeFromChars​(ReadOnlySpan<​char> source, Span<​byte> destination, Int32& bytesWritten)
public static bool
TryDecodeFromUtf8​(ReadOnlySpan<​byte> source, Span<​byte> destination, Int32& bytesWritten)
public static bool
TryEncodeToChars​(ReadOnlySpan<​byte> source, Span<​char> destination, Int32& charsWritten)
public static bool
TryEncodeToUtf8​(ReadOnlySpan<​byte> source, Span<​byte> destination, Int32& bytesWritten)
public static bool
TryEncodeToUtf8InPlace​(Span<​byte> buffer, int dataLength, Int32& bytesWritten)
public bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj The object to compare with the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns a string that represents the current object.
Returns A string that represents the current object.