Password manager
This commit is contained in:
parent
aff4758ac8
commit
9001204c9e
1 changed files with 17 additions and 0 deletions
17
password_manager.py
Normal file
17
password_manager.py
Normal 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))
|
||||
|
Loading…
Reference in a new issue