function decode(base64) {
let len = base64.length;
let bufferLength = len * 0.75;
let i;
let p = 0;
if (base64[base64.length - 1] === "=") {
--bufferLength;
if (base64[base64.length - 2] === "=") {
--bufferLength;
}
}
let bytes = new Uint8Array(bufferLength);
for (i = 0; i < len; i+=4) {
const encoded1 = lookup[base64.charCodeAt(i)];
const encoded2 = lookup[base64.charCodeAt(i+1)];
const encoded3 = lookup[base64.charCodeAt(i+2)];
const encoded4 = lookup[base64.charCodeAt(i+3)];
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
}
return bytes.buffer;
}