import { Buffer } from "buffer"; const toHex = (value: any) => { return Buffer.from(value, "hex").toString("hex"); }; const hexToString = (str: string) => { return Buffer.from(str, "hex").toString("utf8"); }; const hexToBytes = (hex: string): number[] => { let bytes: number[] = []; for (let c = 0; c < hex.length; c += 2) bytes.push(parseInt(hex.substring(c, c + 2), 16)); return bytes; }; export const HexUtils = { toHex, hexToString, hexToBytes, };