password auto-generation & valiadation project

Hello,pros. Note: Win32 Console Application > Empty Project > C++ File(.cpp)

I had this project from school that requires me to program a "login security control using passwords, such as password setting and login validation".

(1st Issue,Solved by Skillless)(Closed) *Important*: I'm stuck at the part,which the password was wrongly keyed. E.g. "asd". Then i had a while(); to verify if the userID and password is correct compared to the one thats been hardcoded. Then it will asks the user to re-enter both ID and PW again and it will re-verify them. Now the problem is.. let's say during the re-entering,both the ID and PW was entered correctly to the one thats been hardcoded. Hardcoded ID is "administrator" and PW is "nyp". Now is the main point,when the user re-enter them. The ID has nothing wrong after i checked with breakpoint debugging but the password has a problem. It stored in "asdnyp" instead of replacing "nyp" over "asd". P.s:(Password needs to be '*' during input).

(2nd Issue,Solved by my own real life elder brother)(Closed) (Refer to 3rd post for more details)

(3rd Issue,Solved by Myself with tips & guidence from a NUS student)(Closed) (Refer to 4rd post for more details)

How can i solve this issue of the above?

Now i'm type out all of the requirements of my project(I'm still currently on Option 1 & 2 & 3 & 4):
The project allows the students to learn and practice login security control using
passwords, such as password setting and login validation. The students also need to write
C program to auto-generate passwords using the random number generator in C. The
main features of the program are listed as follows
1.) Creation of the user account (user id + password)
2.) Validation of login id and password
3.) Password auto-generation
4.) Exit

The program allows the user to repeatedly use the program until the option 4 is chosen.
Note that the program should also validate user’s inputs.

1. Creation of the user account (user name + password)
This option is for the administrator to create a number of users. At most 100 user
accounts can be added into the system. The program further allows the administrator to
manually set a user name and a default password for each user. You need to use arrays or
structure array to store user names and their corresponding passwords. The data stored in
the computer memory will be used by the program to check whether the user’s name and
password are valid when he or she logins into the system

Only administrator can use this option. Note that the user-name for administrator is “administrator”. You may set a password for the administrator in the program for security control.

2. Validation of login id and password
Note that this option is only available if the user names and passwords are set by using option 1.
The program prompts the user to enter a user name and then a password, note that the program should allow the user to correct errors, if any by using backspace key. Then the program compares the login data (user id & password) with pre-stored data, and displays the comparison results.

If the input password is not valid, the program may allow the user to try again, but he or she can only try three times

3. Password auto-generation
A password is often manually created by the user for security purpose, which is a combination of lower or uppercase letters, letters, numerical digits and sometimes punctuation symbols which are listed below.
Uppercase letters : A . . . Z
Lower letters : a . . . z
Digits : 0 . . . 9
Punctuation symbols : ! @ # $ % ^ & * - + ? < > ; :
Random and mixture use of uppercase letters, lowercase letters, digits and punctuation symbols is encouraged, so that the passwords created thus are highly secure and extremely difficult to crack or guess. Although a password can be any length, most software systems define a fixed password length.

For Option 3, you need to write a random password generator using C. The program allows the user to specify following parameters when generating random passwords.
Password length : n
No of passwords to be generated : N
Password type : T
Where the password type T indicates the combination of lower or uppercase letters, digits and punctuations symbols, as described below.
Type Character Combination
T=1 Lower letters only
T=2 Lower or uppercase letters
T=3 Lower or uppercase letters and digits
T=4 Lower or uppercase letters, digits and punctuation symbols.

Now,heres my codes that so far i've done:

-=Deleted=-
Last edited on
...because you never reset adminpw and just continue to put characters in it?
gets(char*) fills the string from [0] to [length of input]
when you reenter the password youre filling the string from [current length of string] to [current length + length of input]

basically, try this
1
2
3
4
5
6
7
8
9
10
11
12
13
						 if((strcmp(adminid, ID)!=0)||(strcmp(adminpw, PW)!=0))
						 {
							 printf("\nPassword is NOT valid.");
							 getch();
							 putch('\b');
							 putch(NULL);
							 putch('\b');
							 printf(",");
							 getch();
							 urpw = 0;
							 adminpw[0] = '\0';
							 printf("You may try again.\n");
						 }

Not completely sure though, your code is pretty,, much, weird, and not really easy to read
Thanks alot,Skillless =]

The 1st problem is solved,althought your line 10 and line 11 is placed at the wrong place but those are the two lines of codes that i'm short of that caused the issue.

I've managed to found the right place to place those two lines of codes already.

thanks alot again,Skillless.

Now i have a 2nd 3rd problem for Option 2 3 for validation of username and password password auto-generation.
Last edited on
(2nd Issue,Solved by my own real life elder brother)(Closed)

*Important*I'm stuck at Option 2),which was the username and password validation. When a user keyed in a username and password during Option 2) E.g. username == "asd" and password == "qwe". Note: The username and password can be anything thats keyed in by the user during Option 2). The username and password will then be verify with the pre-setted username and password,which was an account thats done during Option 1) by the administrator. E.g. username[0][0] == "zxc" and password[0][0] == "cvb" Note: This is an account. Followed by username[1][0] == "dfg" and password [1][0] == "jkl" and so on. Which is also an account per pair. Now is the main point,how can i verify what the user keyed in with the pre-setted onces during Option 1) by the administrator?

(For more infomation refer to 1st post)

Now,heres my *latest codes* that i've done :

-=Deleted
Last edited on
(3rd Issue,Solved by Myself with tips & guidence from a NUS student)(Closed)

*Important* : I totally don't even know how to do or even start off with Option 3), Pw auto-generation (Refer to 1st post). Teacher didn't teach but expects us to be able to do already. Can someone teach/guide me with Option 3)? i'm just this close to finishing my project. A million thanks to whoever pros that could teach/guide me.

A reference code thats provided by my school for doing Option 3) is posted on the 5th post.

Now,heres my *latest codes* that i've done :

-=Deleted=-
Last edited on
Now,heres the reference code thats provided by my school for Option 3),which is the Password auto-generation:

-=Deleted=-
Last edited on
Topic archived. No new replies allowed.