File size: 436 Bytes
4fb50a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from Resources.salt import salt
import hashlib


def encrypt(password):
    result = hashlib.pbkdf2_hmac('sha256', bytes(password, "utf-8"), salt, 100000)
    return result.hex()


def auth_function(username, password, db_ref):
    user_password = db_ref.child(username).get()
    if user_password is None:
        return False
    pass_input = encrypt(password)
    if user_password == pass_input:
        return True
    return False