Reputation: 111
my code has different result between postman and python,and I hope that the results of Python execution are consistent with Postman.
var secret = 'gourds';
var mmd5 = 'sha1=' + CryptoJS.HmacSHA1(JSON.stringify(JSON.parse(params)),secret).toString(CryptoJS.enc.Hex);
hmac.new(str.encode('gourds'),json.dumps(json.loads(md,object_pairs_hook=OrderedDict)),sha1).hexdigest()
Upvotes: 1
Views: 395
Reputation: 111
Now I find the reason. because the content is different. Extra spaces in python scripts and incorrect encoding
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
...
json.dumps(json.loads(md,object_pairs_hook=OrderedDict),separators=(',',':'),ensure_ascii=False)
Upvotes: 1