AesCcm.Encrypt 方法

定義

多載

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

將純文字加密至加密文字目的地緩衝區,並在另一個緩衝區中產生驗證標記。

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

將純文字加密至加密文字目的地緩衝區,並在另一個緩衝區中產生驗證標記。

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

將純文字加密至加密文字目的地緩衝區,並在另一個緩衝區中產生驗證標記。

public void Encrypt (byte[] nonce, byte[] plaintext, byte[] ciphertext, byte[] tag, byte[]? associatedData = default);
public void Encrypt (byte[] nonce, byte[] plaintext, byte[] ciphertext, byte[] tag, byte[] associatedData = default);
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() = Nothing)

參數

nonce
Byte[]

與這個訊息建立關聯的 nonce,對於具有相同金鑰的每項作業,這應該是唯一的值。

plaintext
Byte[]

要加密內容。

ciphertext
Byte[]

要接收加密內容的位元組陣列。

tag
Byte[]

要接收所產生驗證標記的位元組陣列。

associatedData
Byte[]

與這個訊息建立關聯的額外資料,也必須在解密期間提供。

例外狀況

plaintext 參數與 ciphertext 的長度不同。

-或-

NonceByteSizes 不允許 nonce 參數長度。

-或-

TagByteSizes 不允許 tag 參數長度。

nonceciphertexttagplaintext 參數是 null

加密作業失敗。

備註

AES-CCM 演算法模式的安全性保證要求相同的 nonce 值永遠不會使用相同的索引鍵兩次。

適用於

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

將純文字加密至加密文字目的地緩衝區,並在另一個緩衝區中產生驗證標記。

public void Encrypt (ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> plaintext, Span<byte> ciphertext, Span<byte> tag, ReadOnlySpan<byte> associatedData = default);
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) = Nothing)

參數

nonce
ReadOnlySpan<Byte>

與這個訊息建立關聯的 nonce,對於具有相同金鑰的每項作業,這應該是唯一的值。

plaintext
ReadOnlySpan<Byte>

要加密內容。

ciphertext
Span<Byte>

要接收加密內容的位元組範圍。

tag
Span<Byte>

要接收所產生驗證標記的位元組範圍。

associatedData
ReadOnlySpan<Byte>

與這個訊息建立關聯的額外資料,也必須在解密期間提供。

例外狀況

plaintext 參數與 ciphertext 的長度不同。

-或-

NonceByteSizes 不允許 nonce 參數長度。

-或-

TagByteSizes 不允許 tag 參數長度。

加密作業失敗。

備註

AES-CCM 演算法模式的安全性保證要求相同的 nonce 值永遠不會使用相同的索引鍵兩次。

適用於