Results 1 to 3 of 3

Thread: Password checker program - help?

  1. #1
    Join Date
    Mar 2010
    Location
    Tennessee
    Posts
    1

    Password checker program - help?

    Okay...I've been trying to write a piece of code to read a password from the keyboard, check it against a static password (or set thereof; I've found that if I put more than one password in the text file that I'm using currently, the "correct" password cycles depending on what try the user is on). I've gotten far enough to have the code work, but with more than one logic error, and I am confuzzled as to how I go about getting around that. The logic errors plaguing this piece of code are simple: if the password is entered incorrectly multiple times, then when it is finally entered correctly the API is completely ignored, as though I never put it in. I believe the way that I originally referenced the strings to be partially responsible for this, as I originally had it checking whole words against one another instead of what I believe to be the added redundancy of having the checker loop compare individual characters.

    My problem is that I am as of yet unsure of whether my strings (pass and passcheck) will accept being indexed as if they were arrays, which is essential to the correct operation of my program.

    This originally started off as a homework assignment, but has grown into something of a side project of mine. Any assistance you can provide would be most appreciated (any day I can stave off a headache is a good day indeed).

    Code:
    #include <conio.h>
    #include <fstream.h>
    #include <string>
    #include <c:\\bc5\\include\\win32\\windows.h>
    #include <ctype.h>
    
    void func(char* (&array)[11])		/*passes array by reference; I had an idea from searching around, and was going to try to modify this function to do my bidding*/
    {
    for (int i = 0; i < 11; ++i)
    	{
    	cout << array[i] << '\n';
    	
    	}
    }
    
    
    /*void main()*/
    int main()
    {
    	fstream password("passwd.txt",ios::in);
    	string pass,passcheck;
    	cout<<"Enter your password: ";
    	cin<<pass;
    	/*do*/
    	/*while(!password.eof)*/
    	while(password>>passcheck)
    	{
    		password>>passcheck;   
    		/*if(pass==passcheck)    Old method of checking the password; it checked the values of whole words against one another rather than individual letters
    		{
    			MessageBox(0,"Accepted", "Ok", MB_OK|MB_EXCLAMATION|MB_TOPMOST);  This is to happen if the password is accepted
    		
    		else  This is to happen if it doesn't
    		{  
    			MessageBox(0,"Access Denied", "Ok",   MB_OK|MB_EXCLAMATION|MB_TOPMOST);
    		}*/
    
    		for(i=0;i<11;i++) /*This is my current idea on how to make this program work correctly*/
    		{
    			if(pass[i]==passcheck[1])   /*This loop is supposed to check the value assigned to pass[i] against the value assigned to passcheck[i], and if they are equal then continue*/
    			{
    				MessageBox(0,"Accepted","Ok",MB_OK|MB_EXCLAMATION|MB_TOPMOST);
    			}
    	}
    /*while(!password.eof)*/  /*I never really could get that particular piece of syntax to work correctly, so I gave up and wrote the above while loop*/
    	return 0;
    }

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Password checker program - help?

    I have something interesting program in C++ and that is only for you and I hope you can understand and implement it much better than other. It is written in the file(notepad ) attach with the post in the attachment section, just download it and try to implement and if you are getting any problem then please please post me what's your problem ..
    Attached Files Attached Files

  3. #3
    smith001 Guest

    Re: Password checker program - help?

    As I have seen your comments above & I think my problem is that I am as of yet unsure of whether my strings (pass and passcheck) will accept being indexed as if they were arrays, which is essential to the correct operation of my program.
    Thanks
    Jessica

Similar Threads

  1. Replies: 8
    Last Post: 19-03-2012, 03:28 PM
  2. Replies: 1
    Last Post: 11-10-2011, 01:41 PM
  3. Twitter Name Checker
    By monsitj in forum Technology & Internet
    Replies: 1
    Last Post: 08-07-2009, 05:32 PM
  4. Microsoft Password Checker
    By monsitj in forum Networking & Security
    Replies: 2
    Last Post: 07-02-2009, 08:54 AM
  5. Program To Get Password Of A Rar File?
    By mauricio in forum Windows Software
    Replies: 3
    Last Post: 17-10-2006, 08:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,727,136,747.39919 seconds with 18 queries