次の方法で共有


CspParameters コンストラクタ (Int32)

指定したプロバイダの種類コードコードを使用して、CspParameters クラスの新しいインスタンスを初期化します。

名前空間: System.Security.Cryptography
アセンブリ: mscorlib (mscorlib.dll 内)

構文

'宣言
Public Sub New ( _
    dwTypeIn As Integer _
)
'使用
Dim dwTypeIn As Integer

Dim instance As New CspParameters(dwTypeIn)
public CspParameters (
    int dwTypeIn
)
public:
CspParameters (
    int dwTypeIn
)
public CspParameters (
    int dwTypeIn
)
public function CspParameters (
    dwTypeIn : int
)
適用できません。

パラメータ

  • dwTypeIn
    作成するプロバイダの種類を示すプロバイダの種類コード。

解説

CspParameters コンストラクタを使用し、プロバイダを表す数値を渡してプロバイダの種類を指定します。既定プロバイダの種類を表す数値は、WinCrypt.h ヘッダー ファイルで定義されます。

  • RSA アルゴリズムと互換性のあるプロバイダを指定するには、値 1 を dwTypeIn パラメータに渡します。

  • DSA アルゴリズムと互換性のあるプロバイダを指定するには、値 13 を dwTypeIn パラメータに渡します。

他のプロバイダの種類の値については、ProviderType フィールドを参照してください。既定のプロバイダの種類とそれらの動作の詳細については、MSDN ライブラリで CAPI (Microsoft Cryptography API) に関するドキュメントを参照してください。

使用例

CspParameters クラスを使用してキー コンテナを作成し、そのコンテナにキーを保存するコード例を次に示します。

Imports System
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 'Main
End Class 'StoreKey
using System;
using System.IO;
using System.Security.Cryptography;

public class StoreKey
{
    public static void Main()
    {
        // creates the CspParameters object and sets the key container name used to store the RSA key pair
        CspParameters cp = new CspParameters();
        cp.KeyContainerName = "MyKeyContainerName";

        // instantiates the rsa instance accessing the key container MyKeyContainerName
        RSACryptoServiceProvider rsa = 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 : \n" + rsa.ToXmlString(true));
    }
}
using namespace System;
using namespace System::IO;
using namespace System::Security::Cryptography;
int main()
{
   
   // creates the CspParameters object and sets the key container name used to store the RSA key pair
   CspParameters^ cp = gcnew CspParameters;
   cp->KeyContainerName = "MyKeyContainerName";
   
   // instantiates the rsa instance accessing the key container MyKeyContainerName
   RSACryptoServiceProvider^ rsa = gcnew 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 : \n{0}", rsa->ToXmlString( true ) );
}
import System.*;
import System.IO.*;
import System.Security.Cryptography.*;

public class StoreKey
{
    public static void main(String[] args)
    {
        // creates the CspParameters object and sets the key container name 
        // used to store the RSA key pair
        CspParameters cp = new CspParameters();
        cp.KeyContainerName = "MyKeyContainerName";

        // instantiates the rsa instance accessing the key container 
        // MyKeyContainerName
        RSACryptoServiceProvider rsa = 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 : \n" + rsa.ToXmlString(true));
    } //main
} //StoreKey

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

.NET Compact Framework

サポート対象 : 2.0

参照

関連項目

CspParameters クラス
CspParameters メンバ
System.Security.Cryptography 名前空間

その他の技術情報

暗号サービス