php – javascript – btoa, atob – Kódování Base64

Od posmura

 

// encode a string
encodedData = btoa(“Hello, world”);

// decode the string
decodedData = atob(encodedData);

function utf8_to_b64(str) {
return window.btoa(unescape(encodeURIComponent(str)));
}

function b64_to_utf8(str) {
return decodeURIComponent(escape(window.atob(str)));