def github_signature(string, shared_secret, challenge_hmac):
 if six.PY3:
  msg = salt.utils.to_bytes(string)
  key = salt.utils.to_bytes(shared_secret)
  (hashtype, challenge) = salt.utils.to_bytes(challenge_hmac).split('=')
 else:
  msg = string
  key = shared_secret
  (hashtype, challenge) = challenge_hmac.split('=')
 hmac_hash = hmac.new(key, msg, getattr(hashlib, hashtype))
 return (hmac_hash.hexdigest() == challenge)

def github_signature ( string , shared_secret , challenge_hmac ) : if six . PY3 : msg = salt . utils . to_bytes ( string ) key = salt . utils . to_bytes ( shared_secret ) ( hashtype , challenge ) = salt . utils . to_bytes ( challenge_hmac ) . split ( '=' ) else : msg = string key = shared_secret ( hashtype , challenge ) = challenge_hmac . split ( '=' ) hmac_hash = hmac . new ( key , msg , getattr ( hashlib , hashtype ) ) return ( hmac_hash . hexdigest ( ) == challenge )
verify a challenging hmac signature against a string / shared-secret for github webhooks .