Component UtilitiesGet Hash Code Deterministic Method
This returns a deterministic hash code that is the same in the full .NET Framework and in .NET Core
in every session given the same string to hash.
Definition
Namespace: Sandcastle.Core
Assembly: Sandcastle.Core (in Sandcastle.Core.dll) Version: 2026.1.20.0
The deterministic hash code
Assembly: Sandcastle.Core (in Sandcastle.Core.dll) Version: 2026.1.20.0
C#
public static int GetHashCodeDeterministic(
this string hashString
)VB
<ExtensionAttribute>
Public Shared Function GetHashCodeDeterministic (
hashString As String
) As IntegerC++
public:
[ExtensionAttribute]
static int GetHashCodeDeterministic(
String^ hashString
)F#
[<ExtensionAttribute>]
static member GetHashCodeDeterministic :
hashString : string -> int Parameters
- hashString String
- The string to hash
Return Value
Int32The deterministic hash code
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Remarks
The hashing algorithm differs in .NET Core and returns different hash codes for each session.
This was done for security to prevent DoS attacks. For the help file builder, we're just using it to
generate a short filenames or other constant IDs. As such, we need a deterministic hash code to keep
generating the same hash code for the same IDs in all sessions regardless of platform so that the
filenames and other IDs stay the same for backward compatibility.