0

我需要在我的 Flutter 应用程序中生成一个密钥对,有一个名为 RSA 的库可以解析一对公钥/私钥并能够使用它们加密和解密字符串,但它无法生成一个新的KeyPair(最好来自给定的字符串)。

我如何首先生成密钥?我错过了什么吗?

//Future to hold our KeyPair
Future<crypto.AsymmetricKeyPair> futureKeyPair;

//to store the KeyPair once we get data from our future
crypto.AsymmetricKeyPair keyPair;

Future<crypto.AsymmetricKeyPair<crypto.PublicKey, crypto.PrivateKey>> getKeyPair()
{
  var helper = RsaKeyHelper();
  return helper.computeRSAKeyPair(helper.getSecureRandom());
}
4

0 回答 0