本文整理汇总了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