Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from base64 import b64decode, b64encode
- import hashlib
- f = 'users.csv'
- d = open(f).read()
- d = d.decode('utf16')
- username = raw_input('your ars username: ')
- m1 = hashlib.sha1()
- for i in d.splitlines():
- if i.strip() != '':
- user, salt, hash = i.split(',')
- # Clean up any whitespace
- user = user.strip()
- salt = salt.strip()
- hash = hash.strip()
- # Convert b64 salt to binary
- binsalt = b64decode(salt)
- if user == username:
- pw_string = unicode(raw_input('your ars password: ').strip())
- # Get bytes
- pw_string_bytes = pw_string.encode("utf8")
- # Pass in salt
- m1.update(binsalt)
- # Pass in password
- m1.update(pw_string)
- # B64 encode the binary digest
- if b64encode(m1.digest()) == hash:
- print "Logged in!"
- else:
- print "Didn't match"
Add Comment
Please, Sign In to add comment