Base64UrlEncoder.Encode Method

Definition

Overloads

Encode(Byte[])

Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation encoded with base64url digits.

Encode(String)

Performs base64url encoding, which differs from regular base64 encoding as follows:

  • Padding is skipped so the pad character '=' doesn't have to be percent encoded.
  • The 62nd and 63rd regular base64 encoding characters ('+' and '/') are replaced with ('-' and '_'). This makes the encoding alphabet URL safe.
Encode(ReadOnlySpan<Byte>, Span<Char>)

Populates a Span<T> with the base64url encoded representation of a ReadOnlySpan<T> of bytes.

Encode(Byte[], Int32, Int32)

Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation encoded with base64url digits. Parameters specify the subset as an offset in the input array and the number of elements in the array to convert.

Encode(Byte[])

Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation encoded with base64url digits.

public static string Encode (byte[] inArray);
static member Encode : byte[] -> string
Public Shared Function Encode (inArray As Byte()) As String

Parameters

inArray
Byte[]

An array of 8-bit unsigned integers.

Returns

The base64url encoded string representation of the elements in inArray.

Exceptions

Thrown if inArray is null.

Thrown if offset or length is negative, or if offset plus length is greater than the length of inArray.

Applies to

Encode(String)

Performs base64url encoding, which differs from regular base64 encoding as follows:

  • Padding is skipped so the pad character '=' doesn't have to be percent encoded.
  • The 62nd and 63rd regular base64 encoding characters ('+' and '/') are replaced with ('-' and '_'). This makes the encoding alphabet URL safe.
public static string Encode (string arg);
static member Encode : string -> string
Public Shared Function Encode (arg As String) As String

Parameters

arg
String

The string to encode.

Returns

The base64url encoding of the UTF8 bytes.

Applies to

Encode(ReadOnlySpan<Byte>, Span<Char>)

Populates a Span<T> with the base64url encoded representation of a ReadOnlySpan<T> of bytes.

public static int Encode (ReadOnlySpan<byte> inArray, Span<char> output);
static member Encode : ReadOnlySpan<byte> * Span<char> -> int
Public Shared Function Encode (inArray As ReadOnlySpan(Of Byte), output As Span(Of Char)) As Integer

Parameters

inArray
ReadOnlySpan<Byte>

A read-only span of bytes to encode.

output
Span<Char>

The span of characters to write the encoded output.

Returns

The number of characters written to the output span.

Applies to

Encode(Byte[], Int32, Int32)

Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation encoded with base64url digits. Parameters specify the subset as an offset in the input array and the number of elements in the array to convert.

public static string Encode (byte[] inArray, int offset, int length);
static member Encode : byte[] * int * int -> string
Public Shared Function Encode (inArray As Byte(), offset As Integer, length As Integer) As String

Parameters

inArray
Byte[]

An array of 8-bit unsigned integers.

offset
Int32

An offset in inArray.

length
Int32

The number of elements of inArray to convert.

Returns

The base64url encoded string representation of length elements of inArray, starting at position offset.

Exceptions

Thrown if inArray is null.

Thrown if offset or length is negative, or if offset plus length is greater than the length of inArray.

Applies to