gpt4 book ai didi

c# - RSA C# 中的 key 大小没有改变!

转载 作者:行者123 更新时间:2023-11-30 16:31:11 25 4
gpt4 key购买 nike

我正在生成 key 对并将它们存储在 xml 文件中使用

ToXmlString(true);

我需要将 key 大小设置为 2048根据 MSDN,唯一可以执行此操作的地方是 RSACryptoServiceProvider 的构造函数

    private void AssignParameter(ProviderType providerType)
{
CspParameters cspParams;

cspParams = new CspParameters((int)providerType);
cspParams.KeyContainerName = RSAEncryption.containerName;
cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
cspParams.ProviderName = "Microsoft Strong Cryptographic Provider";
cspParams.KeyNumber = (int)KeyNumber.Exchange;

this.rsa = new RSACryptoServiceProvider(2048, cspParams);
}

当我使用

检查 key 大小时
int x = this.rsa.KeySize;

我总是得到 1024那么这里出了什么问题??

最佳答案

我以前见过这个,试试改容器名或者试试

using (this.rsa = new RSACryptoServiceProvider(2048, cspParams)) 
{

}

this.rsa.Clear(); 完成后。

如果您已经有一个同名的容器,我相信它会重新使用该容器。

关于c# - RSA C# 中的 key 大小没有改变!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5049402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com