:stringToHex
@echo off
del tmp.hex >nul 2>nul
del tmp.str >nul 2>nul
if "%~1" equ "" (
echo no string passed
exit /b 1
)
echo|set /p=%~1 >tmp.str
::(echo(%~1)>tmp.str
rem certutil -dump tmp.str
certutil -encodehex tmp.str tmp.hex >nul
setlocal enableDelayedExpansion
set "hex_str="
for /f "usebackq tokens=2 delims= " %%A in ("tmp.hex") do (
set "line=%%A"
set hex_str=!hex_str!!line:~0,48!
set hex_str=!hex_str: =!
)
set hex_str=%hex_str:~0,-2%
echo !hex_str!
!! Pamiętaj, że edytor stackoverflow może uszkodzić znak tabulacji. tokens=2 delims= "
Po delimach powinien być pojedynczy TAB
.
wymaga ciągu przekazanego jako argument. Spójrz także na funkcję debnham'a :hexDump, której możesz użyć zamiast certutil.
Wątpię istnieje rozwiązanie tylko z pliku wsadowego. Byłoby łatwo z PowerShell, jeśli jest to opcja. –