I am generating key pair and store them in xml file using
ToXmlString(true);
I need to set the key size to 2048 according to the MSDN the only place to do this is from the constructor of the RSACryptoSe开发者_如何转开发rviceProvider
    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);
    }
when I check the key size using
int x = this.rsa.KeySize;
I always get 1024 so whats the wrong here??
I've seen this before, try changing the container name or try
using (this.rsa = new RSACryptoServiceProvider(2048, cspParams)) 
{
}
or this.rsa.Clear(); after you are done with it.
If you already have a container with the same name it will re-use the container I believe.
You need first to clear the existing container like this:
rsa.PersistKeyInCsp = false;
rsa.Clear();
Then it should work with you. Don't forget to set:
rsa.PersistKeyInCsp = true;
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论