from src import bcrypt

def encrypt_password(password):
    if isinstance(password, bytes):
        password = password.decode("utf-8")
    return bcrypt.generate_password_hash(password, rounds=12).decode("utf-8")

def check_password(hashed_password, password):
    if isinstance(hashed_password, bytes):
        hashed_password = hashed_password.decode("utf-8")
    if isinstance(password, bytes):
        password = password.decode("utf-8")
    return bcrypt.check_password_hash(hashed_password, password)
