'use strict';

var utils_types_string = require('../types/string.cjs');
var utils_types_bytes = require('../types/bytes.cjs');
var utils_error = require('../error.cjs');
require('crypto');
require('../interfaces.cjs');
require('../assert.cjs');
require('../types/iterable.cjs');
require('../types/object.cjs');
require('../inheritance.cjs');
require('../types/set.cjs');

/**
 * Encodes supplied bytes as base64 string.
 * @param {Uint8Array} bytes
 * @returns {string}
 */
const encodeAsBase64 = (bytes) => Buffer.from(utils_types_bytes.normalizeToU8a(bytes)).toString('base64');
/**
 * Decodes bytes of the supplied base64 string.
 * @param {string} string
 * @returns {Uint8Array}
 */
const decodeFromBase64 = utils_error.catchFnErrorWith(
  'Invalid base64 string',
  (string) => utils_types_bytes.u8aToU8a(Buffer.from(utils_types_string.ensureString(string), 'base64')),
);

exports.decodeFromBase64 = decodeFromBase64;
exports.encodeAsBase64 = encodeAsBase64;
//# sourceMappingURL=base-64.cjs.map
