CspParameters.KeyContainerName フィールド
CspParameters のキー コンテナ名を表します。
Public KeyContainerName As String
[C#]
public string KeyContainerName;
[C++]
public: String* KeyContainerName;
[JScript]
public var KeyContainerName : String;
解説
キー コンテナの詳細については、Windows Cryptography API に関するドキュメントを参照してください。
使用例
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
[C#]
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));
}
}
[C++]
#using <mscorlib.dll>
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 = new CspParameters();
cp->KeyContainerName = S"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(S"Key is : \n{0}", rsa->ToXmlString(true));
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
CspParameters クラス | CspParameters メンバ | System.Security.Cryptography 名前空間 | 暗号サービス