'Creates & returns the HTTP ``Authorization`` header for use with Digest
Auth.'

def create_digest(self, username, api_key, method, uri):

    from tastypie.authentication import hmac, sha1, uuid, python_digest
    new_uuid = uuid.uuid4()
    opaque = hmac.new(str(new_uuid).encode(u'utf-8'), digestmod=sha1).hexdigest().decode(u'utf-8')
    return python_digest.build_authorization_request(username, method.upper(), uri, 1, digest_challenge=python_digest.build_digest_challenge(time.time(), settings.SECRET_KEY, u'django-tastypie', opaque, False), password=api_key)
