/** Parse a hex dump string into byte values. Whitespace is ignored. */ export function parseHexInput(hex: string): number[] { const clean = hex.replace(/\s/g, '') if (clean.length % 2 !== 0) return [] const out: number[] = [] for (let i = 0; i < clean.length; i += 2) { const b = parseInt(clean.slice(i, i + 2), 16) if (Number.isNaN(b)) return [] out.push(b) } return out } /** Format bytes as uppercase hex pairs separated by spaces. */ export function formatHexBytes(bytes: number[]): string { return bytes.map(b => b.toString(16).padStart(2, '0').toUpperCase()).join(' ') }