RSA.TryDecrypt Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Attempts to decrypt the input data using the specified padding mode, writing the result into a provided buffer.
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
Parameters
- data
- ReadOnlySpan<Byte>
The data to decrypt.
- padding
- RSAEncryptionPadding
The padding mode.
- bytesWritten
- Int32
When this method returns, the total number of bytes written into destination
. This parameter is treated as uninitialized.
Returns
true
if destination
is long enough to receive the decrypted data; otherwise, false
.
Exceptions
padding
is null
.
padding
is unknown, or not supported by this implementation.
-or-
The length of data
is not equal to the number of bytes for KeySize.
-or-
This instance represents only a public key.
-or-
The decryption operation failed.
Remarks
The default implementation of this method calls Decrypt(Byte[], RSAEncryptionPadding) and copies the result to destination
.
Derived types should override this method to avoid the intermediate array creation.
The RSA decryption algorithm will always produce an output smaller than the input, therefore this method will never return false
when destination.Length >= data.Length
.
Applies to
See also
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應