DSACryptoServiceProvider.PersistKeyInCsp プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DSACryptoServiceProvider.PersistKeyInCsp プロパティの意味・解説 

DSACryptoServiceProvider.PersistKeyInCsp プロパティ

暗号サービス プロバイダ (CSP) でキー永続化する必要があるかどうかを示す値を取得または設定します

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

Dim instance As DSACryptoServiceProvider
Dim value As Boolean

value = instance.PersistKeyInCsp

instance.PersistKeyInCsp = value
public bool PersistKeyInCsp { get;
 set; }
public:
property bool PersistKeyInCsp {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_PersistKeyInCsp ()

/** @property */
public void set_PersistKeyInCsp (boolean value)
public function get PersistKeyInCsp
 () : boolean

public function set PersistKeyInCsp
 (value : boolean)

プロパティ
キーCSP永続化する場合trueそれ以外場合false

解説解説
使用例使用例

DSACryptoServiceProvider のインスタンス作成しキーキー コンテナ内で永続化してから、そのキー削除するコード例次に示します

Imports System.Security.Cryptography

Module DSACSPExample

    Sub Main()

        Dim KeyContainerName As String
 = "MyKeyContainer"

        'Create a new key and persist it in 
        'the key container.  
        DSAPersistKeyInCSP(KeyContainerName)

        'Delete the key from the key container.
        DSADeleteKeyInCSP(KeyContainerName)
    End Sub


    Sub DSAPersistKeyInCSP(ByVal ContainerName
 As String)
        Try
            ' Create a new instance of CspParameters.  Pass
            ' 13 to specify a DSA container or 1 to specify
            ' an DSA container.  The default is 1.
            Dim cspParams As New
 CspParameters

            ' Specify the container name using the passed variable.
            cspParams.KeyContainerName = ContainerName

            'Create a new instance of DSACryptoServiceProvider to generate
            'a new key pair.  Pass the CspParameters class to persist
 the 
            'key in the container.  The PersistKeyInCsp property is
 True by 
            'default, allowing the key to be persisted. 
            Dim DSAalg As New
 DSACryptoServiceProvider(cspParams)

            'Indicate that the key was persisted.
            Console.WriteLine("The DSA key was persisted in the
 container, ""{0}"".",
 ContainerName)
        Catch e As CryptographicException
            Console.WriteLine(e.Message)
        End Try
    End Sub


    Sub DSADeleteKeyInCSP(ByVal ContainerName
 As String)
        Try
            ' Create a new instance of CspParameters.  Pass
            ' 13 to specify a DSA container or 1 to specify
            ' an DSA container.  The default is 1.
            Dim cspParams As New
 CspParameters

            ' Specify the container name using the passed variable.
            cspParams.KeyContainerName = ContainerName

            'Create a new instance of DSACryptoServiceProvider. 
            'Pass the CspParameters class to use the 
            'key in the container.
            Dim DSAalg As New
 DSACryptoServiceProvider(cspParams)

            'Explicitly set the PersistKeyInCsp property to False
            'to delete the key entry in the container.
            DSAalg.PersistKeyInCsp = False

            'Call Clear to release resources and delete the key from
 the container.
            DSAalg.Clear()

            'Indicate that the key was persisted.
            Console.WriteLine("The DSA key was deleted from the
 container, ""{0}"".",
 ContainerName)
        Catch e As CryptographicException
            Console.WriteLine(e.Message)
        End Try
    End Sub

End Module
using System;
using System.Security.Cryptography;

class DSACSPSample
{

    static void Main()
    {

        string KeyContainerName = "MyKeyContainer";

        //Create a new key and persist it in 
        //the key container.  
        DSAPersistKeyInCSP(KeyContainerName);

        //Delete the key from the key container.
        DSADeleteKeyInCSP(KeyContainerName);
    }

    public static void DSAPersistKeyInCSP(string
 ContainerName)
    {
        try
        {
            // Create a new instance of CspParameters.  Pass
            // 13 to specify a DSA container or 1 to specify
            // an DSA container.  The default is 1.
            CspParameters cspParams = new CspParameters();

            // Specify the container name using the passed variable.
            cspParams.KeyContainerName = ContainerName;

            //Create a new instance of DSACryptoServiceProvider to generate
            //a new key pair.  Pass the CspParameters class to persist
 the 
            //key in the container.  The PersistKeyInCsp property is
 true by 
            //default, allowing the key to be persisted. 
            DSACryptoServiceProvider DSAalg = new DSACryptoServiceProvider(cspParams);

          

            //Indicate that the key was persisted.
            Console.WriteLine("The DSA key was persisted in
 the container, \"{0}\".", ContainerName);
        }
        catch(CryptographicException e)
        {
            Console.WriteLine(e.Message);

        }
    }

    public static void DSADeleteKeyInCSP(string
 ContainerName)
    {
        try
        {
            // Create a new instance of CspParameters.  Pass
            // 13 to specify a DSA container or 1 to specify
            // an DSA container.  The default is 1.
            CspParameters cspParams = new CspParameters();

            // Specify the container name using the passed variable.
            cspParams.KeyContainerName = ContainerName;

            //Create a new instance of DSACryptoServiceProvider. 
            //Pass the CspParameters class to use the 
            //key in the container.
            DSACryptoServiceProvider DSAalg = new DSACryptoServiceProvider(cspParams);

            //Explicitly set the PersistKeyInCsp property to false
            //to delete the key entry in the container.
            DSAalg.PersistKeyInCsp = false;

            //Call Clear to release resources and delete the key from
 the container.
            DSAalg.Clear();

            //Indicate that the key was persisted.
            Console.WriteLine("The DSA key was deleted from the container, \"{0}\".",
 ContainerName);
        }
        catch(CryptographicException e)
        {
            Console.WriteLine(e.Message);

        }
    }
}
using namespace System;
using namespace System::Security::Cryptography;
void DSAPersistKeyInCSP( String^ ContainerName )
{
   try
   {
      
      // Create a new instance of CspParameters.  Pass
      // 13 to specify a DSA container or 1 to specify
      // an DSA container.  The default is 1.
      CspParameters^ cspParams = gcnew CspParameters;
      
      // Specify the container name using the passed variable.
      cspParams->KeyContainerName = ContainerName;
      
      //Create a new instance of DSACryptoServiceProvider to generate
      //a new key pair.  Pass the CspParameters class to persist the
 
      //key in the container.  The PersistKeyInCsp property is true
 by 
      //default, allowing the key to be persisted. 
      DSACryptoServiceProvider^ DSAalg = gcnew DSACryptoServiceProvider( cspParams
 );
      
      //Indicate that the key was persisted.
      Console::WriteLine( "The DSA key was persisted in the
 container, \"{0}\".", ContainerName );
   }
   catch ( CryptographicException^ e ) 
   {
      Console::WriteLine( e->Message );
   }

}

void DSADeleteKeyInCSP( String^ ContainerName )
{
   try
   {
      
      // Create a new instance of CspParameters.  Pass
      // 13 to specify a DSA container or 1 to specify
      // an DSA container.  The default is 1.
      CspParameters^ cspParams = gcnew CspParameters;
      
      // Specify the container name using the passed variable.
      cspParams->KeyContainerName = ContainerName;
      
      //Create a new instance of DSACryptoServiceProvider. 
      //Pass the CspParameters class to use the 
      //key in the container.
      DSACryptoServiceProvider^ DSAalg = gcnew DSACryptoServiceProvider( cspParams
 );
      
      //Explicitly set the PersistKeyInCsp property to false
      //to delete the key entry in the container.
      DSAalg->PersistKeyInCsp = false;
      
      //Call Clear to release resources and delete the key from the
 container.
      DSAalg->Clear();
      
      //Indicate that the key was persisted.
      Console::WriteLine( "The DSA key was deleted from the container, \"{0}\".",
 ContainerName );
   }
   catch ( CryptographicException^ e ) 
   {
      Console::WriteLine( e->Message );
   }

}

int main()
{
   String^ KeyContainerName = "MyKeyContainer";
   
   //Create a new key and persist it in 
   //the key container.  
   DSAPersistKeyInCSP( KeyContainerName );
   
   //Delete the key from the key container.
   DSADeleteKeyInCSP( KeyContainerName );
}

import System.*;
import System.Security.Cryptography.*;

class DSACSPSample
{
    public static void main(String
 args[])
    {
        String keyContainerName = "MyKeyContainer";
        //Create a new key and persist it in 
        //the key container.  
        DSAPersistKeyInCSP(keyContainerName);
        //Delete the key from the key container.
        DSADeleteKeyInCSP(keyContainerName);
    } //main

    public static void DSAPersistKeyInCSP(String
 containerName)
    {
        try {
            // Create a new instance of CspParameters.  Pass
            // 13 to specify a DSA container or 1 to specify
            // an DSA container.  The default is 1.
            CspParameters cspParams = new CspParameters();
            // Specify the container name using the passed variable.
            cspParams.KeyContainerName = containerName;
            //Create a new instance of DSACryptoServiceProvider to generate
            //a new key pair.  Pass the CspParameters class to persist
 the 
            //key in the container.  The PersistKeyInCsp property is
 true by 
            //default, allowing the key to be persisted. 
            DSACryptoServiceProvider dsaAlg = 
                new DSACryptoServiceProvider(cspParams);
            //Indicate that the key was persisted.
            Console.WriteLine("The DSA key was persisted in
 the container, " 
                + "\"{0}\".", containerName);
        }
        catch (CryptographicException e) {
            Console.WriteLine(e.get_Message());
        }
    } //DSAPersistKeyInCSP

    public static void DSADeleteKeyInCSP(String
 containerName)
    {
        try {
            // Create a new instance of CspParameters.  Pass
            // 13 to specify a DSA container or 1 to specify
            // an DSA container.  The default is 1.
            CspParameters cspParams = new CspParameters();
            // Specify the container name using the passed variable.
            cspParams.KeyContainerName = containerName;
            //Create a new instance of DSACryptoServiceProvider. 
            //Pass the CspParameters class to use the 
            //key in the container.
            DSACryptoServiceProvider dsaAlg = 
                new DSACryptoServiceProvider(cspParams);
            //Explicitly set the PersistKeyInCsp property to false
            //to delete the key entry in the container.
            dsaAlg.set_PersistKeyInCsp(false);
            //Call Clear to release resources and delete the key from
 the 
            //container.
            dsaAlg.Clear();
            //Indicate that the key was persisted.
            Console.WriteLine("The DSA key was deleted from the container, "
 
                + "\"{0}\".", containerName);
        }
        catch (CryptographicException e) {
            Console.WriteLine(e.get_Message());
        }
    } //DSADeleteKeyInCSP
} //DSACSPSample
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DSACryptoServiceProvider クラス
DSACryptoServiceProvider メンバ
System.Security.Cryptography 名前空間
その他の技術情報
暗号サービス


このページでは「.NET Framework クラス ライブラリ リファレンス」からDSACryptoServiceProvider.PersistKeyInCsp プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDSACryptoServiceProvider.PersistKeyInCsp プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDSACryptoServiceProvider.PersistKeyInCsp プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

DSACryptoServiceProvider.PersistKeyInCsp プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DSACryptoServiceProvider.PersistKeyInCsp プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS