public static int GetPersistentHashCode(
this StringBuilder builder,
int startIndex,
HashType hashType
)<ExtensionAttribute>
Public Shared Function GetPersistentHashCode (
builder As StringBuilder,
startIndex As Integer,
hashType As HashType
) As Integerpublic:
[ExtensionAttribute]
static int GetPersistentHashCode(
StringBuilder^ builder,
int startIndex,
HashType hashType
)[<ExtensionAttribute>]
static member GetPersistentHashCode :
builder : StringBuilder *
startIndex : int *
hashType : HashType -> int The method String.GetHashCode() returns a different hash code for an identical string with each program run for security reasons. Apart from the fact that the hash algorithm of String.GetHashCode() could be different in different framework versions, it makes no sense to use the return value of GetHashCode for reuse. The alternatives, e.g. MD5 or SHA256, use more storage space and are slower. This method offers a slim alternative that is suitable for hashing very short strings that are not used in a security-critical context.
The hashcode generated by this method is not identical to the hashcode generated by the .NET Framework 4.0, because it uses roundshifting to preserve more information.
The hashcodes generated with different values for hashType may provide different hashcodes for an identical Char sequence and MUST therefore not be mixed.
Do not use the hashcodes generated by this method for security-critical purposes (such as hashing passwords)!
| ArgumentNullException | builder is null. |
| ArgumentException | hashType is not a defined value of the HashType enum. |