Guest User

Untitled

a guest
Feb 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from base64 import b64decode, b64encode
  3. import hashlib
  4.  
  5. f = 'users.csv'
  6.  
  7. d = open(f).read()
  8. d = d.decode('utf16')
  9.  
  10. username = raw_input('your ars username: ')
  11. m1 = hashlib.sha1()
  12.  
  13. for i in d.splitlines():
  14. if i.strip() != '':
  15. user, salt, hash = i.split(',')
  16. # Clean up any whitespace
  17. user = user.strip()
  18. salt = salt.strip()
  19. hash = hash.strip()
  20.  
  21. # Convert b64 salt to binary
  22. binsalt = b64decode(salt)
  23.  
  24. if user == username:
  25. pw_string = unicode(raw_input('your ars password: ').strip())
  26.  
  27. # Get bytes
  28. pw_string_bytes = pw_string.encode("utf8")
  29. # Pass in salt
  30. m1.update(binsalt)
  31. # Pass in password
  32. m1.update(pw_string)
  33. # B64 encode the binary digest
  34. if b64encode(m1.digest()) == hash:
  35. print "Logged in!"
  36. else:
  37. print "Didn't match"
Add Comment
Please, Sign In to add comment