Advertisement
Guest User

Untitled

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