带有 CspParameters 的 c# RSACryptoServiceProvider 无法设置 keySize

c# RSACryptoServiceProvider with CspParameters cannot set keySize

我了解到我们无法为 RSACryptoServiceProvider(int, cspParams)

设置 keySize
CspParameters cspParams = new CspParameters
{
    KeyContainerName = "KeyContainer"
};
            
var rsaRoot = new RSACryptoServiceProvider(2048, cspParams);
Console.WriteLine(rsaRoot.KeySize); // 1024

设置密钥大小的唯一方法是使用 RSACryptoServiceProvider(int),如何使用此方法设置 CspParameters KeyContainerName = "KeyContainer"

已解决 我必须使用唯一 KeyContainerName

CspParameters cspParams = new CspParameters
{
    KeyContainerName = Guid.NewGuid().ToString()

};

var rsaRoot = new RSACryptoServiceProvider(2048, cspParams);

关于只读语句 (url)

The RSACryptoServiceProvider class does not allow you to change key sizes using the KeySize property. Any value written to this property will fail to update the property without error. To change the key size, use one of the constructor overloads.

我觉得我或者他们理解有误,创建后不能改变keySize但是我们可以初始化keySize