Page 1 of 1

Hide password

Posted: 30 Jan 2011 03:38
by walter4991
how do I hide the password under asterisks?
I have this code:

Code: Select all

set /p "pass=>"
if NOT %pass%==123456 goto FAIL


but as I write this password is visible .... How do I hide?

Thanks, Walter4991

Re: Hide password

Posted: 30 Jan 2011 06:37
by !k

Code: Select all

set "hash="
set /p "pass=>"
for /f %%a in ('echo.^|md5.exe -d%pass% 2^>nul') do set "hash=%%a"
if NOT "%hash%"=="E10ADC3949BA59ABBE56E057F20F883E" goto FAIL

md5.exe
Note: md5-hashing isn't absolute protection

Re: Hide password

Posted: 30 Jan 2011 07:17
by aGerman
Password requests in a batch file are senseless and there is nothing you could do to change this fact. Thats why hiding the input behind asterisks is not provided.
If you're kinda bored, you can play around:
http://www.dostips.com/forum/viewtopic.php?f=3&t=1562

Regards
aGerman

Re: Hide password

Posted: 01 Jul 2011 00:20
by arjun2988
Hey guys thnx for d help, Finally got one to work :)

Here's the code

@echo off
echo hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5>hide.com

:retry
set /p userid=Enter UserId:
set /p password=Enter password: <nul
for /f "tokens=*" %%i in ('hide.com') do set password=%%i
:next
echo "Your Password is %password%"
echo. & echo You are logged in!