rexinsteroids

registration wew

Apr 7th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <cctype>
  3. #include <conio.h>
  4. #include <cstring>
  5. #include <stdlib.h>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. string user, password, userConfirmation, passwordConfirmation;
  11. string alphaUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  12. string alphaLower = "abcdefghijklmnopqrstuvwxyz";
  13. string numer = "0123456789";
  14. string letter;
  15. char passwordTemp;
  16. int length, check1 = 1, check2 = 1, aUpCount = 0, aUpVer = 0, aLowCount = 0, aLowVer = 0, aNumCount = 0, aNumVer = 0;
  17.  
  18. while (check1 != 0)
  19. {
  20. cout<<"REGISTRATION\n";
  21. cout<<"Username: ";
  22. getline(cin, user);
  23. system("cls");
  24. cout<<"REGISTRATION\n";
  25. cout<<"Username: "<<user;
  26. cout<<"Password: ";
  27. while (check2 != 0)
  28. {
  29. for ( ; ; )
  30. {
  31. passwordTemp = getch();
  32. if (passwordTemp == '\r')
  33. {
  34. break;
  35. }
  36. password += passwordTemp;
  37. cout<<"*";
  38. }
  39. cout<<endl<<password;
  40. break;
  41. }
  42. length = password.length();
  43.  
  44. // checks if password is within 6-10 characters, repeats loop if not
  45. if ((length < 6) || (length > 10))
  46. {
  47. cout<<"DAPAT 6-10 WEW";
  48. password.clear();
  49. continue;
  50. }
  51. for (int a = 0; a <= 26; a++)
  52. {
  53. for (int b = 0; b <= length; b++)
  54. {
  55. letter = password.substr(b, 1);
  56. if (letter == alphaUpper.substr(a, 1))
  57. {
  58. aUpCount += 1;
  59. }
  60. }
  61. }
  62. for (int c = 0; c <= 26; c++)
  63. {
  64. for (int d = 0; d <= length; d++)
  65. {
  66. letter = password.substr(d, 1);
  67. if (letter == alphaLower.substr(c, 1))
  68. {
  69. aLowCount += 1;
  70. }
  71. }
  72. }
  73. for (int e = 0; e <= 10; e++)
  74. {
  75. for (int f = 0; f <= length; f++)
  76. {
  77. letter = password.substr(e, 1);
  78. if (letter == numer.substr(f, 1))
  79. {
  80. aNumCount += 1;
  81. }
  82. }
  83. }
  84.  
  85. if (aUpCount > 0)
  86. {
  87. aUpVer += 1;
  88. }
  89.  
  90. if (aLowCount > 0)
  91. {
  92. aLowVer += 1;
  93. }
  94.  
  95. if (aNumCount > 0)
  96. {
  97. aNumVer += 1;
  98. }
  99.  
  100. if ((aUpVer != 1) || (aLowVer != 1) || (aNumVer != 1))
  101. {
  102. cout<<"DI PWEDE PASSWORD MO PAPS KASI: "<<endl;
  103. if (aUpVer != 1)
  104. {
  105. cout<<"LAGYAN MO NAMAN NG CAPITALIZED LETTERS WEW"<<endl;
  106. }
  107. if (aLowVer != 1)
  108. {
  109. cout<<"LAGYAN MO NAMAN NG LOWERCASE NA LETTERS LOL"<<endl;
  110. }
  111. if (aNumVer != 1)
  112. {
  113. cout<<"LAGYAN MO NAMAN NG DIGITS YAN ;)"<<endl;
  114. }
  115. continue;
  116. }
  117. }
  118. return 0;
  119. }
  120.  
  121.  
  122.  
  123. /**int main()
  124. {
  125. string user, pass, userConf, passConf;
  126. char passTemp;
  127. int n, check = 1;
  128. int alpha = 0;
  129. bool uppCheck, lowCheck, digCheck;
  130. bool oaCheck;
  131.  
  132. Registration:
  133. cout<<"Registration\n\n";
  134. cout<<"Username: ";
  135. cin>>user;
  136. system ("cls");
  137. cout<<"Registration\n\n";
  138. cout<<"Username: "<<user<<endl;
  139. cout<<"Password: ";
  140. while (check != 0)
  141. {
  142. for (int i=0; ; )
  143. {
  144. passTemp = getch();
  145. if (passTemp == '\r')
  146. {
  147. break;
  148. }
  149. pass += passTemp;
  150. cout<<'*';
  151. }
  152. cout<<endl<<pass;
  153. break;
  154. }
  155. n = pass.length();
  156. cout<<endl<<n;
  157. char val[n+1];
  158. strcpy(val, pass.c_str());
  159. if (n < 6 || n > 10)
  160. {
  161. cout<<"Please input a password with 6-10 characters.";
  162. }
  163. else {
  164. for (int h; h <= 2; h++)
  165. {
  166. if (isalpha(val[h]) != 0)
  167. {
  168. alpha += 1;
  169. }
  170. }
  171.  
  172. if (alpha == 2)
  173. {
  174. for (int i = 0; i <= n ; i++)
  175. {
  176. if ((isupper(val[i])) != 0)
  177. {
  178. uppCheck = true;
  179. break;
  180. }
  181. else {
  182. uppCheck = false;
  183. }
  184. }
  185. }
  186.  
  187. for (int j = 0; j <= n; j++)
  188. {
  189. if ((islower(val[j])) != 0)
  190. {
  191. lowCheck = true;
  192. break;
  193. }
  194. else {
  195. lowCheck = false;
  196. }
  197. }
  198. for (int k = 0; k <= n; k++)
  199. {
  200. if ((isdigit(val[k])) != 0)
  201. {
  202. digCheck = true;
  203. break;
  204. }
  205. else {
  206. digCheck = false;
  207. }
  208. }
  209. }
  210. if ((lowCheck == true ) && (uppCheck == true) && (digCheck == true))
  211. {
  212. cout<<"Your account was successfully created.";
  213. }
  214. else {
  215. cout<<"\nYour password: \n";
  216. if (lowCheck == false)
  217. {
  218. cout<<"\n- must have at least one lowercase letter\n";
  219. oaCheck = false;
  220. }
  221. if (uppCheck == false)
  222. {
  223. cout<<"\n- must have at least one uppercase letter\n";
  224. if (oaCheck != false)
  225. {
  226. oaCheck = false;
  227. }
  228. }
  229. if (digCheck == false)
  230. {
  231. cout<<"\n- must have at least one numerical character\n";
  232. if (oaCheck != false)
  233. {
  234. oaCheck = false;
  235. }
  236. }
  237. }
  238. if (oaCheck = false)
  239. {
  240. system ("pause");
  241. system ("cls");
  242. goto Registration;
  243. }
  244.  
  245. system ("pause");
  246. system ("cls");
  247. cout<<"Registration\n\n";
  248. cout<<"Username: ";
  249. cin>>userConf;
  250. system ("cls");
  251. cout<<"Registration\n\n";
  252. cout<<"Username: "<<userConf<<endl;
  253. cout<<"Password: ";
  254. while (check != 0)
  255. {
  256. for (int l=0; ; )
  257. {
  258. passTemp = getch();
  259. if (passTemp == '\r')
  260. {
  261. break;
  262. }
  263. passConf += passTemp;
  264. cout<<'*';
  265. }
  266. cout<<endl<<passConf;
  267. break;
  268. }
  269.  
  270. if (pass == passConf)
  271. {
  272. cout<<"You have successfully confirmed your account.";
  273. }
  274. else {
  275. cout<<"Incorrect. Please confirm your password again.";
  276. }
  277. return 0;
  278. }
  279. **/
Add Comment
Please, Sign In to add comment