Advertisement
Guest User

Untitled

a guest
Apr 8th, 2018
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. • Function main()
  2. o PRINT welcome prompt
  3. o WHILE loginAttempts are less than MAX_LOGIN_ATTEMPTS
  4. • PRINT “Username: “
  5. • SET usernameEntry equal to user response
  6. • PRINT “Password: “
  7. • SET passwordEntry equal to user response
  8. • SET passwordEncrypted equal to md5Encrypt(passwordEntry)
  9. • SET authenticated equal to authenticate(usernameEntry, passwordEncrypted)
  10. • IF authenticated equals true
  11. • SET loginAttempts equal to 0
  12. • ELSE
  13. • INCREMENT loginAttempts
  14. • ENDIF
  15. • IF loginAttempts is equal to MAX_LOGIN_ATTEMPTS
  16. • PRINT “Too many attempts”
  17. • PRINT “Press Enter to quit”
  18. • WAIT for enter key
  19. • END PROGRAM
  20. • ENDIF
  21. o ENDWHILE
  22. • Function md5Encrypt(plaintext)
  23. o DO magic
  24. o RETURN encrypted
  25. • Function authenticate(username, password)
  26. o OPEN credentials.txt as new File wrapped in a Scanner
  27. o WHILE credentials file has next line
  28. • FOR col (one through four)
  29. • SWITCH col
  30. • CASE 1
  31. o SET fileUsername equal to next word
  32. • CASE 2
  33. o SET fileMD5 equal to next word
  34. • CASE 3
  35. o SET filePassword equal to next word
  36. • CASE 4
  37. o SET fileRole equal to next word
  38. o IF fileUsername equals username AND filePassword equals password
  39. • CALL accessGranted(username, fileRole)
  40. o ENDIF
  41. • ENDSWITCH
  42. o RETURN false
  43. • Function accessGranted(username, role)
  44. o SET roleFile equal to role plus “.txt”
  45. o OPEN roleFile as File wrapped in a Scanner
  46. o WHILE roleFile has next line
  47. • PRINT line of file
  48. o ENDWHILE
  49. o PRINT logout prompt
  50. o WAIT for enter key to be pressed
  51. o CALL Authentication.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement