Removed some facebook stuff, maybe adding it back later
This commit is contained in:
22
jellypy/password.py
Normal file
22
jellypy/password.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import binascii
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
|
||||
def make_hash(password):
|
||||
salt = hashlib.sha256(os.urandom(60)).hexdigest().encode('ascii')
|
||||
pwdhash = hashlib.pbkdf2_hmac('sha512', password.encode('utf-8'),
|
||||
salt, 100000)
|
||||
pwdhash = binascii.hexlify(pwdhash)
|
||||
return (salt + pwdhash).decode('ascii')
|
||||
|
||||
|
||||
def check_hash(password, stored_pw):
|
||||
salt = stored_pw[:64]
|
||||
stored_password = stored_pw[64:]
|
||||
pwdhash = hashlib.pbkdf2_hmac('sha512',
|
||||
password.encode('utf-8'),
|
||||
salt.encode('ascii'),
|
||||
100000)
|
||||
pwdhash = binascii.hexlify(pwdhash).decode('ascii')
|
||||
return pwdhash == stored_password
|
Reference in New Issue
Block a user