Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os.path #Module that allows us to check if a file exists
- import hashlib #Hash encryption module
- def createAccount(): #No params
- print ("Create Account")
- usernameLoop = True #Loop vars
- passwordLoop = True
- while usernameLoop == True: #will loop question until satisfied
- username = raw_input ("Username: ")
- if username == "exit": # will break out loop => then function if 'exit'
- usernameLoop = False
- break #break loop
- else:
- usernameFile = username + ".txt"
- x = os.path.isfile(usernameFile)
- if x == True:
- print ("Username Taken")
- elif x == False: #username doesnt exist, so can create new one
- print ("Username doesn't exist, creating file")
- userFile = open (usernameFile, "w")
- while passwordLoop == True:
- password = raw_input ("Password: ")
- password = password.encode("utf-8")
- if password == 'exit':
- break
- else:
- hash = hashlib.md5( 'textUtf8' )
- password = hash.hexdigest()
- userFile.write(password)
- userFile.close()
- usernameLoop = False
- passwordLoop = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement