def get_signature()

in mns/mns_client.py [0:0]


    def get_signature(self, method, headers, resource, credential):
        content_md5 = self.get_element('content-md5', headers)
        content_type = self.get_element('content-type', headers)
        date = self.get_element('date', headers)
        canonicalized_resource = resource
        canonicalized_mns_headers = ""
        if len(headers) > 0:
            x_header_list = headers.keys()
            #x_header_list.sort()
            x_header_list = sorted(x_header_list)
            for k in x_header_list:
                if k.startswith('x-mns-'):
                    canonicalized_mns_headers += k + ":" + headers[k] + "\n"
        string_to_sign = "%s\n%s\n%s\n%s\n%s%s" % (method, content_md5, content_type, date, canonicalized_mns_headers, canonicalized_resource)
        #hmac only support str in python2.7
        #tmp_key = self.access_key.encode('utf-8') if isinstance(self.access_key, unicode) else self.access_key
        tmp_key = credential.get_access_key_secret().encode('utf-8')
        h = hmac.new(tmp_key, string_to_sign.encode('utf-8'), hashlib.sha1)
        signature = base64.b64encode(h.digest())
        signature = "MNS " + credential.get_access_key_id() + ":" + signature.decode('utf-8')
        return signature