wowok
Version:
Wowok Blockchain TypeScript API
1 lines • 385 B
JavaScript
export function fromHex(a){const b=a['startsWith']('0x')?a['slice'](0x2):a,c=b['length']%0x2===0x0?b:'0'+b,d=c['match'](/[0-9a-fA-F]{2}/g)?.['map'](e=>parseInt(e,0x10))??[];if(d['length']!==c['length']/0x2)throw new Error('Invalid\x20hex\x20string\x20'+a);return Uint8Array['from'](d);}export function toHex(a){return a['reduce']((b,c)=>b+c['toString'](0x10)['padStart'](0x2,'0'),'');}