ethers.js/lib.esm/utils/base64-browser.js

19 lines
575 B
JavaScript
Raw Permalink Normal View History

2022-09-05 16:57:11 -04:00
// utils/base64-browser
2022-09-15 22:58:45 -04:00
import { getBytes } from "./data.js";
2022-09-05 16:57:11 -04: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-15 22:58:45 -04:00
return getBytes(data);
2022-09-05 16:57:11 -04:00
}
export function encodeBase64(_data) {
2022-09-15 22:58:45 -04:00
const data = getBytes(_data);
2022-09-05 16:57:11 -04:00
let textData = "";
for (let i = 0; i < data.length; i++) {
textData += String.fromCharCode(data[i]);
}
return btoa(textData);
}
//# sourceMappingURL=base64-browser.js.map