Password manager

This commit is contained in:
zuk 2017-02-09 22:53:54 +01:00
parent aff4758ac8
commit 9001204c9e

17
password_manager.py Normal file
View file

@ -0,0 +1,17 @@
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))