Converts a base64 encoded ascii string to a Uint8Array.
Converts a Uint8Array to a base64 encoded ascii string.
Takes a ucs-2 string and returns a base64 encoded ascii string.
Takes a base64 encoded ascii string and returns a ucs-2 string.
const str = "Hello ☸☹☺☻☼☾☿ World ✓"
const uint8Array = new TextEncoder().encode(str)
uint8Array === convertBase64ToUint8Array(convertUint8ArrayToBase64(uint8Array))
str === convertBase64ToString(convertStringToBase64(str))
The +
and /
characters of standard base64 are respectively replaced by
-
and _
and the padding =
characters are removed.
Converts a base64url string to standard base64.
The addPaddingToBase64url
function makes the string length a multiple of 4
by adding the padding character (=
).
More about this here.
const base64 = "c3ViamVjdHM/X2Q9MQ=="
const base64url = convertBase64ToBase64url(base64)
console.log(base64url) // c3ViamVjdHM_X2Q9MQ