hextostr.exe - convert a passed HEX string into a string of characters
Posted: 09 May 2022 13:57
A few days ago @lazna asked for a tool to convert a HEX string to text. So, I wrote a few lines in C.
Pass the HEX string as argument to hextostr.exe. The converted text is written to the standard output stream.
The lightweight 32 bit executable is highly liberal in what it accepts. Every found pair of contiguous HEX digits is converted into a character. Lone-standig HEX digits, spaces, etc. are just ignored. Additionally, anything passed to the tool is treated as a single argument, regardless of whether it was enclosed in quotes.
Some examples, all converted to "AZ"
However, the fact that almost no rules are defined also means that some outcomes may not seem obvious.This is not entirely ignored because "foobar" contains "ba" which is a pair of valid hex digits.
Note: The amount of data which can be converted is limited by the maximum length of a command line because the HEX string is to be passed as argument. Consider to use CERTUTIL -DECODEHEX for the conversion of a HEX-encoded file.
Steffen
Pass the HEX string as argument to hextostr.exe. The converted text is written to the standard output stream.
The lightweight 32 bit executable is highly liberal in what it accepts. Every found pair of contiguous HEX digits is converted into a character. Lone-standig HEX digits, spaces, etc. are just ignored. Additionally, anything passed to the tool is treated as a single argument, regardless of whether it was enclosed in quotes.
Some examples, all converted to "AZ"
Code: Select all
hextostr 415A
hextostr " 41 5A "
hextostr 41 5a
hextostr 0x41 0x5a
hextostr "&H41 &H5a"
hextostr \x41\x5A
hextostr %%41%%5A
for /f "delims=" %%s in ('hextostr "415a"') do echo captured: %%s
Code: Select all
hextostr foobar
Note: The amount of data which can be converted is limited by the maximum length of a command line because the HEX string is to be passed as argument. Consider to use CERTUTIL -DECODEHEX for the conversion of a HEX-encoded file.
Steffen