From 8c3c8208a69a8337579d968e398b3f0122fdd108 Mon Sep 17 00:00:00 2001 From: ps5antq2e <1819276859@qq.com> Date: Tue, 24 Dec 2024 21:19:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=B5=8B=E8=AF=95=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sender_ui.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sender_ui.py b/sender_ui.py index cdb0244..57b3c1f 100644 --- a/sender_ui.py +++ b/sender_ui.py @@ -12,7 +12,7 @@ # from PyQt5 import QtCore, QtGui, QtWidgets import sys -from PyQt5.QtWidgets import QFileDialog,QMainWindow +from PyQt5.QtWidgets import QFileDialog,QMainWindow,QMessageBox from gmssl import sm4, func import json import socket @@ -86,12 +86,15 @@ class Ui_MainWindow(object): self.mode="" self.algorithm="" self.encrypted_text="" + QMessageBox.information(MainWindow, "提示", "请选择自己的公钥") path = QFileDialog.getOpenFileName()[0] with open(path,"rb") as f: self.public_key=crypto.load_publickey(crypto.FILETYPE_PEM,f.read()) + QMessageBox.information(MainWindow, "提示", "请选择自己的私钥") path = QFileDialog.getOpenFileName()[0] with open(path,"rb") as f: self.private_key=crypto.load_privatekey(crypto.FILETYPE_PEM,f.read()) + QMessageBox.information(MainWindow, "提示", "请选择对方的公钥") path = QFileDialog.getOpenFileName()[0] with open(path,"rb") as f: self.public_key_other=crypto.load_publickey(crypto.FILETYPE_PEM,f.read()) @@ -138,7 +141,7 @@ class Ui_MainWindow(object): text = text + (b'\0' * add) encrypted_text = cryptor.encrypt(text) self.encrypted_text = b2a_hex(encrypted_text).decode("utf-8") - self.textBrowser.append(encrypted_text+"\n") + self.textBrowser.append(encrypted_text.decode()) elif self.mode=="CBC": mode = AES.MODE_CBC cryptor = AES.new(self.key, mode, self.key)#iv = self.key @@ -149,7 +152,7 @@ class Ui_MainWindow(object): text = text + (b'\0' * add) encrypted_text = cryptor.encrypt(text) self.encrypted_text = b2a_hex(encrypted_text).decode("utf-8") - self.textBrowser.append(encrypted_text+"\n") + self.textBrowser.append(encrypted_text.decode()) else: self.textBrowser.append("mode error") elif self.algorithm=="SM4":