RSA.TryDecrypt 方法

定义

尝试使用指定填充模式对输入数据进行解密,然后将结果写入到提供的缓冲区中。

public:
 virtual bool TryDecrypt(ReadOnlySpan<System::Byte> data, Span<System::Byte> destination, System::Security::Cryptography::RSAEncryptionPadding ^ padding, [Runtime::InteropServices::Out] int % bytesWritten);
public virtual bool TryDecrypt (ReadOnlySpan<byte> data, Span<byte> destination, System.Security.Cryptography.RSAEncryptionPadding padding, out int bytesWritten);
abstract member TryDecrypt : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.RSAEncryptionPadding * int -> bool
override this.TryDecrypt : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.RSAEncryptionPadding * int -> bool
Public Overridable Function TryDecrypt (data As ReadOnlySpan(Of Byte), destination As Span(Of Byte), padding As RSAEncryptionPadding, ByRef bytesWritten As Integer) As Boolean

参数

data
ReadOnlySpan<Byte>

要解密的数据。

destination
Span<Byte>

要接收解密数据的缓冲区。

padding
RSAEncryptionPadding

填充模式。

bytesWritten
Int32

此方法返回时,为写入 destination 的字节总数。 该参数未经初始化即被处理。

返回

Boolean

如果 destination 的长度足以接收解密数据,则为 true;否则为 false

例外

padding 上声明的默认值为 null

padding 未知或不受此实现支持。

  • 或 -

data 的长度不等于 KeySize 的字节数。

  • 或 -

此实例仅表示一个公钥。

  • 或 -

解密操作失败。

注解

此方法的默认实现调用 Decrypt(Byte[], RSAEncryptionPadding) 并将结果 destination复制到 。 派生类型应重写此方法以避免创建中间数组。

RSA 解密算法将始终生成小于输入的输出,因此此方法永远不会在输入时destination.Length >= data.Length返回false

适用于

另请参阅