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

24 lines
798 B
JavaScript
Raw Normal View History

2022-09-05 23:57:11 +03:00
"use strict";
// utils/base64-browser
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeBase64 = exports.decodeBase64 = void 0;
2022-09-16 05:58:45 +03:00
const data_js_1 = require("./data.js");
2022-09-05 23:57:11 +03:00
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 (0, data_js_1.getBytes)(data);
2022-09-05 23:57:11 +03:00
}
exports.decodeBase64 = decodeBase64;
function encodeBase64(_data) {
2022-09-16 05:58:45 +03:00
const data = (0, data_js_1.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);
}
exports.encodeBase64 = encodeBase64;
//# sourceMappingURL=base64-browser.js.map