0

In a Windows batch (cmd) file, I'd like to convert the contents of a hex string in the form

4C6F67696300000000000000

to its equivalent ASCII string, here "Logic". The hex string is always same size (12 octets). Note that it is null-terminated if string is less than 12 characters. Only conversion of plain printable ASCII characters (20-7F) required. Pure batch solutions preferred.

Scrontch
  • 3,275
  • 5
  • 30
  • 45

1 Answers1

1

Use certutil tool, see certutil /? for more info.

setlocal enabledelayedexpansion
set "hex=4C6F67696300000000000000"
echo !hex!> temp.hex
call certutil -decodehex temp.hex str.txt >nul
set /p str=<str.txt
echo:
( del temp.hex & del str.txt )>nul
echo Your decoded string is:"!str!".
endlocal
exit /b 0
mEm
  • 353
  • 3
  • 12