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

Crypto error when encoding password: TypeError: Object type <class 'str'> cannot be passed to C code #131

Open
castrapel opened this issue Nov 29, 2018 · 2 comments

Comments

@castrapel
Copy link

Hello,

On my Mac development machine, I'm receiving a crypto error encoding the password when I try to create a DynectSession. This works fine on our production Linux boxes.

Here's how I'm creating a DynectSession with customer name, username, and password (all strings),

dynect_session = DynectSession(
        "customer_name",
        "username",
        "password",
    )

Here's the traceback:

  File "env/lib/python3.6/site-packages/dyn/core.py", line 51, in __call__
    cur_thread: super(_Singleton, cls).__call__(*args, **kwargs)
  File "env/lib/python3.6/site-packages/dyn/tm/session.py", line 54, in __init__
    self.password = self.__cipher.encrypt(password)
  File "env/lib/python3.6/site-packages/dyn/encrypt.py", line 63, in encrypt
    return base64.b64encode(iv + cipher.encrypt(raw))
  File "env/lib/python3.6/site-packages/Crypto/Cipher/_mode_cbc.py", line 177, in encrypt
    c_uint8_ptr(plaintext),
  File "env/lib/python3.6/site-packages/Crypto/Util/_raw_api.py", line 134, in c_uint8_ptr
    raise TypeError("Object type %s cannot be passed to C code" % type(data))
TypeError: Object type <class 'str'> cannot be passed to C code

Library versions

dyn==1.8.1
cryptography==2.4.2
cffi==1.11.5

@mariomarin
Copy link

I replaced the package python-pycryptodome with python-pycrypto, and it solved the issue.

@jayvdb
Copy link

jayvdb commented Sep 6, 2020

Using pycrypto also worked for me.

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