Password Verifier - Write a program to verify passwords, satisfying the following specifications:ALGORITHM:1. Ask the user to input a possible password.2. Check to see that it:- is at least 8 characters long- is no longer than 16 characters3. While it's not valid:- tell the user why it isn't valid- and go back to step one4. Once it's valid, ask the user to re-enter it.5. Compare the new password to the old one, and if it's NOT the same, ask again.HINT: Could be an inner loop that calls a function.6. If the user has tried and failed to duplicate the password 3 times, start over, asking for a new password.7. Once the user has created and verified a good password, give output saying so.SPECIFICATIONS:The program should implement the algorithm above.The program should contain 2 functions other than main that take parameters and return values.All output statements should belong to main and NOT the other functions.All calculation and/or comparison statements should exist in other functions - not main.what kind of loop do I use?
12/4/2005 5:07:44 PM
huh?
12/4/2005 5:11:30 PM
This is for either your little brother or boyfriend isn't it?
12/4/2005 5:13:38 PM
logical thinking is hard for broads
12/4/2005 5:22:18 PM
12/4/2005 6:02:19 PM
12/4/2005 6:41:04 PM
i am stuck on step 3. so far i have a user enter a password which is assigned to a string. i know how to check the string length and make it match the specifications, but i don't know what type of loop to use. i know i will need a for loop for step 6. how do i set up the do-while loop to check the password length?
12/4/2005 6:48:08 PM
You can just create an input function, a checkInput function, and an acceptInput function. You read a password, send it to checkInput, if it is bad, tell why, and go back to input, if not, go to acceptInput. That shouldn't really require a loop.
12/4/2005 7:34:39 PM
wtfjust stick to software engineering
12/4/2005 7:49:35 PM
can you use "breaks" in c++ like java? if so, just set some breaks in a do-while loop if it meets something or doesn't meet something
12/4/2005 8:03:06 PM
^ i've thought of that but i really just don't know what the fuck i'm doingthanks for your help everyone; i'm going to go shoot myself now
12/4/2005 8:06:56 PM
use a CString and use string.getLength() to get length to compare length and string.compare() to compare the 2 stringswhen you send it to the function to check its length use a global variable to set if its ok, if its not don't set it (i.e. 0 for OK, 1 for not OK). then in the main use a while loop that depends on that variable[Edited on December 4, 2005 at 8:50 PM. Reason : ]
12/4/2005 8:44:19 PM
this thread needs more pics of your tits
12/4/2005 9:16:04 PM
^ CString is MFC, not standard C++. Use std::string.
12/4/2005 9:17:04 PM
use gotos like this:
goto home;sweet:printf("sweet ");home:printf("home ");goto sweet;
12/4/2005 9:30:48 PM
there are password check programs online. hint...use the "check to see that it..." parts as conditions in your loops.[Edited on December 4, 2005 at 9:45 PM. Reason : .]
12/4/2005 9:43:43 PM
attn: americaplease use, std::basic_string<wchar_t, char_traits<wchar_t>>
12/4/2005 10:15:38 PM
OMG LIKE USEexit(0);
12/4/2005 10:17:42 PM
you're biggest favor to yourself would be to not waste your time with the responses of this thread.
12/4/2005 10:20:07 PM
I just wrote this program in C.
12/4/2005 10:36:44 PM
^^^^Unicode is for jews, terrorists, the reds, and pretty much everyone that is badUNICODE IS NOT THE AMERICAN WAY
12/4/2005 11:01:21 PM
here is what i have so far:
#include <iostream.h>#include <stdlib.h>#include <string>using namespace std;void enterPassword();void reenterPassword();string password1;string password2;int password1_length;bool valid_length = false;bool passwords_match = false;int main(){ do { cout << "Enter a password: "; cin >> password1; enterPassword(); //function call } while (valid_length = false); do { cout << "Re-enter your password: "; cin >> password2; reenterPassword(); //function call } while (passwords_match = false); system("PAUSE"); return 0;}void enterPassword() //function definition{ password1_length = password1.length(); if ( password1_length >=8 && password1_length <= 16 ) { valid_length = true; } else { valid_length = false; }}void reenterPassword() //function definition{ if ( password1 != password2 ) { passwords_match = true; } else { passwords_match = false; } }
12/5/2005 6:22:26 PM
I'm pretty sure booleans don't work like that in c++, that's how they work in java. In c++ a 0 is false and anything other than a 0 is not false. There are some other issues like prototyping that I think will break that program (don't you have to include your parameters in a prototype in c++) but yeah.. you shouldn't use globals in the first place, they're considered bad practice.off the top of my head.. for strings you use strcpr or strcompare or whatever the hell string compare is abbreviated as. there's.. a lot to work on, maybe grabbing the book would help?
12/5/2005 6:40:38 PM
maybe changing majors would help.[Edited on December 5, 2005 at 7:37 PM. Reason : this is incredibly bad]
12/5/2005 7:37:13 PM
^^In C, that's right (0 = false, nonzero = true).In C++, you can still use numbers (like I tend to), or you can use the boolean types (which I believe are just replaced with the 0/1 designation by the preprocessor).Actually, I'm out of date. The standard for C now includes a boolean type as well:http://home.att.net/~jackklein/c/inttypes.html[Edited on December 5, 2005 at 7:43 PM. Reason : new standard]
12/5/2005 7:40:18 PM
I dare you to copy this:
#include <iostream>#include <string>using namespace std;int validPassword(string pw, string *error) { if(pw.length() < 8 ) { *error = "Password too short\n"; return 0; } if(pw.length() > 16 ) { *error = "Password too long\n"; return 0; } *error = ""; return 1;}bool verifyPassword( string pw, string newPw, string *error) { if(pw.compare(newPw)) { *error = "Passwords do not match\n"; return false; } else { *error = ""; return true; }}int main (int argc, char * const argv[]) { string pw = ""; string newPw=""; string error =""; int verifyCount = 0; bool verified = false; while(!verified) { cout << error; switch(verifyCount) { case 0: cout << "Enter a new password:\n"; cin >> pw; verifyCount = validPassword(pw, &error); break; case 1: case 2: case 3: cout << "Verify password:\n"; cin >> newPw; verified = verifyPassword(pw, newPw, &error ); verifyCount++; break; case 4: verifyCount = 0; error = "Could not verify password.\n"; break; } } return 0;}
12/5/2005 9:59:29 PM
Is there a message board from the class that can narrow some stuff down?
12/5/2005 10:51:50 PM
real men jump directly into other functions, and goto directly out.
12/5/2005 11:19:09 PM
damn straight
12/5/2005 11:25:53 PM
^^ You can try and flex an e-penis all you want, but with what was posted before this person is nowhere close to doing that.Since I am no where close to being a developer... I would hope one of you would be able to do it better, but yet again that is no help to this person. We all have our strengths.
12/5/2005 11:29:34 PM
recursion!
12/5/2005 11:31:34 PM
I got it to work. thanks to those of you who attempted to help me
12/6/2005 12:05:59 AM
post your solution so your classmates can copy.
12/6/2005 2:36:29 AM
12/6/2005 5:26:29 AM