utils_crypto_decode-hex.ts
import "fastestsmallesttextencoderdecoder/EncoderDecoderTogether.min.js";
/**
* 16진수 문자열을 일반 문자열로 변환
*
* @function decodeHex
* @param {string} hex - 변환할 16진수 문자열 (예: "48656c6c6f")
* @returns {string} 디코딩된 문자열 (예: "Hello")
* @memberof $f
* @example
* decodeHex("48656c6c6f"); // returns "Hello"
*
*/
export function decodeHex(hex: string): string {
const bytes = new Uint8Array(
hex.match(/.{1,2}/g)?.map((byte) => parseInt(byte, 16)) || [],
);
return new TextDecoder().decode(bytes);
}