From: Tony Johansson on
Hi!

Why do I get the same private key when I run this program several times even
if I shutdown the computer and start all over again I get the same private
key as I get the first time.

static void Main(string[] args)
{
CspParameters persistentCsp = new CspParameters();
persistentCsp.KeyContainerName = "AssymetricExample";

RSACryptoServiceProvider myRSA = new
RSACryptoServiceProvider(persistentCsp);
myRSA.PersistKeyInCsp = true;
RSAParameters privateKey = myRSA.ExportParameters(true);

foreach (byte thisByte in privateKey.D)
Console.WriteLine(thisByte.ToString("X2") + " ");
}

//Tony


From: rossum on
On Tue, 20 Apr 2010 15:24:37 +0200, "Tony Johansson"
<johansson.andersson(a)telia.com> wrote:

>Hi!
>
>Why do I get the same private key when I run this program several times even
>if I shutdown the computer and start all over again I get the same private
>key as I get the first time.
>
>static void Main(string[] args)
> {
> CspParameters persistentCsp = new CspParameters();
> persistentCsp.KeyContainerName = "AssymetricExample";
>
> RSACryptoServiceProvider myRSA = new
>RSACryptoServiceProvider(persistentCsp);
> myRSA.PersistKeyInCsp = true;
Look up the documentation to see what the effect of setting the
PersistKeyInCsp property to true is.

rossum

> RSAParameters privateKey = myRSA.ExportParameters(true);
>
> foreach (byte thisByte in privateKey.D)
> Console.WriteLine(thisByte.ToString("X2") + " ");
>}
>
>//Tony
>