1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
|
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtGui import QTextCursor from PyQt5.QtWidgets import QFileDialog, QAction import os import rsa
class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(701, 585) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.tabWidget = QtWidgets.QTabWidget(self.centralwidget) self.tabWidget.setGeometry(QtCore.QRect(0, 0, 701, 541)) self.tabWidget.setObjectName("tabWidget") self.key = QtWidgets.QWidget() self.key.setObjectName("key") self.horizontalLayoutWidget_5 = QtWidgets.QWidget(self.key) self.horizontalLayoutWidget_5.setGeometry(QtCore.QRect(100, 40, 191, 61)) self.horizontalLayoutWidget_5.setObjectName("horizontalLayoutWidget_5") self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_5) self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.label_7 = QtWidgets.QLabel(self.horizontalLayoutWidget_5) self.label_7.setObjectName("label_7") self.horizontalLayout_5.addWidget(self.label_7) self.mysc__wei = QtWidgets.QLineEdit(self.horizontalLayoutWidget_5) self.mysc__wei.setObjectName("mysc__wei") self.horizontalLayout_5.addWidget(self.mysc__wei) self.horizontalLayoutWidget_6 = QtWidgets.QWidget(self.key) self.horizontalLayoutWidget_6.setGeometry(QtCore.QRect(350, 40, 271, 61)) self.horizontalLayoutWidget_6.setObjectName("horizontalLayoutWidget_6") self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_6) self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_6.setObjectName("horizontalLayout_6") self.qd = QtWidgets.QPushButton(self.horizontalLayoutWidget_6) self.qd.setObjectName("qd") self.horizontalLayout_6.addWidget(self.qd) self.qx = QtWidgets.QPushButton(self.horizontalLayoutWidget_6) self.qx.setObjectName("qx") self.horizontalLayout_6.addWidget(self.qx) self.horizontalLayoutWidget_7 = QtWidgets.QWidget(self.key) self.horizontalLayoutWidget_7.setGeometry(QtCore.QRect(70, 120, 551, 61)) self.horizontalLayoutWidget_7.setObjectName("horizontalLayoutWidget_7") self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_7) self.horizontalLayout_7.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_7.setObjectName("horizontalLayout_7") self.label_8 = QtWidgets.QLabel(self.horizontalLayoutWidget_7) self.label_8.setObjectName("label_8") self.horizontalLayout_7.addWidget(self.label_8) self.pubkey_path = QtWidgets.QLineEdit(self.horizontalLayoutWidget_7) self.pubkey_path.setObjectName("pubkey_path") self.horizontalLayout_7.addWidget(self.pubkey_path) self.horizontalLayoutWidget_8 = QtWidgets.QWidget(self.key) self.horizontalLayoutWidget_8.setGeometry(QtCore.QRect(69, 200, 551, 61)) self.horizontalLayoutWidget_8.setObjectName("horizontalLayoutWidget_8") self.horizontalLayout_8 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_8) self.horizontalLayout_8.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_8.setObjectName("horizontalLayout_8") self.label_9 = QtWidgets.QLabel(self.horizontalLayoutWidget_8) self.label_9.setObjectName("label_9") self.horizontalLayout_8.addWidget(self.label_9) self.prikey_path = QtWidgets.QLineEdit(self.horizontalLayoutWidget_8) self.prikey_path.setObjectName("prikey_path") self.horizontalLayout_8.addWidget(self.prikey_path) self.sc = QtWidgets.QPushButton(self.key) self.sc.setGeometry(QtCore.QRect(530, 270, 93, 28)) self.sc.setObjectName("sc") self.horizontalLayoutWidget_10 = QtWidgets.QWidget(self.key) self.horizontalLayoutWidget_10.setGeometry(QtCore.QRect(70, 330, 551, 89)) self.horizontalLayoutWidget_10.setObjectName("horizontalLayoutWidget_10") self.horizontalLayout_9 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_10) self.horizontalLayout_9.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_9.setObjectName("horizontalLayout_9") self.label_10 = QtWidgets.QLabel(self.horizontalLayoutWidget_10) self.label_10.setObjectName("label_10") self.horizontalLayout_9.addWidget(self.label_10) self.public_key = QtWidgets.QTextBrowser(self.horizontalLayoutWidget_10) self.public_key.setObjectName("public_key") self.horizontalLayout_9.addWidget(self.public_key) self.horizontalLayoutWidget_9 = QtWidgets.QWidget(self.key) self.horizontalLayoutWidget_9.setGeometry(QtCore.QRect(70, 420, 551, 89)) self.horizontalLayoutWidget_9.setObjectName("horizontalLayoutWidget_9") self.horizontalLayout_10 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_9) self.horizontalLayout_10.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_10.setObjectName("horizontalLayout_10") self.label_11 = QtWidgets.QLabel(self.horizontalLayoutWidget_9) self.label_11.setObjectName("label_11") self.horizontalLayout_10.addWidget(self.label_11) self.pri_key = QtWidgets.QTextBrowser(self.horizontalLayoutWidget_9) self.pri_key.setObjectName("pri_key") self.horizontalLayout_10.addWidget(self.pri_key) self.tabWidget.addTab(self.key, "") self.pub = QtWidgets.QWidget() self.pub.setObjectName("pub") self.horizontalLayoutWidget = QtWidgets.QWidget(self.pub) self.horizontalLayoutWidget.setGeometry(QtCore.QRect(69, 30, 551, 71)) self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget") self.horizontalLayout = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setObjectName("horizontalLayout") self.label = QtWidgets.QLabel(self.horizontalLayoutWidget) self.label.setObjectName("label") self.horizontalLayout.addWidget(self.label) self.file_pubkey = QtWidgets.QLineEdit(self.horizontalLayoutWidget) self.file_pubkey.setReadOnly(True) self.file_pubkey.setObjectName("file_pubkey") self.horizontalLayout.addWidget(self.file_pubkey) self.horizontalLayoutWidget_2 = QtWidgets.QWidget(self.pub) self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(69, 110, 551, 51)) self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_2) self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.add_dr = QtWidgets.QPushButton(self.horizontalLayoutWidget_2) self.add_dr.setObjectName("add_dr") self.horizontalLayout_2.addWidget(self.add_dr) self.add_qc = QtWidgets.QPushButton(self.horizontalLayoutWidget_2) self.add_qc.setObjectName("add_qc") self.horizontalLayout_2.addWidget(self.add_qc) self.verticalLayoutWidget = QtWidgets.QWidget(self.pub) self.verticalLayoutWidget.setGeometry(QtCore.QRect(69, 179, 271, 211)) self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.label_2 = QtWidgets.QLabel(self.verticalLayoutWidget) self.label_2.setObjectName("label_2") self.verticalLayout.addWidget(self.label_2) self.scrollArea = QtWidgets.QScrollArea(self.verticalLayoutWidget) self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents_2 = QtWidgets.QWidget() self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 267, 185)) self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2") self.add_mingwen = QtWidgets.QPlainTextEdit(self.scrollAreaWidgetContents_2) self.add_mingwen.setGeometry(QtCore.QRect(-7, -4, 281, 191)) self.add_mingwen.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.add_mingwen.setObjectName("add_mingwen") self.scrollArea.setWidget(self.scrollAreaWidgetContents_2) self.verticalLayout.addWidget(self.scrollArea) self.verticalLayoutWidget_2 = QtWidgets.QWidget(self.pub) self.verticalLayoutWidget_2.setGeometry(QtCore.QRect(349, 179, 271, 211)) self.verticalLayoutWidget_2.setObjectName("verticalLayoutWidget_2") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_2) self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.verticalLayout_2.setObjectName("verticalLayout_2") self.label_3 = QtWidgets.QLabel(self.verticalLayoutWidget_2) self.label_3.setObjectName("label_3") self.verticalLayout_2.addWidget(self.label_3) self.scrollArea_2 = QtWidgets.QScrollArea(self.verticalLayoutWidget_2) self.scrollArea_2.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.scrollArea_2.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.scrollArea_2.setWidgetResizable(True) self.scrollArea_2.setObjectName("scrollArea_2") self.scrollAreaWidgetContents_3 = QtWidgets.QWidget() self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 267, 185)) self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3") self.add_miwen = QtWidgets.QTextEdit(self.scrollAreaWidgetContents_3) self.add_miwen.setGeometry(QtCore.QRect(-7, -4, 281, 191)) self.add_miwen.setReadOnly(True) self.add_miwen.setObjectName("add_miwen") self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_3) self.verticalLayout_2.addWidget(self.scrollArea_2) self.add_put = QtWidgets.QPushButton(self.pub) self.add_put.setGeometry(QtCore.QRect(530, 420, 93, 28)) self.add_put.setObjectName("add_put") self.tabWidget.addTab(self.pub, "") self.pri = QtWidgets.QWidget() self.pri.setObjectName("pri") self.horizontalLayoutWidget_3 = QtWidgets.QWidget(self.pri) self.horizontalLayoutWidget_3.setGeometry(QtCore.QRect(69, 30, 551, 71)) self.horizontalLayoutWidget_3.setObjectName("horizontalLayoutWidget_3") self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_3) self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.label_4 = QtWidgets.QLabel(self.horizontalLayoutWidget_3) self.label_4.setObjectName("label_4") self.horizontalLayout_3.addWidget(self.label_4) self.file_prikey = QtWidgets.QLineEdit(self.horizontalLayoutWidget_3) self.file_prikey.setReadOnly(True) self.file_prikey.setObjectName("file_prikey") self.horizontalLayout_3.addWidget(self.file_prikey) self.horizontalLayoutWidget_4 = QtWidgets.QWidget(self.pri) self.horizontalLayoutWidget_4.setGeometry(QtCore.QRect(69, 110, 551, 51)) self.horizontalLayoutWidget_4.setObjectName("horizontalLayoutWidget_4") self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_4) self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.jmdr = QtWidgets.QPushButton(self.horizontalLayoutWidget_4) self.jmdr.setObjectName("jmdr") self.horizontalLayout_4.addWidget(self.jmdr) self.jmqc = QtWidgets.QPushButton(self.horizontalLayoutWidget_4) self.jmqc.setObjectName("jmqc") self.horizontalLayout_4.addWidget(self.jmqc) self.verticalLayoutWidget_3 = QtWidgets.QWidget(self.pri) self.verticalLayoutWidget_3.setGeometry(QtCore.QRect(69, 179, 271, 211)) self.verticalLayoutWidget_3.setObjectName("verticalLayoutWidget_3") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_3) self.verticalLayout_3.setContentsMargins(0, 0, 0, 0) self.verticalLayout_3.setObjectName("verticalLayout_3") self.label_5 = QtWidgets.QLabel(self.verticalLayoutWidget_3) self.label_5.setObjectName("label_5") self.verticalLayout_3.addWidget(self.label_5) self.scrollArea_4 = QtWidgets.QScrollArea(self.verticalLayoutWidget_3) self.scrollArea_4.setWidgetResizable(True) self.scrollArea_4.setObjectName("scrollArea_4") self.scrollAreaWidgetContents_4 = QtWidgets.QWidget() self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 267, 185)) self.scrollAreaWidgetContents_4.setObjectName("scrollAreaWidgetContents_4") self.jm_miwen = QtWidgets.QPlainTextEdit(self.scrollAreaWidgetContents_4) self.jm_miwen.setGeometry(QtCore.QRect(-7, -4, 281, 191)) self.jm_miwen.setReadOnly(False) self.jm_miwen.setObjectName("jm_miwen") self.scrollArea_4.setWidget(self.scrollAreaWidgetContents_4) self.verticalLayout_3.addWidget(self.scrollArea_4) self.verticalLayoutWidget_4 = QtWidgets.QWidget(self.pri) self.verticalLayoutWidget_4.setGeometry(QtCore.QRect(349, 179, 271, 211)) self.verticalLayoutWidget_4.setObjectName("verticalLayoutWidget_4") self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_4) self.verticalLayout_4.setContentsMargins(0, 0, 0, 0) self.verticalLayout_4.setObjectName("verticalLayout_4") self.label_6 = QtWidgets.QLabel(self.verticalLayoutWidget_4) self.label_6.setObjectName("label_6") self.verticalLayout_4.addWidget(self.label_6) self.scrollArea_3 = QtWidgets.QScrollArea(self.verticalLayoutWidget_4) self.scrollArea_3.setWidgetResizable(True) self.scrollArea_3.setObjectName("scrollArea_3") self.scrollAreaWidgetContents = QtWidgets.QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 267, 185)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.jm_mingwen = QtWidgets.QTextEdit(self.scrollAreaWidgetContents) self.jm_mingwen.setGeometry(QtCore.QRect(-7, -4, 281, 191)) self.jm_mingwen.setReadOnly(True) self.jm_mingwen.setObjectName("jm_mingwen") self.scrollArea_3.setWidget(self.scrollAreaWidgetContents) self.verticalLayout_4.addWidget(self.scrollArea_3) self.jm_put = QtWidgets.QPushButton(self.pri) self.jm_put.setGeometry(QtCore.QRect(530, 420, 93, 28)) self.jm_put.setObjectName("jm_put") self.tabWidget.addTab(self.pri, "") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 701, 26)) self.menubar.setObjectName("menubar") self.menu = QtWidgets.QMenu(self.menubar) self.menu.setTitle("") self.menu.setObjectName("menu") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.menubar.addAction(self.menu.menuAction()) self.actionopenpubFileDialog = QAction(MainWindow) self.actionopenpubFileDialog.setObjectName("actionopenFileDialog") self.actionopenpubFileDialog.setCheckable(False) self.actionopenpubFileDialog.setEnabled(True) self.actionopenpubFileDialog.triggered.connect(self.openpubFileDialog) self.actionopenpriFileDialog = QAction(MainWindow) self.actionopenpriFileDialog.setObjectName("actionopenpriFileDialog") self.actionopenpriFileDialog.setCheckable(False) self.actionopenpriFileDialog.setEnabled(True) self.actionopenpriFileDialog.triggered.connect(self.openpriFileDialog) self.retranslateUi(MainWindow) self.tabWidget.setCurrentIndex(0) self.qd.clicked.connect(self.qd_clicked) self.qx.clicked.connect(self.qx_clicked) self.add_dr.clicked.connect(self.actionopenpubFileDialog.triggered) self.jmdr.clicked.connect(self.actionopenpriFileDialog.triggered) self.sc.clicked.connect(self.miyaoshengcheng) self.add_put.clicked.connect(self.addput_clicked) self.jm_put.clicked.connect(self.jiemiput_clicked) self.add_qc.clicked.connect(self.file_pubkey.clear) self.jmqc.clicked.connect(self.file_prikey.clear) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "RSA加密")) self.label_7.setText(_translate("MainWindow", "密钥位数:")) self.qd.setText(_translate("MainWindow", "确定")) self.qx.setText(_translate("MainWindow", "取消")) self.label_8.setText(_translate("MainWindow", "公钥存储位置:")) self.label_9.setText(_translate("MainWindow", "私钥存储位置:")) self.sc.setText(_translate("MainWindow", "生成")) self.mysc__wei.setPlaceholderText("默认为1014位") self.pubkey_path.setPlaceholderText("默认为空即当前目录") self.prikey_path.setPlaceholderText("默认为空即当前目录") self.label_10.setText(_translate("MainWindow", "公钥:")) self.label_11.setText(_translate("MainWindow", "私钥:")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.key), _translate("MainWindow", "密钥生成")) self.label.setText(_translate("MainWindow", "公钥:")) self.add_dr.setText(_translate("MainWindow", "导入")) self.add_qc.setText(_translate("MainWindow", "清除")) self.label_2.setText(_translate("MainWindow", "明文:")) self.label_3.setText(_translate("MainWindow", "密文:")) self.add_put.setText(_translate("MainWindow", "加密")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.pub), _translate("MainWindow", "加密")) self.label_4.setText(_translate("MainWindow", "私钥:")) self.jmdr.setText(_translate("MainWindow", "导入")) self.jmqc.setText(_translate("MainWindow", "清除")) self.label_5.setText(_translate("MainWindow", "密文:")) self.label_6.setText(_translate("MainWindow", "明文:")) self.jm_put.setText(_translate("MainWindow", "解密")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.pri), _translate("MainWindow", "解密")) def qd_clicked(self): self.mysc__wei.setStyleSheet("background-color: gray;") self.mysc__wei.setReadOnly(True) def qx_clicked(self): self.mysc__wei.setStyleSheet("background-color: rgb(255, 255, 255);") self.mysc__wei.clear() self.mysc__wei.setReadOnly(False)
def openpubFileDialog(self): try: file_name, _ = QFileDialog.getOpenFileName(self.centralwidget, "Open File", "", "All Files (*);;Text Files (*.txt)") if file_name: self.file_pubkey.setText(file_name) except Exception as e: print(f"An error occurred: {str(e)}") def openpriFileDialog(self): try: file_name, _ = QFileDialog.getOpenFileName(self.centralwidget, "Open File", "", "All Files (*);;Text Files (*.txt)") if file_name: self.file_prikey.setText(file_name) except Exception as e: print(f"An error occurred: {str(e)}")
def miyaoshengcheng(self): if self.mysc__wei.text().isdigit() and int(self.mysc__wei.text()) > 0 and int(self.mysc__wei.text())%2 == 0 and int(self.mysc__wei.isReadOnly()): rsa.bits = int(self.mysc__wei.text()) else: rsa.bits = 1024 default_path = os.getcwd() if self.pubkey_path.text(): pubfilename = self.pubkey_path.text()+"\\public_key.txt" else: pubfilename = default_path+"\\public_key.txt" if self.prikey_path.text(): prifilename = self.prikey_path.text()+"\\private_key.txt" else: prifilename = default_path+"\\private_key.txt" pub, pri = rsa.generate_rsa_key_pair(rsa.bits)
self.public_key.clear() self.public_key.insertPlainText(str(pub)) self.pri_key.clear() self.pri_key.insertPlainText(str(pri))
rsa.save_public_key(pub,pubfilename) rsa.save_private_key(pri,prifilename)
def addput_clicked(self): self.add_miwen.clear() public_path = self.file_pubkey.text() public_key = rsa.load_key_from_file(public_path) ciphertext = rsa.encrypt(self.add_mingwen.toPlainText(), public_key) self.add_miwen.setPlainText(str(ciphertext))
def jiemiput_clicked(self): self.jm_mingwen.clear() pri_path = self.file_prikey.text() private_key = rsa.load_key_from_file(pri_path) message = self.jm_miwen.toPlainText().strip() if message.startswith("[") and message.endswith("]"): message = message[1:-1] message = message.split(",") message = [int(item) for item in message] self.jm_mingwen.setPlainText(str(rsa.decrypt(message, private_key)))
|