<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.19.0" />

Microsoft.IdentityModel.Tokens.Base64UrlEncoder

public static class Base64UrlEncoder
Encodes and Decodes strings as base64url encoding.
public static string Decode(string arg)

Decodes the specified base64url encoded string to UTF-8.

public static byte[] DecodeBytes(string str)

Converts the specified base64url encoded string to UTF-8 bytes.

public static string Encode(string arg)

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(byte[] inArray)

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, int offset, int length)

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 int Encode(ReadOnlySpan<byte> inArray, Span<char> output)

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