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

not working in python 2 #2

Open
dejansa opened this issue Jan 9, 2017 · 2 comments
Open

not working in python 2 #2

dejansa opened this issue Jan 9, 2017 · 2 comments

Comments

@dejansa
Copy link

dejansa commented Jan 9, 2017

I found issue in authenticate method.

problem is bytes which is different in python 2 and python 3
in python 2 it is alias to str:
bytes = str

in python 3 it is: “bytes” object, which is an immutable sequence of integers in the range 0 <= x < 256

I think this will explain it better:

In [1]: private_key=[0x00] * 16

In [2]: private_key
Out[2]: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

In [3]: bytes(private_key)
Out[3]: '[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]'

In [4]: def bytes(k):
   ...:     return str(bytearray(k))
   ...: 

In [5]: bytes(private_key)
Out[5]: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

problem first appears in line:
k = pyDes.triple_des(bytes(private_key), pyDes.CBC, initial_value, pad=None, padmode=pyDes.PAD_NORMAL)

beacuse pyDes.triple_des expects sequence of bytes as first parameter it fails

I solved it by hiding original python 2 bytes with one from my example, but I am not sur wil that work in python 3 and is it right way to solve this issue.

then I found another issue but let solve this first.

@dejansa dejansa changed the title not woring in python 2 not wokring in python 2 Jan 9, 2017
@dejansa dejansa changed the title not wokring in python 2 not working in python 2 Jan 9, 2017
@eoghanj
Copy link

eoghanj commented Jan 9, 2017 via email

@capripio
Copy link

This issue hasn't solved yet? @dejansa how did you solve this issue?

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

3 participants