语言

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之前,必须设置密钥。

适用于

另请参阅