Skip to content

TypeError: Only byte strings can be passed to C code #1

@BenWoodford

Description

@BenWoodford

So I'm trying to use this library with Home Assistant and ran into a spot of trouble, hoping you can advise on the below? The user/pass are taken from a YAML file but are formatted as strings.

  File "/config/custom_components/leaf.py", line 43, in setup
    leaf = Leaf(username, password)
  File "/config/deps/lib/python3.6/site-packages/leafpy/leaf.py", line 14, in __init__
    self.custom_sessionid, self.VIN = login(username, password)
  File "/config/deps/lib/python3.6/site-packages/leafpy/auth.py", line 12, in login
    c1  = Blowfish.new(baseprm, Blowfish.MODE_ECB)
  File "/usr/local/lib/python3.6/site-packages/Crypto/Cipher/Blowfish.py", line 146, in new
    return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/Crypto/Cipher/__init__.py", line 55, in _create_cipher
    return modes[mode](factory, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/Crypto/Cipher/_mode_ecb.py", line 175, in _create_ecb_cipher
    cipher_state = factory._create_base_cipher(kwargs)
  File "/usr/local/lib/python3.6/site-packages/Crypto/Cipher/Blowfish.py", line 70, in _create_base_cipher
    expect_byte_string(key)
  File "/usr/local/lib/python3.6/site-packages/Crypto/Util/_raw_api.py", line 194, in expect_byte_string
    raise TypeError("Only byte strings can be passed to C code")
TypeError: Only byte strings can be passed to C code

During handling of the above exception, another exception occurred:

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