I already have a working program, but the only thing that doesn\'t work is the decrypt_file()
function I have. I can still copy the encrypted text from the file
In Python 3 (which you are clearly using) the default mode for files you open is text, not binary. When you read from the file, you get strings rather than byte arrays. That does not go along with encryption.
In your code, you should replace:
open(file_name, 'r')
with:
open(file_name, 'rb')
The same for when you open the file for writing. At that point, you can get rid of all the various occurrences where you convert from string to binary and vice versa.
For instance, this can go away:
plaintext = plaintext.encode('utf-8')