加密
def encrypt():
k=0
l=1
length=len(message)/20
if int(length)>=1:
for i in range(int(length)+1):
message1=""
if i<int(length)+1:
i=k
message1=""
for 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=""
for i 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 was encrypted")
message = 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71
打印(len(cryptow))倒数第二个字符串= 96
然后我将生成的密码保存在文件中:
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))仍然是96
之后,我重新编程并从文件中加载密码:
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))
和
打印(LEN(解密消息)) = 1那么为什么?
答案 0 :(得分:0)
在线:
decrypt_message = decrypt_message.readlines()
列表分配给decrypt_message
,其中列表中的每个项目都是文件中的一行;文件中只有一行...