Sdílet prostřednictvím


SourceText.GetChecksum Method

Definition

Cryptographic checksum determined by ChecksumAlgorithm. Computed using the original bytes that were used to produce this SourceText (if any of the From methods were used that take a byte[] or Stream). Otherwise, computed by writing this SourceText back to a Stream (using the provided Encoding), and computing the hash off of that.

public:
 System::Collections::Immutable::ImmutableArray<System::Byte> GetChecksum();
public System.Collections.Immutable.ImmutableArray<byte> GetChecksum ();
member this.GetChecksum : unit -> System.Collections.Immutable.ImmutableArray<byte>
Public Function GetChecksum () As ImmutableArray(Of Byte)

Returns

Remarks

Two different SourceText instances with the same content (see ContentEquals(SourceText)) may have different results for this method. This is because different originating bytes may end up with the same final content. For example, a utf8 stream with a byte-order-mark will produce the same contents as a utf8 stream without one. However, these preamble bytes will be part of the checksum, leading to different results.

Similarly, two different SourceText instances with different contents can have the same checksum in normal scenarios. This is because the use of the Encoding can lead to different characters being mapped to the same sequence of encoded bytes.

As such, this function should only be used by clients who need to know the exact SHA hash from the original content bytes, and for no other purposes.

Applies to