SymmetricAlgorithm.TryEncryptCbcCore 方法

定义

在派生类中重写时,尝试使用具有指定填充模式的 CBC 模式将数据加密到指定的缓冲区。

C#
protected virtual bool TryEncryptCbcCore(ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> iv, Span<byte> destination, System.Security.Cryptography.PaddingMode paddingMode, out int bytesWritten);

参数

plaintext
ReadOnlySpan<Byte>

要加密的数据。

iv
ReadOnlySpan<Byte>

初始化向量。

destination
Span<Byte>

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

paddingMode
PaddingMode

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

bytesWritten
Int32

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

返回

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

例外

派生类未提供实现。

注解

派生类必须重写此并提供实现。

此方法的实现必须精确 GetCiphertextLengthCbc(plaintext.Length, paddingMode) 写入字节, destination 并通过 bytesWritten报告。

适用于

产品 版本
.NET 6, 7, 8, 9