-
Notifications
You must be signed in to change notification settings - Fork 13
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
Comments
Thanks for the info. I will take a look when I get a chance. Was some time
ago. I appreciate that!
Eoghan
…On 9 Jan 2017 08:40, "dejansa" ***@***.***> wrote:
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGej7VZy4sSixdFTpbfZ_ehkomrhrz0Jks5rQfKLgaJpZM4LeCIl>
.
|
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
I found issue in authenticate method.
problem is
bytes
which is different in python 2 and python 3in 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:
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 failsI 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.
The text was updated successfully, but these errors were encountered: