import hashlib


def _get_subscriber_hash(email: str) -> str:
    """Returns Mailchimp subscriber hash from email.

    Args:
        email: str. The email of the user.

    Returns:
        str. The subscriber hash corresponding to the input email.

    Raises:
        Exception. Invalid type for email, expected string.
    """
    if not isinstance(email, str):
        raise Exception(
            'Invalid type for email. Expected string, received %s' % email)
    md5_hash = hashlib.md5()
    # The md5 accepts only bytes, so we first need to encode the email to bytes.
    md5_hash.update(email.encode('utf-8'))
    return md5_hash.hexdigest()