RSA.TryEncrypt 方法

定義

使用指定的填補模式,嘗試加密所提供緩衝區中的輸入資料。

public:
 virtual bool TryEncrypt(ReadOnlySpan<System::Byte> data, Span<System::Byte> destination, System::Security::Cryptography::RSAEncryptionPadding ^ padding, [Runtime::InteropServices::Out] int % bytesWritten);
public virtual bool TryEncrypt (ReadOnlySpan<byte> data, Span<byte> destination, System.Security.Cryptography.RSAEncryptionPadding padding, out int bytesWritten);
abstract member TryEncrypt : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.RSAEncryptionPadding * int -> bool
override this.TryEncrypt : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.RSAEncryptionPadding * int -> bool
Public Overridable Function TryEncrypt (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 的位元組總數。 這個參數會被視為未初始化。

傳回

如果 destination 的長度足以接收加密的資料,則為 true;否則為 false

例外狀況

paddingnull

padding 未知,或不支援此實作。

-或-

data 長度太長,不適合 KeySize 和所選填補的組合。

-或-

加密作業失敗。

備註

此方法的預設實作會呼叫 Encrypt(Byte[], RSAEncryptionPadding) ,並將結果 destination 複製到 。 衍生型別應該覆寫這個方法,以避免建立中繼陣列。

RSA 加密演算法一律會產生等於位所需 KeySize 位元組數目的輸出。

適用於

另請參閱