首页 > 解决方案 > 我如何告诉服务器来自加密模块的公钥?

问题描述

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

标签: pythoncryptographypublic-key-encryption

解决方案


您可以通过二进制文件发送密钥,客户端应将此二进制文件转换为 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

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


推荐阅读