Post: looking for a good method of masking passwords
03-19-2013, 08:09 PM #1
Complete Speed
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({}); looking for the best way to mask passwords in a program.
the language doesn't really matter as long as it's at least an intermediate level language.

preferably c# c c++ python


if anyone has any code please reply.

and what i mean is:
example
    
username:john doe
password:********


okay i found this for me and anyone else who would like to implement this into their c++ programs

must include <windows.h>
    
string getpass(const char *prompt, bool show_asterisk=true)
{
const char BACKSPACE=8;
const char RETURN=13;

string password;
unsigned char ch=0;

cout <<prompt<<endl;

DWORD con_mode;
DWORD dwRead;

HANDLE hIn=GetStdHandle(STD_INPUT_HANDLE);

GetConsoleMode( hIn, &con_mode );
SetConsoleMode( hIn, con_mode & ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT) );

while(ReadConsoleA( hIn, &ch, 1, &dwRead, NULL) && ch !=RETURN)
{
if(ch==BACKSPACE)
{
if(password.length()!=0)
{
if(show_asterisk)
cout <<"\b \b";
password.resize(password.length()-1);
}
}
else
{
password+=ch;
if(show_asterisk)
cout <<'*';
}
}
cout <<endl;
return password;
}


it's pretty sweet it works like this.

you have to make a variable like this

    
const char *<variable name>="<string>"


then you make them guess the password like this

    
string <variable name> = getpass("<string to say here", <true or false>Winky Winky;

note: false will not show asterisks true will.
pretty neat.
(adsbygoogle = window.adsbygoogle || []).push({});
03-19-2013, 09:05 PM #2
nay1995
The Master
Originally posted by Complete
looking for the best way to mask passwords in a program.
the language doesn't really matter as long as it's at least an intermediate level language.

preferably c# c c++ python


if anyone has any code please reply.

and what i mean is:
example
    
username:john doe
password:********


i've already found something slightly like what i need in c++ but it uses chars and is just sloppy and to difficult to work with.




if you mean when you type the password in, display a certain char instead of the actual password characters, in visual basic there is a property for it called passwordChar (i think its called that) just input * or whatever, its in visual basic so i presume it will be available for c# / c++ | hope this makes sense. Smile
03-19-2013, 09:41 PM #3
Complete Speed
Do a barrel roll!
Originally posted by nay1995 View Post
if you mean when you type the password in, display a certain char instead of the actual password characters, in visual basic there is a property for it called passwordChar (i think its called that) just input * or whatever, its in visual basic so i presume it will be available for c# / c++ | hope this makes sense. Smile


yeah that's called password masking.

vb is to simple the passwordChar would probably be available for c# but not c++ because it might have something to do with .net? maybe. idk
but anyhow would like to see some implementations in c c++ or python.
03-19-2013, 11:41 PM #4
Pichu
RIP PICHU.
Originally posted by Complete
yeah that's called password masking.

vb is to simple the passwordChar would probably be available for c# but not c++ because it might have something to do with .net? maybe. idk
but anyhow would like to see some implementations in c c++ or python.


C++, C#, VB.NET with Visual Studio when using window forms uses the same classes to do the same things. C++ however allows for you to break away from the .NET framework while programming if you choose to.
03-19-2013, 11:43 PM #5
Complete Speed
Do a barrel roll!
Originally posted by Pichu View Post
C++, C#, VB.NET with Visual Studio when using window forms uses the same classes to do the same things. C++ however allows for you to break away from the .NET framework while programming if you choose to.


oh yeah. that's right. well i've only used visual studio as a compiler really. but i found a way to do it up top that works well in c++ would love to see a py script of it. or something similar.
03-20-2013, 09:19 PM #6
nay1995
The Master
Originally posted by Complete
yeah that's called password masking.

vb is to simple the passwordChar would probably be available for c# but not c++ because it might have something to do with .net? maybe. idk
but anyhow would like to see some implementations in c c++ or python.


you was asking for password masking? anyway to sum up what i said, there is a built in property for password masking for vb

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo