Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os.path
- import hashlib
- def passcheckfunc():
- with open ('hashes.txt', 'r') as hashes:
- check = hashes.readlines()
- passcheck = check[1]
- passcheck = passcheck.strip()
- password = raw_input("Enter your password: ")
- password = hashlib.sha512(password.encode('utf-8')).hexdigest()
- passcheck = str(passcheck)
- if passcheck == password:
- print "You now have access to this computer!"
- else:
- print "Wrong password."
- passcheckfunc()
- def usercheckfunc():
- with open ('hashes.txt', 'r') as hashes:
- check = hashes.readlines()
- username = raw_input("Enter your username: ")
- usercheck = check[0]
- usercheck = usercheck.strip()
- if username == usercheck:
- passcheckfunc()
- else:
- print "Username not found."
- login()
- def login():
- usercheckfunc()
- def register():
- username = raw_input("Enter your username: ")
- password = raw_input("Enter your password: ")
- passhash = hashlib.sha512(password.encode('utf-8')).hexdigest()
- with open ('hashes.txt', 'w') as hashes:
- hashes.write(username)
- passhash = str(passhash)
- hashes.write("{}\n{}".format(str(username),str(passhash)))
- print "You are now registered on this computer!"
- def processfunc():
- process = raw_input("What would you like to do? (Login or Register): ").lower()
- if process == 'login':
- login()
- elif process == 'register':
- register()
- else:
- print "That is not a process!"
- processfunc()
- processfunc()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement