"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const Web3Utils = __importStar(require("web3-utils"));
const ensure_1 = require("../guards/ensure");
exports.stringToBytes = (inputString, numBytes) => {
    const numChars = numBytes * 2; // characters needed to encode numBytes
    ensure_1.ensure(inputString.length <= numChars, `String too long to encode with ${numBytes} bytes`);
    return Web3Utils.padLeft(Web3Utils.stringToHex(inputString), numChars);
};
exports.stringToBytes8 = (input) => exports.stringToBytes(input, 8);
exports.stringToBytes32 = (input) => exports.stringToBytes(input, 32);
