django sign item with some extra values
i recently posted a question on here and now need another answer on this based on an alteration that needs to be done based on extra params.
previously I had the following that gave me a correct signature.
signature = hashlib.sha1("i=myusername&v=%s&t=7087db23de5ef07b5723" % timestamp)
Now I need to add the following into that string exactly as follow wher开发者_如何学运维e %3D represents =
the problem, just adding in the string below, django is looking for another value.
&p=myvar%3Dmyvalue
I have tried a few version and seem to be getting the wrong value everytime. signature are not my strength, thanks for the help.
signature = hashlib.sha1(u'i=myusername&p=myvar%s%s&v=%s&t=7087db23de5ef07b5723' % ('%3D', myvalue, timestamp))
Use %%
in format string to get %
symbol
'&p=myvar%%3D%s' % 'value'
I hope I understand you.
Also you can use urllib.urlencode
>>>urllib.urlencode({'i':'fundedbyme', 'p':'myvar=%s' % myvalue})
'i=fundedbyme&p=myvar%3Dmyvalue'
精彩评论