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

28 lines
935 B
JavaScript
Raw Permalink Normal View History

2022-09-05 16:57:11 -04:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeBase64 = exports.decodeBase64 = void 0;
2022-11-30 15:44:23 -05:00
/**
2022-12-30 11:30:03 -05:00
* [Base64 encoding](link-wiki-base64) using 6-bit words to encode
2022-11-30 15:44:23 -05:00
* arbitrary bytes into a string using 65 printable symbols, the
* upper-case and lower-case alphabet, the digits ``0`` through ``9``,
* ``"+"`` and ``"/"`` with the ``"="`` used for padding.
*
2022-12-02 21:27:06 -05:00
* @_subsection: api/utils:Base64 Encoding [about-base64]
2022-11-30 15:44:23 -05:00
*/
2022-09-15 22:58:45 -04:00
const data_js_1 = require("./data.js");
/**
2022-11-30 15:44:23 -05:00
* Decodes the base-64 encoded %%value%%.
2022-09-15 22:58:45 -04:00
*/
2022-11-30 15:44:23 -05:00
function decodeBase64(value) {
return (0, data_js_1.getBytesCopy)(Buffer.from(value, "base64"));
2022-09-05 16:57:11 -04:00
}
exports.decodeBase64 = decodeBase64;
;
2022-09-15 22:58:45 -04:00
/**
2022-11-30 15:44:23 -05:00
* Encodes %%data%% as a base-64 encoded string.
2022-09-15 22:58:45 -04:00
*/
2022-09-05 16:57:11 -04:00
function encodeBase64(data) {
2022-09-15 22:58:45 -04:00
return Buffer.from((0, data_js_1.getBytes)(data)).toString("base64");
2022-09-05 16:57:11 -04:00
}
exports.encodeBase64 = encodeBase64;
//# sourceMappingURL=base64.js.map