To encode text or data into Base64 in JavaScript, the btoa()
method can be used. This method converts a string of data to a Base64-encoded ASCII string.
Here's an example of how to use btoa()
:
index.tsx110 chars4 lines
To decode a Base64-encoded string back into the original data or text, the atob()
method can be used.
Here's an example of how to use atob()
:
index.tsx124 chars4 lines
gistlibby LogSnag