1.

Solve : Masking user input. (Batch+VBS)?

Answer»

I posted this in the MS-DOS section, but this STRAYS from batch, and I need more help. I need to mask the user's input, with an asterisk or a dot thing. I TRIED the other solutions, which accept 1 letter at a time, but that can't work because there can be over 30 possible passwords, listed in a file. Here is what I am trying to do, but hiding the password from prying eyes.

Code: [Select]@echo off
title School Chat
set num1=0
set num2=0
set fname=I:\Common\t3hwin\name
:looplog
cls
echo Enter your username.
set /p usr=Username^:
Echo Enter your password.
set /p pass=Password^:
for /f "delims= " %%l in ("%fname%") do set /a num1+=1
for /f "tokens=1-2 delims= " %%a in ("%fname%") do (
if "%%a"=="%usr" if "%%b"=="%pass%" goto cont
set /a num2+=1
if %num2%==%num1% echo Username and^/or password don't match.&pause > nul&goto looplog
)
:looplog
echo Logged in!
pause
The actual logging in might not work successfully (I'm working on it), but I need to mask the password input, so in other words, I need your help.

see here for something similar. As an alternative, why not start LEARNING some other languages and using already made modules. eg Perl
Code: [Select]use Term::READKEY;
print "Enter password: ";
ReadMode('noecho');
$password = ReadLine(0);
ReadMode 0;
Quote from: gh0std0g74 on April 19, 2009, 01:51:45 AM

why not start learning some other languages and using already made modules. eg Perl

Ghostdog, you have to pay to see a solution on Experts Exchange! Even for the "free 7 day trial" you need a credit card, and I wouldn't bother. Unless you remember to cancel, they'll hit you for $12.95 per month. Googling for scripts and "solutions" , and passing them off as your own work, is all very well, if you do it with more care.

Anyhow, I didn't get this via Googling, I wrote it myself, it shows the general principles.

This sort of thing is, you may as well say, impossible in either batch or VBS.

Qbasic / FreeBasic

The calling batch could read the entered password from the text file, and then delete the file at once.

Code: [Select]' password collector
password$ = ""
mask$ = "*"
PRINT "Enter password : ";
DO
DO
k$ = INKEY$
LOOP UNTIL k$ <> ""
kval = ASC(k$)
IF kval = 13 THEN
PRINT
EXIT DO
ELSE
PRINT mask$;
password$ = password$ + k$
END IF
LOOP
OPEN "Password.txt" FOR OUTPUT AS #1
PRINT #1, password$
CLOSE #1
SYSTEMQuote from: Dias de verano on April 19, 2009, 02:42:58 AM
Ghostdog, you have to pay to see a solution on Experts Exchange!
don't think you need to pay. long ago i created a user with a valid email address without paying anything. however if the paying scheme is just recently implemented, then too bad.

Quote
Googling for scripts and "solutions" , and passing them off as your own work, is all very well, if you do it with more care.
wow, I didn't say its my own work, did i? I am only helping providing him a link, just like everyone else is doing.

Quote from: gh0std0g74 on April 19, 2009, 02:52:24 AM
don't think you need to pay.

You need to pay. Standard is $12.95 a month.

Quote
long ago i created a user with a valid email address without paying anything. however if the paying scheme is just recently implemented, then too bad.

Yeah right. Like I really believe that! I've been aware of EE for at least 5 years, they are usually high up in Google searches for scripting solutions, and it has always been a pay site.

Quote
wow, I didn't say its my own work, did i?

You didn't say otherwise.

Quote
I am only helping providing him a link, just like everyone else is doing.

Not "everyone".

Quote from: Dias de verano on April 19, 2009, 03:03:20 AM
You need to pay. Standard is $12.95 a month.
too bad. maybe the scheme for solution provider(free) is different than the one asking for solution.

Quote
Yeah right. Like I really believe that! I've been aware of EE for at least 5 years, they are usually high up in Google searches for scripting solutions, and it has always been a pay site.
i am not paying. Period.



Discussion

No Comment Found