|
|
@ -43,7 +43,7 @@ def main():
|
|
|
|
letter.recvPubKey = getRecvPubKey()
|
|
|
|
letter.recvPubKey = getRecvPubKey()
|
|
|
|
letter.senderPubKey = getSenderPubKey()
|
|
|
|
letter.senderPubKey = getSenderPubKey()
|
|
|
|
letter.fileBase64, akey = SymEncryption(base64.b64encode(data).decode("utf-8"),letterSymKey)
|
|
|
|
letter.fileBase64, akey = SymEncryption(base64.b64encode(data).decode("utf-8"),letterSymKey)
|
|
|
|
letter.encryptKey = getEncryptKey()
|
|
|
|
letter.encryptKey = getEncryptKey(letter.recvPubKey)
|
|
|
|
letter.encryptType = getEncryptType()
|
|
|
|
letter.encryptType = getEncryptType()
|
|
|
|
|
|
|
|
|
|
|
|
letter.sign = getSign(data)
|
|
|
|
letter.sign = getSign(data)
|
|
|
@ -166,16 +166,16 @@ def getEncryptType():
|
|
|
|
|
|
|
|
|
|
|
|
return encryType
|
|
|
|
return encryType
|
|
|
|
|
|
|
|
|
|
|
|
# 对称密钥,返回的是使用接收方公钥加密后的密钥
|
|
|
|
# 对称密钥,返回的是使用接收方公钥加密后的对称密钥
|
|
|
|
def getEncryptKey():
|
|
|
|
def getEncryptKey(getRecvPubKey):
|
|
|
|
rsaEncrySymKey = RSA.encrypt_message(letterSymKey, getRecvPubKey())
|
|
|
|
rsaEncrySymKey = RSA.encrypt_message(letterSymKey, getRecvPubKey)
|
|
|
|
|
|
|
|
|
|
|
|
return base64.b64encode(rsaEncrySymKey).decode("utf-8")
|
|
|
|
return base64.b64encode(rsaEncrySymKey).decode("utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
# 获得接收方的公钥
|
|
|
|
# 获得接收方的公钥
|
|
|
|
def getRecvPubKey():
|
|
|
|
def getRecvPubKey():
|
|
|
|
# recPubKey = input("plz input Receiver's Public Key: ")
|
|
|
|
# recPubKey = input(" plz input Receiver's Public Key: ")
|
|
|
|
# 在某某地方获得对方的公钥,然后保存到某个地方,输入路径uoqu
|
|
|
|
# 在某某地方获得对方的公钥,然后保存到某个地方,输入路径
|
|
|
|
recPubKeyPath = input("请输入接受方的公钥文件路径:")
|
|
|
|
recPubKeyPath = input("请输入接受方的公钥文件路径:")
|
|
|
|
with open(recPubKeyPath, "rb") as f:
|
|
|
|
with open(recPubKeyPath, "rb") as f:
|
|
|
|
data = f.read()
|
|
|
|
data = f.read()
|
|
|
|