2022-09-05 23:57:11 +03:00
|
|
|
// utils/base64-browser
|
2022-09-16 05:58:45 +03:00
|
|
|
import { getBytes } from "./data.js";
|
2022-09-05 23:57:11 +03:00
|
|
|
export function decodeBase64(textData) {
|
|
|
|
textData = atob(textData);
|
|
|
|
const data = new Uint8Array(textData.length);
|
|
|
|
for (let i = 0; i < textData.length; i++) {
|
|
|
|
data[i] = textData.charCodeAt(i);
|
|
|
|
}
|
2022-09-16 05:58:45 +03:00
|
|
|
return getBytes(data);
|
2022-09-05 23:57:11 +03:00
|
|
|
}
|
|
|
|
export function encodeBase64(_data) {
|
2022-09-16 05:58:45 +03:00
|
|
|
const data = getBytes(_data);
|
2022-09-05 23:57:11 +03:00
|
|
|
let textData = "";
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
textData += String.fromCharCode(data[i]);
|
|
|
|
}
|
|
|
|
return btoa(textData);
|
|
|
|
}
|
|
|
|
//# sourceMappingURL=base64-browser.js.map
|