The underlying C code performing the blowfish encryption wants bytes and
not a python string. Encode as utf-8 to avoid the issue below.
Traceback (most recent call last):
File "/home/andkem/.weechat/python/autoload/fish.py", line 861, in fish_modifier_in_privmsg_cb
b = Blowfish(fish_keys[targetl])
File "/home/andkem/.weechat/python/autoload/fish.py", line 379, in __init__
self.blowfish = Crypto.Cipher.Blowfish.new(
File "/usr/lib/python3.9/site-packages/Crypto/Cipher/Blowfish.py", line 146, in new
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
File "/usr/lib/python3.9/site-packages/Crypto/Cipher/__init__.py", line 79, in _create_cipher
return modes[mode](factory, **kwargs)
File "/usr/lib/python3.9/site-packages/Crypto/Cipher/_mode_ecb.py", line 215, in _create_ecb_cipher
cipher_state = factory._create_base_cipher(kwargs)
File "/usr/lib/python3.9/site-packages/Crypto/Cipher/Blowfish.py", line 77, in _create_base_cipher
result = start_operation(c_uint8_ptr(key),
File "/usr/lib/python3.9/site-packages/Crypto/Util/_raw_api.py", line 144, 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
python: error in function "fish_modifier_in_privmsg_cb"
SCRIPT_NAME = "fish"
SCRIPT_AUTHOR = "David Flatz <david@upcs.at>"
-SCRIPT_VERSION = "0.9.6"
+SCRIPT_VERSION = "0.9.7"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "FiSH for weechat"
CONFIG_FILE_NAME = SCRIPT_NAME
if len(key) > 72:
key = key[:72]
self.blowfish = Crypto.Cipher.Blowfish.new(
- key, Crypto.Cipher.Blowfish.MODE_ECB
+ key.encode('utf-8'), Crypto.Cipher.Blowfish.MODE_ECB
)
def decrypt(self, data):