Postgresql hmac-sha1 signature differs from python signature -


postgres:

code:

select encode(     hmac(         e'put\n\n1\n1408355972\nx-amz-acl:bucket-owner-full-control\n/1/1',          '1sf235123',         'sha1'     ),     'base64' ); 

result: "h9wrl15mxgwrxxjqlqhbybnfj7i="

python 3

code:

base64.encodestring(     hmac.new(         'put\n\n1\n1408355972\nx-amz-acl:bucket-owner-full-control\n/1/1'.encode(),         '1sf235123'.encode(),         sha1     ).digest() ) 

result: "cru1v93ggf3qe0ovq686ir/i1ss=\n"

i want signed s3 upload request in postgres, can't right signature, have tried whole day t_t.

can give me help??? lot.

you swapping 2 first hmac parameters in python. hmac constructor takes secret first

>>> base64.encodestring( ...     hmac.new( ...         '1sf235123'.encode(), ...         'put\n\n1\n1408355972\nx-amz-acl:bucket-owner-full-control\n/1/1'.encode(), ...         sha1 ...     ).digest() ... ) b'h9wrl15mxgwrxxjqlqhbybnfj7i=\n' 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -