从使用Flask框架(Python)构建的api休息中,我得到了public key
格式的string
。
按照带有Crypto
lib的python中的站点http://studyraspberrypi.blogspot.com/2016/01/sending-rsa-encrypted-message-from.html进行以下操作:
random_generator = Random.new().read
private_key = RSA.generate(1024, random_generator)
public_key = private_key.publickey()
publickey = public_key.exportKey() #public key in string format
#Convert string to key
server_public_key = RSA.importKey(publickey)
#Encrypt message and send to server
message = "This is my secret message."
encrypted = server_public_key.encrypt(message, 32)
server.sendall("encrypted_message="+str(encrypted))
在Dart中是否可以获取字符串格式的public key
并加密消息并以字符串格式发送?