Skip to content

Signature differs from Python 2 to 3 #23

Open

Description

@jesebo

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).

Activity

  1. TuxCoder commented on Jul 25, 2016

    @TuxCoder

    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
  2. ScottieKramer commented on Jan 24, 2017

    @ScottieKramer

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

  3. giopromolla commented on Jan 24, 2018

    @giopromolla

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions