Prev: Visual Studio - get the most recent dll when added as a reference.
Next: Installing 3rd party controls (TreeViewAdv)
From: Tony Johansson on 20 Apr 2010 09:24 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 20 Apr 2010 12:46
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 > |