def hash_data(data, hashlen=None, alphabet=None):
    r
    if alphabet is None:
        alphabet = ALPHABET_27
    if hashlen is None:
        hashlen = HASH_LEN2
    if isinstance(data, stringlike) and len(data) == 0:
        text = (alphabet[0] * hashlen)
    else:
        hasher = hashlib.sha512()
        _update_hasher(hasher, data)
        text = hasher.hexdigest()
        hashstr2 = convert_hexstr_to_bigbase(text, alphabet, bigbase=len(alphabet))
        text = hashstr2[:hashlen]
        return text