The pycryptodome is working fine, but I'm getting an error message.
Here's my code:
from Crypto.Cipher import DES key = 'hello123' def pad(text): while len(text) % 8 != 0: text += '' return text des = DES.new(key, DES.MODE_ECB) text1 = 'Python is the Best Language!' padded_text = pad(text1) encrypted_text = des.encrypt(padded_text) print(encrypted_text) print(des.decrypt(encrypted_text)) This is my error message:
Traceback (most recent call last): File "C:\Users\Raj_7\Desktop\des.py", line 10, in des = DES.new(key, DES.MODE_ECB)
File "D:\Python\lib\site-packages\Crypto\Cipher\DES.py", line 145, in new return _create_cipher(sys.modules[name], key, mode, *args, **kwargs)
File "D:\Python\lib\site-packages\Crypto\Cipher__init__.py", line 79, in _create_cipher return modes[mode](factory, **kwargs)
File "D:\Python\lib\site-packages\Crypto\Cipher_mode_ecb.py", line 215, in _create_ecb_cipher cipher_state = factory._create_base_cipher(kwargs)
File "D:\Python\lib\site-packages\Crypto\Cipher\DES.py", line 76, in _create_base_cipher result = start_operation(c_uint8_ptr(key),
File "D:\Python\lib\site-packages\Crypto\Util_raw_api.py", line 234, in c_uint8_ptr
raise TypeError("Object type %s cannot be passed to C code" % type(data)) TypeError: Object type cannot be passed to C code
editaccordingly. Preceed the error message with a>at the beginning of the line to format it as quote or error message.>, and adding two spaces at the end of a line will produce a line break, but keep the next line formatted.