Share via


SymmetricAlgorithm.TryEncryptEcb 方法

定义

尝试使用具有指定填充模式的 ECB 模式将数据加密到指定的缓冲区。

public:
 bool TryEncryptEcb(ReadOnlySpan<System::Byte> plaintext, Span<System::Byte> destination, System::Security::Cryptography::PaddingMode paddingMode, [Runtime::InteropServices::Out] int % bytesWritten);
public bool TryEncryptEcb (ReadOnlySpan<byte> plaintext, Span<byte> destination, System.Security.Cryptography.PaddingMode paddingMode, out int bytesWritten);
member this.TryEncryptEcb : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.PaddingMode * int -> bool
Public Function TryEncryptEcb (plaintext As ReadOnlySpan(Of Byte), destination As Span(Of Byte), paddingMode As PaddingMode, ByRef bytesWritten As Integer) As Boolean

参数

plaintext
ReadOnlySpan<Byte>

要加密的数据。

destination
Span<Byte>

用于接收密码文本数据的缓冲区。

paddingMode
PaddingMode

用于生成密码文本并在解密期间删除的填充模式。

bytesWritten
Int32

此方法返回时,包含写入 到 destination的字节总数。

返回

true 如果 destination 大小足以接收加密数据,则为 ;否则为 false

例外

paddingMode 不是有效的填充模式。

无法成功加密纯文本。

注解

此方法的行为由 TryEncryptEcbCore(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)定义。

适用于