Base64 UrlEncode

For JWT tokens etc

Use the Microsoft.AspNetCore.WebUtilities package which contains a WebEncoders class:

Method Description
Base64UrlDecode(String) Decodes a base64url-encoded string.
Base64UrlDecode(String, Int32, Char[], Int32, Int32) Decodes a base64url-encoded input into a byte[].
Base64UrlDecode(String, Int32, Int32) Decodes a base64url-encoded substring of a given string.
Base64UrlEncode(Byte[]) Encodes input using base64url encoding.
Base64UrlEncode(Byte[], Int32, Char[], Int32, Int32) Encodes input using base64url encoding.
Base64UrlEncode(Byte[], Int32, Int32) Encodes input using base64url encoding.
Base64UrlEncode(ReadOnlySpan<Byte>) Encodes input using base64url encoding.
GetArraySizeRequiredToDecode(Int32) Gets the minimum char[] size required for decoding of count characters with the Base64UrlDecode(String, Int32, Char[], Int32, Int32) method.
GetArraySizeRequiredToEncode(Int32) Get the minimum output char[] size required for encoding countBytes with the Base64UrlEncode(Byte[], Int32, Char[], Int32, Int32) method.
Last updated: 12/19/2022 12:28:30 PM

Latest Updates

© 0 - 2025 - Mike Brind.
All rights reserved.
Contact me at Mike dot Brind at Outlook.com