20 lines
No EOL
591 B
Python
20 lines
No EOL
591 B
Python
import hashlib
|
|
import os
|
|
import binascii
|
|
|
|
__ROUNDS=100000
|
|
|
|
def gen_salt(size=16):
|
|
return binascii.hexlify(os.urandom(size))
|
|
|
|
def encrypt_password(password,salt=None):
|
|
salt=binascii.unhexlify(salt) if salt else ''
|
|
return binascii.hexlify(hashlib.pbkdf2_hmac("sha512",password,salt,__ROUNDS))
|
|
|
|
def check_password(encrypted_password,clear_password,salt=None):
|
|
salt=binascii.unhexlify(salt) if salt else ''
|
|
return encrypted_password==binascii.hexlify(hashlib.pbkdf2_hmac("sha512",clear_password,salt,__ROUNDS))
|
|
|
|
def login_validation(auth,auth_value):
|
|
#TBD
|
|
return True |