def register(username, password):
    if check_password_strength(password, username):
        insert_sql = "insert into clients (username, password, salt) values (?, ?, ?);"
        hash_salt_pair = helpers.hash_password_salt_tuple(password)
        cursor.execute(insert_sql, (username, hash_salt_pair[0], hash_salt_pair[1]))
        conn.commit()
        print("OK")
        return True
        # password not strong enough, better throw an excpetion
    else:
        return False
def register(username, password):
    if check_password_strength(password, username):
        insert_sql = "insert into clients (username, password, salt) values (?, ?, ?);"
        hash_salt_pair = helpers.hash_password_salt_tuple(password)
        cursor.execute(insert_sql, (username, hash_salt_pair[0],
                       hash_salt_pair[1]))
        conn.commit()
        print ("OK")
        return True
        # password not strong enough, better throw an excpetion
    else:
        return False
def login(username, password):
    select_query = """SELECT id, username, balance, message
                      FROM clients
                      WHERE username = ?
                      AND password = ?
                      LIMIT 1;"""
    salt = get_user_salt(username)
    hashed_password = helpers.hash_password_salt_tuple(password, salt)[0]
    cursor.execute(select_query, (username, hashed_password))
    user = cursor.fetchone()

    if(user):
        return Client(user[0], user[1], user[2], user[3])
    return False
def login(username, password):
    select_query = """SELECT id, username, balance, message
                      FROM clients
                      WHERE username = ?
                      AND password = ?
                      LIMIT 1;"""
    salt = get_user_salt(username)
    hashed_password = helpers.hash_password_salt_tuple(password, salt)[0]
    cursor.execute(select_query, (username, hashed_password))
    user = cursor.fetchone()

    if user:
        return Client(user[0], user[1], user[2], user[3])
    return False