These are the decryption functions.
def decrypt(info,key):
    msg=info
    PAD="%"
    decipher=AES.new(new_pwd,AES.MODE_ECB)
    pt=decipher.decrypt(msg).decode('utf-8')  # ERROR OCCURS HERE
    pad_index=pt.find(PAD)
    result=pt[:pad_index]
    return result
def decrypt_file(filename,new_pwd):
    with open(filename, 'r') as f:
        ciphertext=f.read()
    dec=decrypt(ciphertext, new_pwd)
    with open(filename[:-4], 'w') as f:
         f.write(dec)
This is the error I got when I run the code:
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "first.py", line 85, in decrypt_text_file
    decrypt_file(fname,new_pwd)
  File "first.py", line 63, in decrypt_file
    dec=decrypt(ciphertext, new_pwd)
  File "first.py", line 29, in decrypt
    pt=decipher.decrypt(msg).decode('utf-8')
  File "C:\Users\aravi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\Crypto\Cipher\_mode_ecb.py", line 190, in decrypt
    c_uint8_ptr(ciphertext),
  File "C:\Users\aravi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\Crypto\Util\_raw_api.py", line 243, 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
I don't have clue about fixing this.
 
    