0

我正在编写一些代码来加密来自颤振客户端的数据并将其发送到我们的服务器。我们正在使用 PKCS1 填充的 RSA,但在尝试加密数据时出现以下错误。

I/flutter (12394): Bad state: Reflectable has not been initialized.
I/flutter (12394): Please make sure that the first action taken by your program
I/flutter (12394): in `main` is to call `initializeReflectable()`.

负责这个的代码如下。

static String encrypt(String text, RSAPublicKey pubKey) {
    var cipher = PKCS1Encoding(RSAEngine());
    cipher.init(true, PublicKeyParameter<RSAPublicKey>(pubKey));
    Uint8List output1 = cipher.process(utf8.encode(text));
    return base64Encode(output1);
}

我已经设法让一个非填充样本运行良好,但 PKCS1 填充加密需要一个随机生成器,该生成器通过反射初始化,并且颤振说不。

任何帮助,将不胜感激。

4

1 回答 1

1

基于反射的Random构造函数已被替换为FortunaRandom种子。

_random = new FortunaRandom();
_random.seed(KeyParameter(_seed()));

PR 已经被批准并且现在是 master 所以没有人应该再有这个问题了!

于 2018-09-11T09:30:46.937 回答