Dart-使用字符串格式的公共密钥RSA加密消息

时间:2018-08-23 23:08:03

标签: python dart rsa

从使用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并加密消息并以字符串格式发送?

0 个答案:

没有答案