Advertisement
Guest User

Untitled

a guest
May 9th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1.  
  2. import os.path #Module that allows us to check if a file exists
  3. import hashlib #Hash encryption module
  4.  
  5.  
  6.  
  7. def createAccount(): #No params
  8. print ("Create Account")
  9. usernameLoop = True #Loop vars
  10. passwordLoop = True
  11.  
  12. while usernameLoop == True: #will loop question until satisfied
  13. username = raw_input ("Username: ")
  14. if username == "exit": # will break out loop => then function if 'exit'
  15. usernameLoop = False
  16. break #break loop
  17. else:
  18. usernameFile = username + ".txt"
  19. x = os.path.isfile(usernameFile)
  20. if x == True:
  21. print ("Username Taken")
  22. elif x == False: #username doesnt exist, so can create new one
  23. print ("Username doesn't exist, creating file")
  24. userFile = open (usernameFile, "w")
  25. while passwordLoop == True:
  26. password = raw_input ("Password: ")
  27. password = password.encode("utf-8")
  28. if password == 'exit':
  29. break
  30. else:
  31. hash = hashlib.md5( 'textUtf8' )
  32. password = hash.hexdigest()
  33. userFile.write(password)
  34. userFile.close()
  35. usernameLoop = False
  36. passwordLoop = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement