samedi 15 octobre 2016

How to generate random Hex String from batch file?

Friends, I am trying to generate a random hex string on my web server. I am using Apache HTTPD on Windows 10. I am using the hex string for session ID's etc.

The code I have tried so far:

setlocal enabledelayedexpansion
set HESSTR=0123456789ABCDEF
set /a tempone="("%RANDOM%"*"16")"
set /a RANHEXS=tempone"/"32767
echo %RANHEXS%
set hexout=!HESSTR:~%RANHEXS%,1!
echo %hexout%
pause
endlocal

But this code Always returns 6... What am I doing wrong?

Thanks a lot!




Aucun commentaire:

Enregistrer un commentaire