fddf
This commit is contained in:
parent
c3ce4c8743
commit
254995d1e4
948 changed files with 128 additions and 128 deletions
23
files/helpers/security.py
Normal file
23
files/helpers/security.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from werkzeug.security import *
|
||||
from os import environ
|
||||
|
||||
|
||||
def generate_hash(string):
|
||||
|
||||
msg = bytes(string, "utf-16")
|
||||
|
||||
return hmac.new(key=bytes(environ.get("MASTER_KEY"), "utf-16"),
|
||||
msg=msg,
|
||||
digestmod='md5'
|
||||
).hexdigest()
|
||||
|
||||
|
||||
def validate_hash(string, hashstr):
|
||||
|
||||
return hmac.compare_digest(hashstr, generate_hash(string))
|
||||
|
||||
|
||||
def hash_password(password):
|
||||
|
||||
return generate_password_hash(
|
||||
password, method='pbkdf2:sha512', salt_length=8)
|
Loading…
Add table
Add a link
Reference in a new issue