Im trying to make a program that takes input and saves it to a file. Afterwards, I'd like for the information that's in the document to be encrypted using caesar shift with 6 shifts. Then I'd like to have a decrypt program where I decrypt the file back to the original, (done by using approx the same code but decrypt instead?)
This is my code:
encrypt = str.maketrans('abcdefghijklmnopqrstuvwxyz0123456789', 'ghijklmnopqrstuvwxyz0123456789abcdef')
decrypt = str.maketrans('ghijklmnopqrstuvwxyz0123456789abcdef', 'abcdefghijklmnopqrstuvwxyz0123456789')
filename = "abc.abd.txt"
with open(filename, "a+") as r:
with open(filename+'-encrypted.txt', 'w+'):
for line in r:
print(line.translate(encrypt), file=r)
Also, I'd like to delete the file with cleartext info on it after it has been decrypted into another file, if I'm not mistaken, this is done like this:
open(filename, "w+") # At the end of the document.
My problem is that after running the program, there is no output in my new encrypted document. Also, is there a good way of including capital letters in this program?
Thanks in advance for all help!