我怎样才能告诉服务器来自加密模块的 public 密钥?

How can i tell the server the public key from the crypthography module?

我正在尝试在 python 中创建一个简单的 Messenger,并使用加密模块进行加密。我已经对客户端和服务器进行了编码,但现在我卡在了这一部分,我告诉服务器我的 public 密钥,以便服务器可以加密组密钥或客户端可以用他的私钥解密的某种密钥.我尝试使用常规类型的发送字符串来发送密钥,但我只是发送内存地址。我还尝试将密钥保存到文件并将文件发送过来,但这也不起作用。我该如何解决这个问题?

您可以通过二进制文件发送密钥,客户端应将此二进制文件转换为 utf8 或您想要使用的任何格式,这里是向客户端发送加密数据的场景:

- server asks the client for the public key
- client sends public key with a binary file to the server
- server unpacks the binary file and transform it into another form
- server use public key extracted to encrypt data
- server sends encrypted data to the client
- client decrypt the encrypted data

你也可以在另一边做同样的事情