import hashlib


def sha256_encode(text):
    """
    Returns the digest of SHA-256 of the text
    """
    _hash = hashlib.sha256
    if type(text) is str:
        return _hash(text.encode('utf8')).digest()
    elif type(text) is bytes:
        return _hash(text).digest()
    elif not text:
        # Generally for calls where the payload is empty. Eg: get calls
        # Fix for AttributeError: 'NoneType' object has no attribute 'encode'
        return _hash("".encode('utf8')).digest()
    else:
        return _hash(str(text).encode('utf-8')).digest()