Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- class networkAccess:
- def __init__(self):
- self.password = self.def_pwd()
- print("Your default password: " + self.password)
- self.username = self.create_username()
- print("Your username: " + self.username)
- self.change_pwd()
- print("Your new password: " + self.password)
- def set_firstname(self, name):
- self.firstname = name
- def set_middlename(self, name):
- self.middlename = name
- def set_lastname(self, name):
- self.lastname = name
- def set_username(self, username):
- self.username = username
- def create_username(self):
- first = raw_input("Enter your first name: ")
- self.set_firstname(first)
- middle = raw_input("Enter your middle name: ")
- self.set_middlename(middle)
- last = raw_input("Enter your last name: ")
- self.set_lastname(last)
- new_username = self.firstname.lower()[0] + self.middlename.lower()[0] + self.lastname.lower()[0] + str(random.randint(100,999))
- self.set_username(new_username)
- return new_username
- def def_pwd(self):
- num_of_upper = random.randint(2,4)
- num_of_lower = random.randint(2,4)
- num_of_number = random.randint(2,4)
- num_of_symbol = random.randint(2,4)
- pwd = ""
- for i in range(num_of_upper):
- upper = chr(random.randint(65,90))
- pwd = pwd + upper
- for i in range(num_of_lower):
- lower = chr(random.randint(97,122))
- pwd = pwd + lower
- for i in range(num_of_number):
- num = chr(random.randint(48,57))
- pwd = pwd + num
- for i in range(num_of_symbol):
- symbol = chr(random.randint(58,64))
- pwd = pwd + symbol
- l = list(pwd)
- random.shuffle(l)
- pwd = ''.join(l)
- return pwd
- def change_pwd(self):
- password = raw_input("Enter your new password: ")
- numbers = 0
- symbols = 0
- upper = 0
- lower = 0
- for L in password:
- o = ord(L)
- if(o >= 48 and o <= 57):
- numbers += 1
- if((o >= 32 and o <= 47) or (o >= 58 and o <= 64) or (o >= 91 and o <= 96) or (o >= 123 and o <= 126)):
- symbols += 1
- if(o >= 65 and o <= 90):
- upper += 1
- if(o >= 97 and o <= 122):
- lower += 1
- if(numbers < 1):
- print("***Password must contain at least one number***")
- return False
- if(symbols < 1):
- print("***Password must contain at least one symbol***")
- return False
- if(upper < 1):
- print("***Password must contain at least one uppercase letter***")
- return False
- if(len(password) < 8):
- print("***Passoword must be at least 8 characters long***")
- return False
- if(password == self.password):
- print("***Passoword can't be the same as the old one***")
- return False
- if(self.firstname.lower() in password.lower() or self.lastname.lower() in password.lower):
- print("***Passoword can't contain your first nor your last name***")
- self.password = password
- return True
- network = networkAccess()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement