import hashlib


def _key(counter_type, counter_name):
    """
    We store a hashed version of the key because what we generate can be
    too long, and it's possible the POST data we get could contain characters
    that memcache doesn't like.
    """
    key = "security.authentication_throttling.%s:%s" % (
        counter_type,
        counter_name,
    )
    return hashlib.sha1(key.encode('ascii')).hexdigest()