def salted_hmac(key_salt, value, secret=None):
    if secret is None:
        secret = settings.SECRET_KEY

    # We need to generate a derived key from our base key.  We can do this by
    # passing the key_salt and our base key through a pseudo-random function and
    # SHA1 works nicely.
    key = hashlib.sha1(key_salt + secret).digest()

    # If len(key_salt + secret) > sha_constructor().block_size, the above
    # line is redundant and could be replaced by key = key_salt + secret, since
    # the hmac module does the same thing for keys longer than the block size.
    # However, we need to ensure that we *always* do this.
    return hmac.new(key, msg=value, digestmod=hashlib.sha1)
Test Python virtualenv creation
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/django/utils/crypto.py/salted_hmac--crossover with--dataset/ETHPy150Open ronnix/fabtools/fabtools/tests/functional_tests/test_python.py/test_require_virtualenv