Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- def hashpass(unhashed):
- hashedPass = hashlib.md5(unhashed.encode())
- return hashedPass.hexdigest()
- def validpass():
- length = False
- characters = False
- number = False
- while not length or not characters or not number:
- if not length:
- print("Password needs to be longer than 7 characters.")
- if not characters:
- print("Password need to include a capital.")
- if not number:
- print("Password needs to include a number.")
- passwordCheck = input("Enter password - ")
- for i in range(0, len(passwordCheck)):
- try:
- int(passwordCheck[i])
- number = True
- except ValueError:
- pass
- if len(passwordCheck) >= 7:
- length = True
- if not passwordCheck.islower():
- characters = True
- validHash = hashpass(passwordCheck)
- return validHash
- passwordFile = input('Enter the filename where the credentials are stored. - ')
- user_name = input("Enter the user's account name.")
- password = validpass()
- password1 = hashpass(input("Re-enter password - "))
- while (password != password1):
- print('Passwords do not match.')
- password1 = hashpass(input("Please re-enter - "))
- try:
- with open(passwordFile, 'w') as f:
- f.write('Username: {}\n'.format(user_name))
- f.write('Password: {}\n'.format(password))
- except OSError as e:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement