Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature differs from Python 2 to 3 #23

Open
jesebo opened this issue Mar 14, 2016 · 3 comments
Open

Signature differs from Python 2 to 3 #23

jesebo opened this issue Mar 14, 2016 · 3 comments

Comments

@jesebo
Copy link

jesebo commented Mar 14, 2016

Hi,
I try the exemple :

import jws
header = { 'alg': 'HS256' }
payload = { 'claim': 'JSON is the raddest.', 'iss': 'brianb' }
signature = jws.sign(header, payload, 'secret')

With Python 2.7.9 et 3.4.3, I get 2 signatures different : 9CG_vCmpr-UFKbkTtelFS2o9hJm1groP5vqUUKeV84c (3) and jn0z1avR1-tKtXjuEEVsGeBWHVx5E6YjzHEWmrkAdCY (2).
Python 2 seems to be ok (same as another language).

@TuxCoder
Copy link

TuxCoder commented Jul 25, 2016

Have the same issue, think it comes from jws/init.py#L56
In python 3 is is not <base64>.<base64>. It is because a binary string is casted to string: b\'<base64>.b\'<base64>

I fixed it with a quick and dirty fix.

def jws_signing_input(head, payload, is_json=False):
    enc = jws.utils.to_base64 if is_json else jws.utils.encode
    head_input, payload_input = map(enc, [head, payload])
    return "%s.%s" % (head_input.decode('ascii'), payload_input.decode('ascii'))
jws._signing_input=jws_signing_input

@ScottieKramer
Copy link

Ran into the same issue. I submitted a pull request .

@giopromolla
Copy link

Hi, I need these! Is there any possibilty to be admin and accept the pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants