开发者

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'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜