語言

RSAOAEPKeyExchangeFormatter.SetKey(AsymmetricAlgorithm) 方法

定義

設定公鑰用於加密金鑰交換資料。

public:
 override void SetKey(System::Security::Cryptography::AsymmetricAlgorithm ^ key);
public override void SetKey(System.Security.Cryptography.AsymmetricAlgorithm key);
override this.SetKey : System.Security.Cryptography.AsymmetricAlgorithm -> unit
Public Overrides Sub SetKey (key As AsymmetricAlgorithm)

參數

key
AsymmetricAlgorithm

持有公鑰的演算法實例 RSA 。

例外狀況

key 是 null。

範例

以下程式碼範例示範如何使用此 SetKey 方法設定 RSA 解密金鑰。 此程式碼範例是本類別更大範例 RSAOAEPKeyExchangeFormatter 的一部分。

RSA key = RSA.Create();
rsaFormatter.SetKey(key);
Dim key As RSA = RSA.Create()
rsaFormatter.SetKey(key)

備註

你必須先設定鑰匙再呼叫 CreateKeyExchange。

適用於

另請參閱