SymmetricAlgorithm.EncryptEcb Method

Definition

Overloads

EncryptEcb(Byte[], PaddingMode)

Encrypts data using ECB mode with the specified padding mode.

EncryptEcb(ReadOnlySpan<Byte>, PaddingMode)

Encrypts data using ECB mode with the specified padding mode.

EncryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)

Encrypts data into the specified buffer, using ECB mode with the specified padding mode.

EncryptEcb(Byte[], PaddingMode)

Source:
SymmetricAlgorithm.cs
Source:
SymmetricAlgorithm.cs
Source:
SymmetricAlgorithm.cs

Encrypts data using ECB mode with the specified padding mode.

C#
public byte[] EncryptEcb(byte[] plaintext, System.Security.Cryptography.PaddingMode paddingMode);

Parameters

plaintext
Byte[]

The data to encrypt.

paddingMode
PaddingMode

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

Returns

Byte[]

The encrypted ciphertext data.

Exceptions

plaintext is null.

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

.NET 9 and other versions
Product Versions
.NET 6, 7, 8, 9

EncryptEcb(ReadOnlySpan<Byte>, PaddingMode)

Source:
SymmetricAlgorithm.cs
Source:
SymmetricAlgorithm.cs
Source:
SymmetricAlgorithm.cs

Encrypts data using ECB mode with the specified padding mode.

C#
public byte[] EncryptEcb(ReadOnlySpan<byte> plaintext, System.Security.Cryptography.PaddingMode paddingMode);

Parameters

plaintext
ReadOnlySpan<Byte>

The data to encrypt.

paddingMode
PaddingMode

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

Returns

Byte[]

The encrypted ciphertext data.

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

.NET 9 and other versions
Product Versions
.NET 6, 7, 8, 9

EncryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)

Source:
SymmetricAlgorithm.cs
Source:
SymmetricAlgorithm.cs
Source:
SymmetricAlgorithm.cs

Encrypts data into the specified buffer, using ECB mode with the specified padding mode.

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

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.

Returns

The total number of bytes written to destination.

Exceptions

paddingMode is not a valid padding mode.

The plaintext could not be encrypted successfully.

The buffer in destination is too small to hold the ciphertext data.

Remarks

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

Applies to

.NET 9 and other versions
Product Versions
.NET 6, 7, 8, 9