Hide password

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
walter4991
Posts: 21
Joined: 11 Dec 2010 10:17

Hide password

#1 Post by walter4991 » 30 Jan 2011 03:38

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

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Hide password

#2 Post by !k » 30 Jan 2011 06:37

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

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Hide password

#3 Post by aGerman » 30 Jan 2011 07:17

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

arjun2988
Posts: 6
Joined: 30 Jun 2011 01:33

Re: Hide password

#4 Post by arjun2988 » 01 Jul 2011 00:20

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!

Post Reply