Base64UrlEncoder.Encode Method

Definition

Overloads

Encode(Byte[])

Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation which is encoded with base-64-url digits.

Encode(String)

The following functions perform 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 replace with ('-' and '_') The changes make the encoding alphabet file and URL safe.
Encode(ReadOnlySpan<Byte>, Span<Char>)

Populates a ReadOnlySpan<T>Converts a Span<T> encoded with base-64-url digits. Parameters specify the subset as an offset in the input array, and the number of elements in the array to convert.

Encode(Byte[], Int32, Int32)

Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation which is encoded with base-64-url 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 which is encoded with base-64-url 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 string representation in base 64 url encoding of length elements of inArray, starting at position offset.

Exceptions

'inArray' is null.

offset or length is negative OR offset plus length is greater than the length of inArray.

Applies to

Encode(String)

The following functions perform 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 replace with ('-' and '_') The changes make the encoding alphabet file and 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

string to encode.

Returns

Base64Url encoding of the UTF8 bytes.

Applies to

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

Populates a ReadOnlySpan<T>Converts a Span<T> encoded with base-64-url digits. Parameters specify the subset as an offset in the input array, and the number of elements in the array to convert.

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 span of bytes.

output
Span<Char>

output for encoding.

Returns

The number of chars written to the output.

Applies to

Encode(Byte[], Int32, Int32)

Converts a subset of an array of 8-bit unsigned integers to its equivalent string representation which is encoded with base-64-url 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

The number of elements of inArray to convert.

length
Int32

An offset in inArray.

Returns

The string representation in base 64 url encoding of length elements of inArray, starting at position offset.

Exceptions

'inArray' is null.

offset or length is negative OR offset plus length is greater than the length of inArray.

Applies to