plz help me to solve the problem..add some more code in c/c++ related to show that the output will be password too strong or strong or weak....

    #include <iostream>
    #include <cstring>
    #include <cctype>
    using namespace std;
    bool testPass(char []);//function prototype to check password
    int main()
    {
        char *password;
        int length; //assure requested length and password length are the same
        int numCharacters; //hold number of characters for password
        cout << "Please enter how many characters you would like your\npassword to be.";
        cout << " Your password must be at least 6 characters long." << endl;
        cin >> numCharacters;

        while (numCharacters < 6)
        {
            cout << "Please enter a password length of at least 6 characters." << endl;
            cin >> numCharacters;
        }

        password = new char[numCharacters+1];

        cout << "Please enter a password that contains at least one uppercase letter, ";
        cout << "one\nlowercase letter, and at least one digit." << endl;
        cin >> password;
        length = strlen(password);
        while (length != numCharacters)
        {
            cout << "Your password is not the size you requested. ";
            cout << "Please re-enter your password." << endl;
            cin >> password;
            length = strlen(password);
        }

        if (testPass(password))
            cout << "Your password is valid." << endl;
        else
        {
            cout << "Your password is not valid. ";
            cout << "Please refer to the above warning message." << endl;
        }

        delete[] password ;
        return 0;
    }

    /*This function will check each input and ensure that the password
    contains a uppercase, lowercase, and digit.*/

    bool testPass(char pass[])
    {
        bool aUpper = false,
             aLower = false,
             aDigit = false ;
        for ( int i = 0 ; pass[i] ; ++i )
            if ( isupper(pass[i]) )
                aUpper = true ;
            else if ( islower(pass[i]) )
                aLower = true ;
            else if ( isdigit(pass[i]) )
                aDigit = true ;
        if ( aUpper && aLower && aDigit )
            return true;
        else
            return false ;
    }

Hopefully you understand the concept of bit patterns and that way at line 48 you could code whatever conditionals you need. I left out the 6 char conditional, you can stuff it in wherever it will work.

I'm also new to C++ and think there might be better ways to set/test bits.

    #include    <iostream>
    #include    <string>
    #include    <cctype>

    using namespace std;

int main () {
    string PassWord;    
    short   CharCount;
    string Prompt = "\n\t--------\n";

    cout << "\nPlease enter password, minimum 6 chars, alphanumeric" << endl;
    cout << "Must have upper/lower case and one digit" << endl;

    do {
        int charVal, Flags = 0;

        cout << hex << "\n\t-: ";
        getline (cin, PassWord);
        CharCount = PassWord.length ();

        if (!CharCount)
            { cout << "Bye" << endl; break; }

        cout << Prompt << "\t";

        for ( int Pntr = 0; Pntr < CharCount; Pntr++ ) {
          charVal = (int) PassWord [Pntr];

          if ( isalnum (charVal) ) {                      
                cout << charVal << " ";
                if ( isdigit (charVal) )
                    Flags |= 1;
                else {
                    if ( isupper (charVal) )
                        Flags |= 4;
                    else
                        Flags |= 2;
                    }
                }
            else {
                cout << "XX ";
                Flags |= 128;
                }
            }

            cout << Prompt << "\nFlags: " << Flags;
            // Prompt user here             
        } while ( 1 );

    return 0;
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.