Convert hex to Base64 without encoding the hex digits as text
The input 00ff41 can lead to AP9B or MDBmZjQx. Compare the two byte sequences and pick the one required by the receiving format.
Establish what the six digits represent
In hexadecimal notation, two digits describe one byte. The string 00ff41 can describe the three bytes 00, FF and 41. Typing the six digits into a text encoder instead supplies six ASCII characters, each with its own byte value.
Compare both results side by side
The first row parses the hex notation. The second encodes the digits literally. In Node.js, Buffer.from("00ff41", "hex").toString("base64") produces the first row. Enter 00ff41 in the Decodex text encoder to reproduce the second.
| Input | Bytes in hexadecimal | Base64 |
|---|---|---|
0x00 0xFF 0x41 | 00 FF 41 | AP9B |
"00ff41" · ASCII | 30 30 66 66 34 31 | MDBmZjQx |
Check the protocol length
If the device specification calls for a three-byte field, verify the decoded length before sending it. Validate complete pairs and the allowed hex digits when implementing an input field. Some library functions stop at the first invalid pair and return a shorter result.