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

Microsoft.IdentityModel.Tokens.Base64UrlEncoding

static class Base64UrlEncoding
For Non-Net9.0 Targets: Base64 encode/decode implementation for as per https://tools.ietf.org/html/rfc4648#section-5. For Net9.0 Targets: Uses System.Buffers.Text.Base64Url to perform the encoding/decoding. Uses ArrayPool[T] to minimize memory usage.
public static byte[] Decode(string inputString)

Decodes a base64url encoded string into a byte array.

public static byte[] Decode(string input, int offset, int length)

Decodes a base64url encoded substring of a string into a byte array.

public static T Decode<T, TX>(string input, int offset, int length, TX argx, Func<byte[], int, TX, T> action)

Decodes a base64url encoded substring of a string and then performs an action on the decoded bytes.

public static T Decode<T>(string input, int offset, int length, Func<byte[], int, T> action)

Decodes a base64url encoded substring of a string and then performs an action on the decoded bytes.

public static T Decode<T, TX, TY, TZ>(string input, int offset, int length, TX argx, TY argy, TZ argz, Func<byte[], int, TX, TY, TZ, T> action)

Decodes a base64url encoded substring of a string and then performs an action on the decoded bytes.

public static string Encode(byte[] bytes)

Encodes a byte array into a base64url encoded string.

public static string Encode(byte[] input, int offset, int length)

Encodes a subset of a byte array into a Base64Url encoded string.