rudemaps/password_manager.py

20 lines
591 B
Python
Raw Normal View History

2017-02-09 22:53:54 +01:00
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))
2017-02-26 11:42:14 +01:00
def login_validation(auth,auth_value):
#TBD
return True