def encode(data, checksum=True):
    """Convert binary to base58 using BASE58_ALPHABET."""

    if checksum:
        data = data + utils.hash256(data)[:4]
    v, prefix = to_long(256, lambda x: x, iter(data))
    data = from_long(v, prefix, BASE58_BASE, lambda v: BASE58_ALPHABET[v])
    return data.decode("utf8")
Convert binary to base58 using BASE58_ALPHABET.