Example #1
0
        private ulong CalculateHash()
        {
            if (string.IsNullOrEmpty(_value))
            {
                return(0);
            }

            var buffer  = Encoding.UTF8.GetBytes(_value);
            var sBuffer = Array.ConvertAll(buffer, b => b != 0x80 ? (byte)Math.Abs((sbyte)b) : (byte)0x80);

            return(FNV1A64HashAlgorithm.HashReadOnlySpan(sBuffer));
        }
Example #2
0
 public void TestFNV1a64_ByteSpan(byte[] test, ulong result)
 {
     Assert.AreEqual(FNV1A64HashAlgorithm.HashReadOnlySpan(test), result);
 }
Example #3
0
 public void TestFNV1a64_CharSpan(string test, ulong result)
 {
     Assert.AreEqual(FNV1A64HashAlgorithm.HashReadOnlySpan(test.AsSpan()), result);
 }