Advertisement
Guest User

Untitled

a guest
Oct 10th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. void UserPrompts()
  2. {
  3. char enteredId[32];
  4. char enteredPw[12];
  5. char hashedPW[32];
  6. int n = 5;
  7. int attempts = 0;
  8. int size = 60;
  9. // Get user input
  10. printf("Input User ID: ");
  11. fgets(enteredId, 32, stdin);
  12. usrNameValidity(enteredId);
  13.  
  14. // Clean out new input so it matches perfectly with what's in the array
  15. enteredId[strcspn(enteredId, "\r\n")] = '\0';
  16. //User = malloc(sizeof(User) * size); // Allows up to 60 users (fixed size)
  17. for (int i=0;i<size;i++)
  18. {
  19. if (strcmp(enteredId,user[i].Id) == 0) //strcmp(pw1,pw2) == 0 //
  20. {
  21. int location = i;
  22. printf("ID found\n");
  23. PasswordCreation(location);
  24. }
  25. }
  26. printf("INVALID, ID NOT FOUND! ");
  27. userCreation();
  28.  
  29. }
  30. void PasswordCreation(int location)
  31. {
  32. int n = 5;
  33. int i = location;
  34. int attempts = 0;
  35. int size = 60;
  36. char enteredId[32];
  37. char enteredPw [13];
  38. //char hashedPW[32];
  39. char ahashedPW[13];
  40. //while(attempts < n)
  41. //{
  42. printf("\n Enter password: ");
  43. fgets(enteredPw,13,stdin); // might need the same fix as above
  44. //passwordChecker(enteredPw);
  45. passwordHasher(enteredPw, ahashedPW);
  46. printf("%s", ahashedPW);
  47. printf("\n%s", user[i].hashPW);
  48. if (!(strcmp(ahashedPW, user[i].hashPW) == 0))
  49. {
  50.  
  51. printf("\nEnter New Password: ");
  52. fgets(enteredPw,12,stdin);
  53. passwordChecker(enteredPw);
  54. passwordHasher(enteredPw, ahashedPW);
  55. strcpy(user[i].hashPW, ahashedPW);
  56. fileRepop();
  57. printf("your password has been changed");
  58. attempts = n;
  59. }
  60. attempts ++;
  61. //}
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement