Subscribe Now: standard

Saturday, September 11, 2010

Accept Passwords Hidden By * In C++


A question I hear a lot, and a serious one too.
Any thing that deals with security and safety should be handled with extreme
care as it can ruin almost anything if it is at fault.

So here I Want to present you with a simple method to take in passwords for your c++ program by hiding them with a '*'.
#include

#include 


void getpass(char pas[])    //pas is an character array passed to this funtion
     {

       int i=0;
       while(pas[i]!=13)     //13 is the ASCII value for ENTER, so loop till ENTER
                                        // is pressed
       {
           pas[i] = getch();  //get a character without displaying it on screen
       }
       
       pas[i]='\0';    //marking the end of password.

     }

Ok , just pass a charecter array to this function, once this function executes and ends the array that you passed will have your password.

And next time, a simple encryption tool to keep your passwords safe.


So wait..........along