(hex: string)
| 159 | * ``` |
| 160 | */ |
| 161 | export function hexToBytes(hex: string) { |
| 162 | const cleaned = hex.replace(/\s/g, ""); |
| 163 | const bytes = new Uint8Array(cleaned.length / 2); |
| 164 | |
| 165 | for (let i = 0; i < bytes.length; i++) { |
| 166 | bytes[i] = Number.parseInt(cleaned.slice(i * 2, i * 2 + 2), 16); |
| 167 | } |
| 168 | |
| 169 | return bytes; |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Check if bytes start with the PDF header signature. |
no test coverage detected