SymmetricAlgorithm.TryEncryptEcb 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 encrypt data into the specified buffer, using ECB mode with the specified padding mode.

C#
public bool TryEncryptEcb(ReadOnlySpan<byte> plaintext, Span<byte> destination, System.Security.Cryptography.PaddingMode paddingMode, out int bytesWritten);

Parameters

plaintext
ReadOnlySpan<Byte>

The data to encrypt.

destination
Span<Byte>

The buffer to receive the ciphertext data.

paddingMode
PaddingMode

The padding mode used to produce the ciphertext and remove during decryption.

bytesWritten
Int32

When this method returns, contains the total number of bytes written to destination.

Returns

true if destination was large enough to receive the encrypted data; otherwise, false.

Exceptions

paddingMode is not a valid padding mode.

The plaintext could not be encrypted successfully.

Remarks

This method's behavior is defined by TryEncryptEcbCore(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32).

Applies to

Produkt Versioner
.NET 6, 7, 8, 9, 10