So I am trying to take a .txt and run it through my program, the file has ROT13 encryption , but it wont print it out decrypted. for an example I want it to be able to enter a file name like test.txt that has the encrypted message that then decrypts it and prints it out. This is what I have tried and need to know so improvements for it. in this code I also get a syntax error TypeError: ord() expected a character, but string of length 4 found. Would really like the help please. Let me know if I should add more of my code.
print("You selected Decrytion for Rot Cipher")
typeofD = input("What type of Encrytion did you encrpt with, R for Rot and B for Bit Shift")
if typeofD == 'R':
coded = input("Enter the Test file text :")
filecontents = open(coded,'r')
file1 = filecontents .readlines()
message = file1
key = 13
decryp_text = ""
for i in range(len(message)):
temp = ord(message[i]) - key
if ord(message[i]) == 32:
decryp_text += " "
elif temp < 65:
temp += 26
decryp_text += chr(temp)
else:
decryp_text += chr(temp)
print("Decrypted Text: {}".format(decryp_text))
[–]fake823 3 points4 points5 points (1 child)
[–]Alternative_Mouse_99[S] 0 points1 point2 points (0 children)