Mega Code Archive

 
Categories / VB.Net Tutorial / Security
 

Creates a key container using the CspParameters class and saves the key in the container

Imports System Imports System.IO Imports System.Security.Cryptography Public Class StoreKey     Public Shared Sub Main()         Dim cp As New CspParameters()         cp.KeyContainerName = "MyKeyContainerName"         Dim rsa As New RSACryptoServiceProvider(cp)         rsa.PersistKeyInCsp = False         Console.WriteLine("Key is : "  & rsa.ToXmlString(True))     End Sub End Class