/// <summary> /// Gets a 64-bit signed integer hash code of the specified string. /// </summary> /// <param name="value">The string value.</param> /// <returns>A 64-bit signed integer hash code.</returns> public unsafe static long HashString2Int64(string value) { byte[] bytes = BitHelper.GetBytes(value); long hash; uint * p = (uint *)&hash; *p = HashBytesA(bytes); *(p + 1) = HashBytesB(bytes); return(hash); }
internal unsafe static long HashString2Int64Strong(string s) { if (s != null && s.Length != 0) { byte[] bytes = BitHelper.GetBytes(s); SHA256 hash = new SHA256CryptoServiceProvider(); byte[] hashBytes = hash.ComputeHash(bytes); return(BitHelper.ToInt64(hashBytes, 0) ^ BitHelper.ToInt64(hashBytes, 8) ^ BitHelper.ToInt64(hashBytes, 24)); } return(0); }