語言

ChaCha20Poly1305.Encrypt 方法

定義

將明文加密到密文目的緩衝區,並將認證標籤產生到獨立的緩衝區。

多載

名稱 Description
Encrypt(Byte[], Byte[], Byte[], Byte[], Byte[])

將明文加密到密文目的緩衝區,並將認證標籤產生到獨立的緩衝區。

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

將明文加密到密文目的緩衝區,並將認證標籤產生到獨立的緩衝區。

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

來源:
ChaCha20Poly1305.cs
來源:
ChaCha20Poly1305.cs
來源:
ChaCha20Poly1305.cs
來源:
ChaCha20Poly1305.cs
來源:
ChaCha20Poly1305.cs

將明文加密到密文目的緩衝區,並將認證標籤產生到獨立的緩衝區。

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 的長度並不相同。

-或-

nonce參數長度並非 12 位元組(96 位元)。

-或-

tag參數長度不是 16 位元組(128 位元組)。

參數 nonce, ciphertext, tag, 或 plaintext 為 null。

加密操作失敗了。

備註

ChaCha20/Poly1305 演算法模式的安全保障要求,同一 nonce 值絕不能重複使用同一金鑰。

適用於

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

來源:
ChaCha20Poly1305.cs
來源:
ChaCha20Poly1305.cs
來源:
ChaCha20Poly1305.cs
來源:
ChaCha20Poly1305.cs
來源:
ChaCha20Poly1305.cs

將明文加密到密文目的緩衝區,並將認證標籤產生到獨立的緩衝區。

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 的長度並不相同。

-或-

nonce參數長度並非 12 位元組(96 位元)。

-或-

tag參數長度不是 16 位元組(128 位元組)。

參數 nonce, ciphertext, tag, 或 plaintext 為 null。

加密操作失敗了。

備註

ChaCha20/Poly1305 演算法模式的安全保障要求,同一 nonce 值絕不能重複使用同一金鑰。

適用於