संपादित करें

इसके माध्यम से साझा किया गया


SymmetricAlgorithm.EncryptCbc Method

Definition

Overloads

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

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

EncryptCbc(Byte[], Byte[], PaddingMode)

Encrypts data using CBC mode with the specified padding mode.

EncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode)

Encrypts data using CBC mode with the specified padding mode.

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

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

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

public int EncryptCbc (ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> iv, Span<byte> destination, System.Security.Cryptography.PaddingMode paddingMode = System.Security.Cryptography.PaddingMode.PKCS7);
member this.EncryptCbc : ReadOnlySpan<byte> * ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.PaddingMode -> int
Public Function EncryptCbc (plaintext As ReadOnlySpan(Of Byte), iv As ReadOnlySpan(Of Byte), destination As Span(Of Byte), Optional paddingMode As PaddingMode = System.Security.Cryptography.PaddingMode.PKCS7) As Integer

Parameters

plaintext
ReadOnlySpan<Byte>

The data to encrypt.

iv
ReadOnlySpan<Byte>

The initialization vector.

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.

iv is the incorrect length. Callers are expected to pass an initialization vector that is exactly BlockSize in length, converted to bytes (BlockSize / 8).

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 TryEncryptCbcCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32).

Applies to

EncryptCbc(Byte[], Byte[], PaddingMode)

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

Encrypts data using CBC mode with the specified padding mode.

public byte[] EncryptCbc (byte[] plaintext, byte[] iv, System.Security.Cryptography.PaddingMode paddingMode = System.Security.Cryptography.PaddingMode.PKCS7);
member this.EncryptCbc : byte[] * byte[] * System.Security.Cryptography.PaddingMode -> byte[]
Public Function EncryptCbc (plaintext As Byte(), iv As Byte(), Optional paddingMode As PaddingMode = System.Security.Cryptography.PaddingMode.PKCS7) As Byte()

Parameters

plaintext
Byte[]

The data to encrypt.

iv
Byte[]

The initialization vector.

paddingMode
PaddingMode

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

Returns

Byte[]

The encrypted ciphertext data.

Exceptions

plaintext or iv is null.

paddingMode is not a valid padding mode.

iv is the incorrect length. Callers are expected to pass an initialization vector that is exactly BlockSize in length, converted to bytes (BlockSize / 8).

The plaintext could not be encrypted successfully.

Remarks

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

Applies to

EncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode)

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

Encrypts data using CBC mode with the specified padding mode.

public byte[] EncryptCbc (ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> iv, System.Security.Cryptography.PaddingMode paddingMode = System.Security.Cryptography.PaddingMode.PKCS7);
member this.EncryptCbc : ReadOnlySpan<byte> * ReadOnlySpan<byte> * System.Security.Cryptography.PaddingMode -> byte[]
Public Function EncryptCbc (plaintext As ReadOnlySpan(Of Byte), iv As ReadOnlySpan(Of Byte), Optional paddingMode As PaddingMode = System.Security.Cryptography.PaddingMode.PKCS7) As Byte()

Parameters

plaintext
ReadOnlySpan<Byte>

The data to encrypt.

iv
ReadOnlySpan<Byte>

The initialization vector.

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.

iv is the incorrect length. Callers are expected to pass an initialization vector that is exactly BlockSize in length, converted to bytes (BlockSize / 8).

The plaintext could not be encrypted successfully.

Remarks

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

Applies to