Base64Url.EncodeToUtf8 Method

Definition

Overloads

EncodeToUtf8(ReadOnlySpan<Byte>, Span<Byte>, Int32, Int32, Boolean)

Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.

EncodeToUtf8(ReadOnlySpan<Byte>, Span<Byte>)

Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.

EncodeToUtf8(ReadOnlySpan<Byte>)

Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.

EncodeToUtf8(ReadOnlySpan<Byte>, Span<Byte>, Int32, Int32, Boolean)

Source:
Base64UrlEncoder.cs

Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.

C#
public static System.Buffers.OperationStatus EncodeToUtf8 (ReadOnlySpan<byte> source, Span<byte> destination, out int bytesConsumed, out int bytesWritten, bool isFinalBlock = true);

Parameters

source
ReadOnlySpan<Byte>

The input span which contains binary data that needs to be encoded.

destination
Span<Byte>

The output span which contains the result of the operation, i.e. the UTF-8 encoded text in Base64Url.

bytesConsumed
Int32

When this method returns, contains the number of input bytes consumed during the operation. This can be used to slice the input for subsequent calls, if necessary. This parameter is treated as uninitialized.

bytesWritten
Int32

When this method returns, contains the number of bytes written into the output span. This can be used to slice the output for subsequent calls, if necessary. This parameter is treated as uninitialized.

isFinalBlock
Boolean

true when the input span contains the entirety of data to encode; false when more data may follow,

such as when calling in a loop, subsequent calls with false should end with true call. The default is true.

Returns

One of the enumeration values that indicates the success or failure of the operation.

Remarks

This implementation of the base64url encoding omits the optional padding characters.

Applies to

.NET 9 and other versions
Product Versions
.NET 8 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)

EncodeToUtf8(ReadOnlySpan<Byte>, Span<Byte>)

Source:
Base64UrlEncoder.cs

Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.

C#
public static int EncodeToUtf8 (ReadOnlySpan<byte> source, Span<byte> destination);

Parameters

source
ReadOnlySpan<Byte>

The input span which contains binary data that needs to be encoded.

destination
Span<Byte>

The output span which contains the result of the operation, i.e. the UTF-8 encoded text in Base64Url.

Returns

The number of bytes written into the destination span. This can be used to slice the output for subsequent calls, if necessary.

Exceptions

The buffer in destination is too small to hold the encoded output.

Remarks

This implementation of the base64url encoding omits the optional padding characters.

Applies to

.NET 9 and other versions
Product Versions
.NET 8 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)

EncodeToUtf8(ReadOnlySpan<Byte>)

Source:
Base64UrlEncoder.cs

Encodes the span of binary data into UTF-8 encoded text represented as Base64Url.

C#
public static byte[] EncodeToUtf8 (ReadOnlySpan<byte> source);

Parameters

source
ReadOnlySpan<Byte>

The input span which contains binary data that needs to be encoded.

Returns

Byte[]

The output byte array which contains the result of the operation, i.e. the UTF-8 encoded text in Base64Url.

Remarks

This implementation of the base64url encoding omits the optional padding characters.

Applies to

.NET 9 and other versions
Product Versions
.NET 8 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)