def _fast_hmac(key, msg, digest):
 (dig1, dig2) = (digest(), digest())
 if (len(key) > dig1.block_size):
  key = digest(key).digest()
 key += ('\x00' * (dig1.block_size - len(key)))
 dig1.update(key.translate(_trans_36))
 dig1.update(msg)
 dig2.update(key.translate(_trans_5c))
 dig2.update(dig1.digest())
 return dig2

def _fast_hmac ( key , msg , digest ) : ( dig1 , dig2 ) = ( digest ( ) , digest ( ) ) if ( len ( key ) > dig1 . block_size ) : key = digest ( key ) . digest ( ) key += ( '\x00' * ( dig1 . block_size - len ( key ) ) ) dig1 . update ( key . translate ( _trans_36 ) ) dig1 . update ( msg ) dig2 . update ( key . translate ( _trans_5c ) ) dig2 . update ( dig1 . digest ( ) ) return dig2
a trimmed down version of pythons hmac implementation .