ISpanDataProtector.Unprotect<TWriter> Method

Definition

Cryptographically unprotects a piece of protected data and writes the result to a buffer writer.

public void Unprotect<TWriter>(ReadOnlySpan<byte> protectedData, ref TWriter destination) where TWriter : System.Buffers.IBufferWriter<byte>, allows ref struct;
abstract member Unprotect : ReadOnlySpan<byte> * 'Writer -> unit (requires 'Writer :> System.Buffers.IBufferWriter<byte>)
Public Sub Unprotect(Of TWriter As IBufferWriter(Of Byte)) (protectedData As ReadOnlySpan(Of Byte), ByRef destination As TWriter)

Type Parameters

TWriter

The type of buffer writer to write the unprotected data to.

Parameters

protectedData
ReadOnlySpan<Byte>

The protected data to unprotect.

destination
TWriter

The buffer writer to which the unprotected plaintext will be written.

Remarks

This method provides an optimized, streaming alternative to Unprotect(Byte[]). Rather than allocating an intermediate buffer, the unprotected 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.

Applies to