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 算法的实例。

例外

keynull

示例

下面的代码示例演示如何使用 SetKey 该方法设置 RSA 密钥进行解密。 此代码示例是为类提供的大型示例的 RSAOAEPKeyExchangeFormatter 一部分。

RSA^ key = RSA::Create();
rsaFormatter->SetKey( key );
RSA key = RSA.Create();
rsaFormatter.SetKey(key);
Dim key As RSA = RSA.Create()
rsaFormatter.SetKey(key)

注解

在调用 CreateKeyExchange之前,必须设置密钥。

适用于

另请参阅