import hashlib

DEFAULT_SALT = b"snekker-de-snek-"


async def hash(data, salt=DEFAULT_SALT):
    try:
        data = data.encode(errors="ignore")
    except AttributeError:
        pass
    try:
        salt = salt.encode(errors="ignore")
    except AttributeError:
        pass
    salted = salt + data

    obj = hashlib.sha256(salted)
    return obj.hexdigest()


async def verify(string: str, hashed: str):
    return await hash(string) == hashed
