I wanna use a batch-File to generate a SHA1-Key from user input(online-tools are not allowed) and show it on the console. For hashing I use certutil. Following my code:
@ECHO OFF
TITLE MyBatchFile
ECHO Please enter the value
ECHO ===========================================
SET /p var=
ECHO %var%>temp_file.tmp
certutil -hashfile temp_file.tmp SHA1
PAUSE
DEL temp_file.tmp
EXIT
It works everything, except writing into the file temp_file.temp. There I always have a carriage return and a space and I really don't get it how to remove those. For Hashing I need the exact string and no additional spaces and carriage returns. I was looking for sevaral solutions in the web(e.g. following code) but I didn't found anyone that worked.
if exist "temp_file.tmp" findstr /R "^." "temp_file.tmp" >"file.tmp"
if exist "file.tmp" for %%I in ("file.tmp") do if %%~zI == 0 (del "file.tmp") else move /Y "file.tmp" "temp_file.tmp"
How can I write into the temp-File without any additional spaces, carriage returns, etc. or how can I remove these in the file? Thank you for your answers
Phil