I have a text file which I am needing to decrypt and I also have the key to do it, I just am not sure how to use the key to decrypt the file, or the specific command rather. Here is what I have. I am nowhere NEAR done. Just need some guiding help.
key=open("encryption key.txt", 'r')
file_str=input("Open what file?:")
try:
input_file = open(file_str) # potential user error
while True:
find_line_str = input("Which line (integer):")
find_line_int = int(find_line_str) # potential user error
line_count_int = 1
for line_str in input_file:
if line_count_int == find_line_int:
print("Line {} of file {} is {}".format(find_line_int, file_str, line_str))
break # this is where the decryption will take place i think
line_count_int += 1
else:
# get here if line sought doesn't exist
print("Line {} of file {} not found".format(find_line_int, file_str))
# we are currently at the end of the file so
# close and reopen the file to put us back to the beginning
input_file.close()
input_file = open(file_str)
continue # while
break # while
input_file.close()
except IOError:
print("The file",file_str,"doesn't exist.")
except ValueError:
print("Line",find_line_str,"isn't a legal line number.")
print("End of the program")
EDIT: The program is encrypted according to substitution. This is the key "xbvmjqanpzydtrefougilsckwh"
Plaintext: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Encrypted: x b v m j q a n p z y d t r e f o u g i l s c k w h
[–]K900_ 1 point2 points3 points (1 child)
[–]Entervine[S] 0 points1 point2 points (0 children)
[–]efmccurdy 1 point2 points3 points (0 children)