Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 where %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))
like image 202
ApPeL Avatar asked Jan 01 '26 12:01

ApPeL


1 Answers

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'
like image 94
srusskih Avatar answered Jan 03 '26 02:01

srusskih



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!