Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Thu Dec 5 14:44:49 2019
  4.  
  5. @author: u8798995
  6. """
  7.  
  8. stop = False
  9.  
  10. password_loc = r'C:\Users\u8798995\Desktop\Password.txt'
  11.  
  12. def connect():
  13. username = input('Enter username: ')
  14. password = input('Enter password: ')
  15. if(username.lower() == 'admin' or 'root'):
  16. file = open(password_loc, '+r')
  17. if(password == file.read()):
  18. file.close()
  19. return True
  20. file.close()
  21. return False
  22.  
  23. def printCommands():
  24. print('\'quit\' - exits the program.')
  25. print('\'repass\' - change the password.')
  26. print('\'hoger\' - checks if the hoger is valid.')
  27.  
  28. def executeCommand(command):
  29. command = command.lower()
  30. if command == 'quit':
  31. quitCommand()
  32. elif command == 'repass':
  33. repassCommand()
  34. elif command == 'hoger':
  35. hogerCommand()
  36.  
  37. def quitCommand():
  38. print('Quitting...')
  39. global stop
  40. stop = True
  41.  
  42. def repassCommand():
  43. print('---------------')
  44. print('Password Change')
  45. print('---------------')
  46. dig = ('0','1','2','3','4','5','6','7','8','9')
  47. newpass = input('Enter a new password: ')
  48. if(len(newpass) < 6):
  49. print('Password should be at least 6 chars long!')
  50. elif((newpass[len(newpass)-1] not in dig) or (newpass[len(newpass)-2] not in dig)):
  51. print('Password should have 2 digits at the end!')
  52. else:
  53. file = open(password_loc, 'w')
  54. file.write(newpass)
  55. file.close()
  56. print('Password changed!')
  57.  
  58. def hogerCommand():
  59. hoger_id = input('Enter the hoger id: ')
  60. hoger_date_raw = input('Enter the date of the hoger(DD-MM-YYYY): ')
  61. hoger_date = hoger_date_raw.split('-')
  62. hoger_sex = input('Enter the sex: ')
  63.  
  64. hoger_valid = True
  65. if(len(hoger_id) > 7):
  66. hoger_valid = False
  67. elif(len(hoger_id) < 7 and int(hoger_date[2]) >= 2011):
  68. hoger_valid = False
  69.  
  70. if(hoger_valid):
  71. print('The hoger is valid!')
  72. else:
  73. print('The hoger is not valid!')
  74.  
  75. print('The hoger is not takin.')
  76.  
  77. def main():
  78. if (connect() == False):
  79. print('Login failed!')
  80. global stop
  81. stop = True
  82. else:
  83. print('Login successful!')
  84. while(stop == False):
  85. printCommands()
  86. command = input('Enter a command: ')
  87. executeCommand(command)
  88.  
  89. if __name__ == "__main__":
  90. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement