Passwords

This is a discussion on Passwords within the C++ Programming forums, part of the General Programming Boards category; Hi, I'm a new member to this forum, and I was wondering if ye could help me with something, I ...

  1. #1
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262

    Passwords

    Hi, I'm a new member to this forum, and I was wondering if ye could help me with something,

    I want to password protect a program, but when someone types in their password, the letters of the password come up, and I was wondering if there is an easy way in c++ to make the letters come up as stars (*) or merely white spaces. any code would be most appreciated!!!!!!!!!!!!!!

    thanks, twomers

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    Not unless you tell us which OS and compiler you're using.

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    I'm using windows XP pro, and the compiler is microsoft visual c++

    that help? thanks!!

  4. #4
    Registered User
    Join Date
    May 2005
    Location
    Texas
    Posts
    103
    I've been doing something similar like this , maybe this thing can help you:
    Code:
    #include <iostream>
    #include <conio.h>
    
    #define ENTER	13
    #define STAR	'*'
    
    char key;
    char buffer[80];
    
    using namespace std;
    
    int main()
    {
        cout<<"Please Enter Your Password: "<<endl;
    	for(int x=0; x<80 ; x++)
    	{
    	    key= _getch();
    	    if( (int)key == ENTER)
    	    {
    		break;
    	    }
    
    	    else
    	    {
    		buffer[x]=key;
    		cout<<STAR;
    	    }
    	}
    	system("PAUSE");
    	return(0);
    }
    It's not all, but it's the base of all the program, hope it helps!
    Last edited by toonlover; 12-03-2005 at 05:53 PM.

  5. #5
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Excellent!!! thanks a lot! it looks good. I hope it works!

  6. #6
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    also, For this program, it would be great for it to execute a bat file afterwards, is that possible or would I have to tell the user to do it??
    Last edited by twomers; 12-03-2005 at 11:26 AM.

  7. #7
    Registered User
    Join Date
    May 2005
    Location
    Texas
    Posts
    103
    Yes, yet I am not the guy you should be asking, do you know I/O? File I/O has the capabilities of modifiying texts outside the program...and I am not sure how to execute a .bat file , maybe someone here might help you with this problem. I am bearly a nooby, so don't expect so much of me.

  8. #8
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    oh right, you've helped a lot already tho! that star program is fantastic! thanks a lot for that!!! I don't suppose you know where I could look for that thing I want do you?

  9. #9
    Registered User
    Join Date
    May 2005
    Location
    Texas
    Posts
    103
    Well, this is and I\O Tutorial:

    http://www.cprogramming.com/tutorial/lesson10.html

    After getting the hang of File I\O, trying googling your question:

    http://www.google.com/search?hl=en&q...=Google+Search

    Search for something similar, Hope it works, sorry I couldn't help you with the rest.

  10. #10
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    thanks! googling is fun, but time consuming ah well. I'm finding things, but am not sure about them, does this look right??


    http://www.site.uottawa.ca/~nat/Cour...e-2/sld005.htm

    ???

  11. #11
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    also, For this program, it would be great for it to execute a bat file afterwards, is that possible or would I have to tell the user to do it??
    Code:
    system("test.bat");
    will run test.bat.

    [edit]
    Or look at the responses you elicted here: opening a batch file from c++
    [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  12. #12
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Nice code, toonlover! Not.
    Code:
    #include <iostream>
    #include <conio.h>
    
    #define ENTER	13
    #define STAR	'*'
    
    char key;
    char buffer[80];
    
    int main()
    {
        cout<<"Please Enter Your Password: "<<endl;
    	for(int x=0; x<80 ; x++)
    	{
    	    key= _getch();
    	    if( (int)key == ENTER)
    	    {
    		break;
    	    }
    
    	    else
    	    {
    		buffer[x]==key;
    		cout<<STAR;
    	    }
    	}
    	system("PAUSE");
    	return(0);
    }
    1. Since you use <iostream> (which is good, by the way ), you need to use std::cout or a using directive.
    2. system("PAUSE") is not good.
    3. Code:
      buffer[x]==key;
      Make that =. And NULL-terminate the string somewhere.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  13. #13
    Registered User
    Join Date
    May 2005
    Location
    Texas
    Posts
    103
    Yea, I forgot. Oh dumb me

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. vBulletin vandals and the wisdom of randomly generated passwords
    By abachler in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 12-08-2008, 04:27 PM
  2. Deleting IE saved user names and passwords
    By patrick22 in forum Windows Programming
    Replies: 3
    Last Post: 03-23-2008, 04:38 PM
  3. Database programming and passwords
    By Squintz in forum Windows Programming
    Replies: 6
    Last Post: 11-19-2003, 08:05 PM
  4. Encrypting and checking passwords in bigger programs
    By TerryBogard in forum C Programming
    Replies: 1
    Last Post: 11-17-2002, 06:21 AM
  5. What is the best way to use passwords?
    By GreenCherry in forum C++ Programming
    Replies: 1
    Last Post: 03-22-2002, 10:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21