MCPcopy Index your code
hub / github.com/googlemaps/google-maps-services-python / sign_hmac

Function sign_hmac

googlemaps/client.py:477–492  ·  view source on GitHub ↗

Returns a base64-encoded HMAC-SHA1 signature of a given string. :param secret: The key used for the signature, base64 encoded. :type secret: string :param payload: The payload to sign. :type payload: string :rtype: string

(secret, payload)

Source from the content-addressed store, hash-verified

475
476
477def sign_hmac(secret, payload):
478 """Returns a base64-encoded HMAC-SHA1 signature of a given string.
479
480 :param secret: The key used for the signature, base64 encoded.
481 :type secret: string
482
483 :param payload: The payload to sign.
484 :type payload: string
485
486 :rtype: string
487 """
488 payload = payload.encode('ascii', 'strict')
489 secret = secret.encode('ascii', 'strict')
490 sig = hmac.new(base64.urlsafe_b64decode(secret), payload, hashlib.sha1)
491 out = base64.urlsafe_b64encode(sig.digest())
492 return out.decode('utf-8')
493
494
495def urlencode_params(params):

Callers 1

_generate_auth_urlMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected