|
|
|
@ -6,7 +6,10 @@
|
|
|
|
|
#
|
|
|
|
|
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
|
|
|
|
# run again. Do not edit this file unless you know what you are doing.
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
# Form implementation generated from reading ui file 'sender_ui.ui'
|
|
|
|
|
#
|
|
|
|
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
|
|
|
|
import sys
|
|
|
|
|
from PyQt5.QtWidgets import QFileDialog,QMainWindow
|
|
|
|
@ -30,7 +33,7 @@ import hashlib
|
|
|
|
|
from Crypto.Hash import SHA512
|
|
|
|
|
#导入加密算法的类
|
|
|
|
|
class Ui_MainWindow(object):
|
|
|
|
|
def setupUi(self, MainWindow):
|
|
|
|
|
def setupUi(self, MainWindow,sender):
|
|
|
|
|
MainWindow.setObjectName("MainWindow")
|
|
|
|
|
MainWindow.resize(839, 600)
|
|
|
|
|
self.centralwidget = QtWidgets.QWidget(MainWindow)
|
|
|
|
@ -101,8 +104,7 @@ class Ui_MainWindow(object):
|
|
|
|
|
self.key=""
|
|
|
|
|
self.envelope={}
|
|
|
|
|
#等待接收方连接
|
|
|
|
|
self.sender=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
|
self.sender.bind(("127.0.0.1", 5555))
|
|
|
|
|
self.sender=sender
|
|
|
|
|
def retranslateUi(self, MainWindow):
|
|
|
|
|
_translate = QtCore.QCoreApplication.translate
|
|
|
|
|
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
|
|
|
|
@ -199,11 +201,18 @@ class Ui_MainWindow(object):
|
|
|
|
|
self.envelope={"algorithm":self.algorithm,"mode":self.mode,"ciphertext":self.encrypted_text,"key":enc_key,"signature":signature,"publick_key":self.public_key}
|
|
|
|
|
self.textBrowser.append("pack successfully")
|
|
|
|
|
def send(self):
|
|
|
|
|
pass
|
|
|
|
|
#发送数据
|
|
|
|
|
envelope = json.dumps(self.envelope)
|
|
|
|
|
self.sender.send(envelope.encode('utf-8'))
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
#连接接收端 准备发送数据
|
|
|
|
|
sender_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
|
sender_conn.connect(('localhost', 8888))
|
|
|
|
|
#创建窗口
|
|
|
|
|
app = QtWidgets.QApplication(sys.argv)
|
|
|
|
|
MainWindow = QtWidgets.QMainWindow()
|
|
|
|
|
ui = Ui_MainWindow()
|
|
|
|
|
ui.setupUi(MainWindow)
|
|
|
|
|
ui.setupUi(MainWindow,sender_conn)
|
|
|
|
|
MainWindow.show()
|
|
|
|
|
sys.exit(app.exec_())
|