Guest User

Untitled

a guest
Feb 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. bool validatePass(char *);
  7.  
  8. int main()
  9. {
  10. char password(100);
  11. bool exit = false;
  12.  
  13. // Name of App.
  14. cout << "Password Verification Program: " << endl << endl;
  15.  
  16. while (exit == false)
  17. {
  18. cout << endl << "Enter a Password: ";
  19. cin.getline(password,99);
  20.  
  21. exit = validatePass(password);
  22. }
  23. cout << endl << "Password Accepted" << endl;
  24.  
  25. //Password Validation Function
  26. bool validatePass(char *array);
  27. {
  28. int length, upCount=0, lowCount=0, digCount=0;
  29. length = strlen(array);
  30. if (length<6)
  31. {
  32. cout << "Password must be at least 6 characters in length";
  33. return false;
  34. }
  35.  
  36. for (int i=0; i<length; i++)
  37. {
  38. if(isupper(array[i]) > 0)
  39. upCount++;
  40. if(islower(array[i]) > 0)
  41. lowCount++;
  42. if(isdigit(array[i]) > 0)
  43. digCount++;
  44. }
  45.  
  46. if(upCount == 0)
  47. {
  48. cout << endl << "Password must contain at least 1 UPPER case character";
  49. return false;
  50. }
  51. if(lowCount == 0)
  52. {
  53. cout << endl << "Password must contain at least 1 LOWER case character";
  54. return false;
  55. }
  56. if(digCount == 0)
  57. {
  58. cout << endl << "Password must contain at least ONE numeric chracter";
  59. return false;
  60. }
  61. return true;
  62. }
Add Comment
Please, Sign In to add comment