ISpanAuthenticatedEncryptor.Decrypt<TWriter> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Validates the authentication tag of and decrypts a blob of encrypted data, writing the result to a buffer writer.
public void Decrypt<TWriter>(ReadOnlySpan<byte> ciphertext, ReadOnlySpan<byte> additionalAuthenticatedData, ref TWriter destination) where TWriter : System.Buffers.IBufferWriter<byte>, allows ref struct;
abstract member Decrypt : ReadOnlySpan<byte> * ReadOnlySpan<byte> * 'Writer -> unit (requires 'Writer :> System.Buffers.IBufferWriter<byte>)
Public Sub Decrypt(Of TWriter As IBufferWriter(Of Byte)) (ciphertext As ReadOnlySpan(Of Byte), additionalAuthenticatedData As ReadOnlySpan(Of Byte), ByRef destination As TWriter)
Type Parameters
- TWriter
The type of buffer writer to write the plaintext to.
Parameters
- ciphertext
- ReadOnlySpan<Byte>
The ciphertext (including authentication tag) to decrypt.
- additionalAuthenticatedData
- ReadOnlySpan<Byte>
Any ancillary data which was used during computation of the authentication tag. The same AAD must have been specified in the corresponding call to Encrypt<TWriter>(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, TWriter).
- destination
- TWriter
The buffer writer to which the decrypted plaintext will be written.
Remarks
This method provides an optimized, streaming alternative to Decrypt(ArraySegment<Byte>, ArraySegment<Byte>). Rather than allocating an intermediate buffer, the plaintext is written directly to the provided buffer writer, which can improve performance and reduce memory allocation pressure. The buffer writer is advanced by the total number of bytes written to it.