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到的字节总数。 此参数被视为未初始化。

返回

如果 足够长,无法接收解密的数据,则为

例外

paddingnull

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

-或-

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

-或-

此实例仅表示公钥。

-或-

解密操作失败。

注解

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

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

适用于

另请参阅