Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cctype>
- #include <conio.h>
- #include <cstring>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- string user, password, userConfirmation, passwordConfirmation;
- string alphaUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- string alphaLower = "abcdefghijklmnopqrstuvwxyz";
- string numer = "0123456789";
- string letter;
- char passwordTemp;
- int length, check1 = 1, check2 = 1, aUpCount = 0, aUpVer = 0, aLowCount = 0, aLowVer = 0, aNumCount = 0, aNumVer = 0;
- while (check1 != 0)
- {
- cout<<"REGISTRATION\n";
- cout<<"Username: ";
- getline(cin, user);
- system("cls");
- cout<<"REGISTRATION\n";
- cout<<"Username: "<<user;
- cout<<"Password: ";
- while (check2 != 0)
- {
- for ( ; ; )
- {
- passwordTemp = getch();
- if (passwordTemp == '\r')
- {
- break;
- }
- password += passwordTemp;
- cout<<"*";
- }
- cout<<endl<<password;
- break;
- }
- length = password.length();
- // checks if password is within 6-10 characters, repeats loop if not
- if ((length < 6) || (length > 10))
- {
- cout<<"DAPAT 6-10 WEW";
- password.clear();
- continue;
- }
- for (int a = 0; a <= 26; a++)
- {
- for (int b = 0; b <= length; b++)
- {
- letter = password.substr(b, 1);
- if (letter == alphaUpper.substr(a, 1))
- {
- aUpCount += 1;
- }
- }
- }
- for (int c = 0; c <= 26; c++)
- {
- for (int d = 0; d <= length; d++)
- {
- letter = password.substr(d, 1);
- if (letter == alphaLower.substr(c, 1))
- {
- aLowCount += 1;
- }
- }
- }
- for (int e = 0; e <= 10; e++)
- {
- for (int f = 0; f <= length; f++)
- {
- letter = password.substr(e, 1);
- if (letter == numer.substr(f, 1))
- {
- aNumCount += 1;
- }
- }
- }
- if (aUpCount > 0)
- {
- aUpVer += 1;
- }
- if (aLowCount > 0)
- {
- aLowVer += 1;
- }
- if (aNumCount > 0)
- {
- aNumVer += 1;
- }
- if ((aUpVer != 1) || (aLowVer != 1) || (aNumVer != 1))
- {
- cout<<"DI PWEDE PASSWORD MO PAPS KASI: "<<endl;
- if (aUpVer != 1)
- {
- cout<<"LAGYAN MO NAMAN NG CAPITALIZED LETTERS WEW"<<endl;
- }
- if (aLowVer != 1)
- {
- cout<<"LAGYAN MO NAMAN NG LOWERCASE NA LETTERS LOL"<<endl;
- }
- if (aNumVer != 1)
- {
- cout<<"LAGYAN MO NAMAN NG DIGITS YAN ;)"<<endl;
- }
- continue;
- }
- }
- return 0;
- }
- /**int main()
- {
- string user, pass, userConf, passConf;
- char passTemp;
- int n, check = 1;
- int alpha = 0;
- bool uppCheck, lowCheck, digCheck;
- bool oaCheck;
- Registration:
- cout<<"Registration\n\n";
- cout<<"Username: ";
- cin>>user;
- system ("cls");
- cout<<"Registration\n\n";
- cout<<"Username: "<<user<<endl;
- cout<<"Password: ";
- while (check != 0)
- {
- for (int i=0; ; )
- {
- passTemp = getch();
- if (passTemp == '\r')
- {
- break;
- }
- pass += passTemp;
- cout<<'*';
- }
- cout<<endl<<pass;
- break;
- }
- n = pass.length();
- cout<<endl<<n;
- char val[n+1];
- strcpy(val, pass.c_str());
- if (n < 6 || n > 10)
- {
- cout<<"Please input a password with 6-10 characters.";
- }
- else {
- for (int h; h <= 2; h++)
- {
- if (isalpha(val[h]) != 0)
- {
- alpha += 1;
- }
- }
- if (alpha == 2)
- {
- for (int i = 0; i <= n ; i++)
- {
- if ((isupper(val[i])) != 0)
- {
- uppCheck = true;
- break;
- }
- else {
- uppCheck = false;
- }
- }
- }
- for (int j = 0; j <= n; j++)
- {
- if ((islower(val[j])) != 0)
- {
- lowCheck = true;
- break;
- }
- else {
- lowCheck = false;
- }
- }
- for (int k = 0; k <= n; k++)
- {
- if ((isdigit(val[k])) != 0)
- {
- digCheck = true;
- break;
- }
- else {
- digCheck = false;
- }
- }
- }
- if ((lowCheck == true ) && (uppCheck == true) && (digCheck == true))
- {
- cout<<"Your account was successfully created.";
- }
- else {
- cout<<"\nYour password: \n";
- if (lowCheck == false)
- {
- cout<<"\n- must have at least one lowercase letter\n";
- oaCheck = false;
- }
- if (uppCheck == false)
- {
- cout<<"\n- must have at least one uppercase letter\n";
- if (oaCheck != false)
- {
- oaCheck = false;
- }
- }
- if (digCheck == false)
- {
- cout<<"\n- must have at least one numerical character\n";
- if (oaCheck != false)
- {
- oaCheck = false;
- }
- }
- }
- if (oaCheck = false)
- {
- system ("pause");
- system ("cls");
- goto Registration;
- }
- system ("pause");
- system ("cls");
- cout<<"Registration\n\n";
- cout<<"Username: ";
- cin>>userConf;
- system ("cls");
- cout<<"Registration\n\n";
- cout<<"Username: "<<userConf<<endl;
- cout<<"Password: ";
- while (check != 0)
- {
- for (int l=0; ; )
- {
- passTemp = getch();
- if (passTemp == '\r')
- {
- break;
- }
- passConf += passTemp;
- cout<<'*';
- }
- cout<<endl<<passConf;
- break;
- }
- if (pass == passConf)
- {
- cout<<"You have successfully confirmed your account.";
- }
- else {
- cout<<"Incorrect. Please confirm your password again.";
- }
- return 0;
- }
- **/
Add Comment
Please, Sign In to add comment