(key, msg, digest)
return outer.digest()
Fast inline implementation of HMAC.

    key: bytes or buffer, The key for the keyed hash object.
    msg: bytes or buffer, Input message.
    digest: A hash name suitable for hashlib.new() for best performance. *OR*
            A hashlib constructor returning a new hash object. *OR*
            A module supporting PEP 247.
Fast inline implementation of HMAC.
Fast inline implementation of HMAC .
def digest(key, msg, digest):
    """Fast inline implementation of HMAC.

    key: bytes or buffer, The key for the keyed hash object.
    msg: bytes or buffer, Input message.
    digest: A hash name suitable for hashlib.new() for best performance. *OR*
            A hashlib constructor returning a new hash object. *OR*
            A module supporting PEP 247.
    """
    if _hashopenssl is not None and isinstance(digest, (str, _functype)):
        try:
            return _hashopenssl.hmac_digest(key, msg, digest)
        except _hashopenssl.UnsupportedDigestmodError:
            pass

    if callable(digest):
        digest_cons = digest
    elif isinstance(digest, str):
        digest_cons = lambda d=b'': _hashlib.new(digest, d)
    else:
        digest_cons = lambda d=b'': digest.new(d)

    inner = digest_cons()
    outer = digest_cons()
    blocksize = getattr(inner, 'block_size', 64)
    if len(key) > blocksize:
        key = digest_cons(key).digest()
    key = key + b'\x00' * (blocksize - len(key))
    inner.update(key.translate(trans_36))
    outer.update(key.translate(trans_5C))
    inner.update(msg)
    outer.update(inner.digest())
    return outer.digest()
def digest ( key , msg , digest ) : if _hashopenssl is not None and isinstance ( digest , ( str , _functype ) ) : try : return _hashopenssl . hmac_digest ( key , msg , digest ) except _hashopenssl . UnsupportedDigestmodError : pass if callable ( digest ) : digest_cons = digest elif isinstance ( digest , str ) : digest_cons = lambda d = b'' : _hashlib . new ( digest , d ) else : digest_cons = lambda d = b'' : digest . new ( d ) inner = digest_cons ( ) outer = digest_cons ( ) blocksize = getattr ( inner , 'block_size' , 64 ) if len ( key ) > blocksize : key = digest_cons ( key ) . digest ( ) key = key + b'\x00' * ( blocksize - len ( key ) ) inner . update ( key . translate ( trans_36 ) ) outer . update ( key . translate ( trans_5C ) ) inner . update ( msg ) outer . update ( inner . digest ( ) ) return outer . digest ( )