Skip to content

Commit 5887b35

Browse files
committed
Create stringToHex.bat
1 parent 1d35fc2 commit 5887b35

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

stringutils/stringToHex.bat

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@echo off
2+
:stringToHex
3+
del tmp.hex >nul 2>nul
4+
del tmp.str >nul 2>nul
5+
echo|(set /p=%~1)>tmp.str
6+
7+
certutil -encodehex tmp.str tmp.hex >nul
8+
setlocal enableDelayedExpansion
9+
set "hex_str="
10+
for /f "usebackq tokens=2 delims= " %%A in ("tmp.hex") do (
11+
set "line=%%A"
12+
set hex_str=!hex_str!!line:~0,48!
13+
set hex_str=!hex_str: =!
14+
15+
)
16+
::clears EOF character
17+
set "hex_str=%hex_str:~0,-2%"
18+
(echo(!hex_str!)

0 commit comments

Comments
 (0)