def sign_hmac(secret, payload):
 payload = payload.encode('ascii', 'strict')
 secret = secret.encode('ascii', 'strict')
 sig = hmac.new(base64.urlsafe_b64decode(secret), payload, hashlib.sha1)
 out = base64.urlsafe_b64encode(sig.digest())
 return out.decode('utf-8')

def sign_hmac ( secret , payload ) : payload = payload . encode ( 'ascii' , 'strict' ) secret = secret . encode ( 'ascii' , 'strict' ) sig = hmac . new ( base64 . urlsafe_b64decode ( secret ) , payload , hashlib . sha1 ) out = base64 . urlsafe_b64encode ( sig . digest ( ) ) return out . decode ( 'utf-8' )
returns a base64-encoded hmac-sha1 signature of a given string .