本文整理匯總了VB.NET中System.Security.Cryptography.CspParameters類的典型用法代碼示例。如果您正苦於以下問題:VB.NET CspParameters類的具體用法?VB.NET CspParameters怎麽用?VB.NET CspParameters使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了CspParameters類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: StoreKey
' 導入命名空間
Imports System.IO
Imports System.Security.Cryptography
Public Class StoreKey
Public Shared Sub Main()
' creates the CspParameters object and sets the key container name used to store the RSA key pair
Dim cp As New CspParameters()
cp.KeyContainerName = "MyKeyContainerName"
' instantiates the rsa instance accessing the key container MyKeyContainerName
Dim rsa As New RSACryptoServiceProvider(cp)
' add the below line to delete the key entry in MyKeyContainerName
' rsa.PersistKeyInCsp = false;
'writes out the current key pair used in the rsa instance
Console.WriteLine("Key is : " & rsa.ToXmlString(True))
End Sub
End Class
示例2: SCSign
' 導入命名空間
Imports System.Security.Cryptography
Module SCSign
Sub Main(ByVal args() As String)
' To idendify the Smart Card CryptoGraphic Providers on your
' computer, use the Microsoft Registry Editor (Regedit.exe).
' The available Smart Card CryptoGraphic Providers are listed
' in HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider.
' Create a new CspParameters object that identifies a
' Smart Card CryptoGraphic Provider.
' The 1st parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider Types.
' The 2nd parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider.
Dim csp As New CspParameters(1, "Schlumberger Cryptographic Service Provider")
csp.Flags = CspProviderFlags.UseDefaultKeyContainer
' Initialize an RSACryptoServiceProvider object using
' the CspParameters object.
Dim rsa As New RSACryptoServiceProvider(csp)
' Create some data to sign.
Dim data() As Byte = {0, 1, 2, 3, 4, 5, 6, 7}
Console.WriteLine("Data : " + BitConverter.ToString(data))
' Sign the data using the Smart Card CryptoGraphic Provider.
Dim sig As Byte() = rsa.SignData(data, "SHA1")
Console.WriteLine("Signature : " + BitConverter.ToString(sig))
' Verify the data using the Smart Card CryptoGraphic Provider.
Dim verified As Boolean = rsa.VerifyData(data, "SHA1", sig)
Console.WriteLine("Verified")
End Sub
End Module