I am trying to encrypt a file using RSA algo in python for that i have stored all the possible values that can be written in a normal text file. like this
SYMBOLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !?.'
now i have a text file which i want to encrypt. It contains only a single line; "I am a boy" (without these quote). But when i am trying to encrypt the file its showing that: "the SYMBOLS does not have the character", which is a message that will be delivered by the program if the character does not match. here's the code where i have declared the SYMBOLS and open the text file:
SYMBOLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !?'
def main():
# Runs a test that encrypts a message to a file or decrypts a message
# from a file.
filename = 'encrypted_file.txt' # The file to write to/read from.
mode = 'encrypt' # Set to either 'encrypt' or 'decrypt'.
if mode == 'encrypt':
message1 = open('afile.txt', 'r') #open the file which will be encrypted
message = str((message1.read())
print(message)
I think that i am making a mistake in opening the text file, as for this script only the contains will be needed as str, but i don't know how to do it. Looking forward to some si=uggestions. Thank you.