"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function zero2(word) { if (word.length === 1) { return '0' + word; } else { return word; } } function toArray(msg, enc) { if (Array.isArray(msg)) { return msg.slice(); } if (!msg) { return []; } const res = []; if (typeof msg !== 'string') { for (let i = 0; i < msg.length; i++) { res[i] = msg[i] | 0; } return res; } if (enc === 'hex') { msg = msg.replace(/[^a-z0-9]+/ig, ''); if (msg.length % 2 !== 0) { msg = '0' + msg; } for (let i = 0; i < msg.length; i += 2) { res.push(parseInt(msg[i] + msg[i + 1], 16)); } } else { for (let i = 0; i < msg.length; i++) { const c = msg.charCodeAt(i); const hi = c >> 8; const lo = c & 0xff; if (hi) { res.push(hi, lo); } else { res.push(lo); } } } return res; } exports.toArray = toArray; function encodeHex(msg) { let res = ''; for (let i = 0; i < msg.length; i++) { res += zero2(msg[i].toString(16)); } return res; } exports.encodeHex = encodeHex; //# sourceMappingURL=util.js.map