Igo*_*ova 1 c# encryption rsa .net-core
对于加密、解密、签名和验证签名,我使用此处的代码DotnetCore.RSA
在我开始处理大文本之前,它一直运行良好。
通过 RSA 加密不适用于大文本。大,超过 245 个字节,具有 2048 个 RSA 密钥
我在尝试加密大文本时遇到异常:
异常消息:Interop.Crypto.OpenSslCryptographicException: 'error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size'
加密功能:
public string Encrypt(string text) {
if (_publicKeyRsaProvider == null) {
throw new Exception("_publicKeyRsaProvider is null");
}
return Convert.ToBase64String(_publicKeyRsaProvider.Encrypt(Encoding.UTF8.GetBytes(text), RSAEncryptionPadding.Pkcs1));
}
Run Code Online (Sandbox Code Playgroud)
编写 DotnetCore.RSA 的开发人员建议将长文本分成许多小文本,分别加密并连接它们
有什么建议吗,正常还是不正常?也许建议一些用于 .net Core 的 RSA 加密库