コード例 #1
0
        /// <summary>
        /// Computes the xxHash of the input string. xxHash is an extremely fast non-cryptographic Hash algorithm.
        /// </summary>
        /// <param name="value">The input string</param>
        /// <returns>xxHash</returns>
        public static string XxHash(this string value)
        {
            if (value.IsEmpty())
            {
                return(value);
            }

            return($"{XxHashUnsafe.ComputeHash(value):X}");
        }
コード例 #2
0
        public int GetFileHash()
        {
            if (_contentHash == null)
            {
                var css = GetContent();
                _contentHash = (int)XxHashUnsafe.ComputeHash(css);
            }

            return(_contentHash.Value);
        }
コード例 #3
0
        private static string SaltKey(Expression expression)
        {
            ConstantVisitor constantVisitor = new ConstantVisitor();

            constantVisitor.Visit(expression);
            var saltKey = constantVisitor.ValueBuilder.ToString();

            saltKey = $"{XxHashUnsafe.ComputeHash(saltKey):X}";
            return(saltKey);
        }
コード例 #4
0
        public void TestLoremIpsumXxHashReturnsCorrectValue()
        {
            var hash = XxHashUnsafe.ComputeHash(TestConstants.LoremIpsum);

            Assert.AreEqual((uint)4046722717, hash);
        }
コード例 #5
0
        public void TestFooBarXxHashReturnsCorrectValue()
        {
            var hash = XxHashUnsafe.ComputeHash(TestConstants.FooBar);

            Assert.AreEqual((uint)2348340516, hash);
        }
コード例 #6
0
        public void TestEmptyXxHashReturnsCorrectValue()
        {
            var hash = XxHashUnsafe.ComputeHash(TestConstants.Empty);

            Assert.AreEqual((uint)0x02cc5d05, hash);
        }