Why the length of the encrypted message is changed after downloading this message from file?Python RSA encryption/decryption -


encryption

def encrypt(): k=0 l=1 length=len(message)/20 if int(length)>=1:     in range(int(length)+1):         message1=""         if i<int(length)+1:             i=k             message1=""             j in range(20*i,20*(i+1)):                 message1+=message[j]             k=i             message1=message1.encode()             print(len(message1))             crypto = rsa.encrypt(message1, pubkey)             text1.insert(end,crypto)             cryptow+=crypto         else:             message1=""             in range(len(message)-int(length)*20):                 message1+=message[int(length)*20+i]             message1=message1.encode()             crypto = rsa.encrypt(message1, pubkey)             print(type(crypto))             text1.insert(end,crypto)             cryptow+=crypto print(len(cryptow)) showinfo("attention!","message encrypted") 

message=2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71

print(len(cryptow)) in penultimate string=96

then save resulting cipher in file:

def save_encrypt_message(): filename = asksaveasfilename() save_encrypt_message = open(filename,'wb') print(len(cryptow)) save_encrypt_message = save_encrypt_message.write(cryptow) save_encrypt_message.close() 

print(len(cryptow)) still equally 96

after, reran program , load cipher file:

def open_message_for_decrypt(): filename = askopenfilename() decrypt_message = open(filename,'rb') decrypt_message = decrypt_message.readlines() text1.delete('1.0', end) text1.insert(end,decrypt_message) print(len(decrypt_message)) 

and

print(len(decrypt_message)) =1 why?

on line:

decrypt_message = decrypt_message.readlines() 

a list assigned decrypt_message, each item in list 1 line file; there's 1 line in file...


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -