Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Thu Dec 5 14:44:49 2019
- @author: u8798995
- """
- stop = False
- password_loc = r'C:\Users\u8798995\Desktop\Password.txt'
- def connect():
- username = input('Enter username: ')
- password = input('Enter password: ')
- if(username.lower() == 'admin' or 'root'):
- file = open(password_loc, '+r')
- if(password == file.read()):
- file.close()
- return True
- file.close()
- return False
- def printCommands():
- print('\'quit\' - exits the program.')
- print('\'repass\' - change the password.')
- print('\'hoger\' - checks if the hoger is valid.')
- def executeCommand(command):
- command = command.lower()
- if command == 'quit':
- quitCommand()
- elif command == 'repass':
- repassCommand()
- elif command == 'hoger':
- hogerCommand()
- def quitCommand():
- print('Quitting...')
- global stop
- stop = True
- def repassCommand():
- print('---------------')
- print('Password Change')
- print('---------------')
- dig = ('0','1','2','3','4','5','6','7','8','9')
- newpass = input('Enter a new password: ')
- if(len(newpass) < 6):
- print('Password should be at least 6 chars long!')
- elif((newpass[len(newpass)-1] not in dig) or (newpass[len(newpass)-2] not in dig)):
- print('Password should have 2 digits at the end!')
- else:
- file = open(password_loc, 'w')
- file.write(newpass)
- file.close()
- print('Password changed!')
- def hogerCommand():
- hoger_id = input('Enter the hoger id: ')
- hoger_date_raw = input('Enter the date of the hoger(DD-MM-YYYY): ')
- hoger_date = hoger_date_raw.split('-')
- hoger_sex = input('Enter the sex: ')
- hoger_valid = True
- if(len(hoger_id) > 7):
- hoger_valid = False
- elif(len(hoger_id) < 7 and int(hoger_date[2]) >= 2011):
- hoger_valid = False
- if(hoger_valid):
- print('The hoger is valid!')
- else:
- print('The hoger is not valid!')
- print('The hoger is not takin.')
- def main():
- if (connect() == False):
- print('Login failed!')
- global stop
- stop = True
- else:
- print('Login successful!')
- while(stop == False):
- printCommands()
- command = input('Enter a command: ')
- executeCommand(command)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement