AesCcm.Encrypt 方法

定義

多載

Encrypt(Byte[], Byte[], Byte[], Byte[], Byte[])

將純文字加密至加密文字目的地緩衝區,並在另一個緩衝區中產生驗證標記。Encrypts the plaintext into the ciphertext destination buffer and generates the authentication tag into a separate buffer.

Encrypt(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Span<Byte>, ReadOnlySpan<Byte>)

將純文字加密至加密文字目的地緩衝區,並在另一個緩衝區中產生驗證標記。Encrypts the plaintext into the ciphertext destination buffer and generates the authentication tag into a separate buffer.

Encrypt(Byte[], Byte[], Byte[], Byte[], Byte[])

將純文字加密至加密文字目的地緩衝區,並在另一個緩衝區中產生驗證標記。Encrypts the plaintext into the ciphertext destination buffer and generates the authentication tag into a separate buffer.

public void Encrypt (byte[] nonce, byte[] plaintext, byte[] ciphertext, byte[] tag, byte[] associatedData = null);
member this.Encrypt : byte[] * byte[] * byte[] * byte[] * byte[] -> unit
Public Sub Encrypt (nonce As Byte(), plaintext As Byte(), ciphertext As Byte(), tag As Byte(), Optional associatedData As Byte() = null)

參數

nonce
Byte[]

與這個訊息建立關聯的 nonce,對於具有相同金鑰的每項作業,這應該是唯一的值。The nonce associated with this message, which should be a unique value for every operation with the same key.

plaintext
Byte[]

要加密內容。The content to encrypt.

ciphertext
Byte[]

要接收加密內容的位元組陣列。The byte array to receive the encrypted contents.

tag
Byte[]

要接收所產生驗證標記的位元組陣列。The byte array to receive the generated authentication tag.

associatedData
Byte[]

與這個訊息建立關聯的額外資料,也必須在解密期間提供。Extra data associated with this message, which must also be provided during decryption.

例外狀況

plaintext 參數與 ciphertext 的長度不同。The plaintext parameter and the ciphertext do not have the same length.

-或--or-

nonce 不允許 NonceByteSizes 參數長度。The nonce parameter length is not permitted by NonceByteSizes.

-或--or-

tag 不允許 TagByteSizes 參數長度。The tag parameter length is not permitted by TagByteSizes.

nonceciphertexttagplaintext 參數是 nullThe nonce, ciphertext, tag, or plaintext parameter is null.

加密作業失敗。The encryption operation failed.

備註

AES-CCM 演算法模式的安全性保證要求相同的 nonce 值永遠不會使用相同的金鑰兩次。The security guarantees of the AES-CCM algorithm mode require that the same nonce value is never used twice with the same key.

Encrypt(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Span<Byte>, ReadOnlySpan<Byte>)

將純文字加密至加密文字目的地緩衝區,並在另一個緩衝區中產生驗證標記。Encrypts the plaintext into the ciphertext destination buffer and generates the authentication tag into a separate buffer.

public void Encrypt (ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> plaintext, Span<byte> ciphertext, Span<byte> tag, ReadOnlySpan<byte> associatedData = null);
member this.Encrypt : ReadOnlySpan<byte> * ReadOnlySpan<byte> * Span<byte> * Span<byte> * ReadOnlySpan<byte> -> unit
Public Sub Encrypt (nonce As ReadOnlySpan(Of Byte), plaintext As ReadOnlySpan(Of Byte), ciphertext As Span(Of Byte), tag As Span(Of Byte), Optional associatedData As ReadOnlySpan(Of Byte) = null)

參數

nonce
ReadOnlySpan<Byte>

與這個訊息建立關聯的 nonce,對於具有相同金鑰的每項作業,這應該是唯一的值。The nonce associated with this message, which should be a unique value for every operation with the same key.

plaintext
ReadOnlySpan<Byte>

要加密內容。The content to encrypt.

ciphertext
Span<Byte>

要接收加密內容的位元組範圍。The byte span to receive the encrypted contents.

tag
Span<Byte>

要接收所產生驗證標記的位元組範圍。The byte span to receive the generated authentication tag.

associatedData
ReadOnlySpan<Byte>

與這個訊息建立關聯的額外資料,也必須在解密期間提供。Extra data associated with this message, which must also be provided during decryption.

例外狀況

plaintext 參數與 ciphertext 的長度不同。The plaintext parameter and the ciphertext do not have the same length.

-或--or-

nonce 不允許 NonceByteSizes 參數長度。The nonce parameter length is not permitted by NonceByteSizes.

-或--or-

tag 不允許 TagByteSizes 參數長度。The tag parameter length is not permitted by TagByteSizes.

加密作業失敗。The encryption operation failed.

備註

AES-CCM 演算法模式的安全性保證要求相同的 nonce 值永遠不會使用相同的金鑰兩次。The security guarantees of the AES-CCM algorithm mode require that the same nonce value is never used twice with the same key.

適用於