ISpanDataProtector.Protect<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.
Cryptographically protects a piece of plaintext data and writes the result to a buffer writer.
public void Protect<TWriter>(ReadOnlySpan<byte> plaintext, ref TWriter destination) where TWriter : System.Buffers.IBufferWriter<byte>, allows ref struct;
abstract member Protect : ReadOnlySpan<byte> * 'Writer -> unit (requires 'Writer :> System.Buffers.IBufferWriter<byte>)
Public Sub Protect(Of TWriter As IBufferWriter(Of Byte)) (plaintext As ReadOnlySpan(Of Byte), ByRef destination As TWriter)
Type Parameters
- TWriter
The type of buffer writer to write the protected data to.
Parameters
- plaintext
- ReadOnlySpan<Byte>
The plaintext data to protect.
- destination
- TWriter
The buffer writer to which the protected data will be written.
Remarks
This method provides an optimized, streaming alternative to Protect(Byte[]). Rather than allocating an intermediate buffer, the protected data 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.