Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1. import os.path
  2. import hashlib
  3.  
  4. def passcheckfunc():
  5.     with open ('hashes.txt', 'r') as hashes:
  6.         check = hashes.readlines()
  7.         passcheck = check[1]
  8.         passcheck = passcheck.strip()
  9.     password = raw_input("Enter your password: ")
  10.     password = hashlib.sha512(password.encode('utf-8')).hexdigest()
  11.     passcheck = str(passcheck)
  12.     if passcheck == password:
  13.         print "You now have access to this computer!"
  14.     else:
  15.         print "Wrong password."
  16.         passcheckfunc()
  17.  
  18. def usercheckfunc():
  19.     with open ('hashes.txt', 'r') as hashes:
  20.         check = hashes.readlines()
  21.         username = raw_input("Enter your username: ")
  22.         usercheck = check[0]
  23.         usercheck = usercheck.strip()
  24.     if username == usercheck:
  25.         passcheckfunc()
  26.     else:
  27.         print "Username not found."
  28.         login()
  29.  
  30. def login():
  31.     usercheckfunc()
  32.  
  33. def register():
  34.     username = raw_input("Enter your username: ")
  35.     password = raw_input("Enter your password: ")
  36.     passhash = hashlib.sha512(password.encode('utf-8')).hexdigest()
  37.     with open ('hashes.txt', 'w') as hashes:
  38.         hashes.write(username)
  39.         passhash = str(passhash)
  40.         hashes.write("{}\n{}".format(str(username),str(passhash)))
  41.     print "You are now registered on this computer!"
  42.    
  43. def processfunc():
  44.     process = raw_input("What would you like to do? (Login or Register): ").lower()
  45.     if process == 'login':
  46.         login()
  47.     elif process == 'register':
  48.         register()
  49.     else:
  50.         print "That is not a process!"
  51.         processfunc()
  52.  
  53. processfunc()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement