brandondahler / Data.HashFunction

C# library to create a common interface to non-cryptographic hash functions.
MIT License
255 stars 42 forks source link

CRC Hash Error #41

Closed mahdiit closed 5 years ago

mahdiit commented 6 years ago

i try using CRC hash but i get this error:

"ICRC does not contain a definition for Value" and no extension method 'Value' accepting a first argument of type 'ICRC' could be found (are you missing a using directive or an assembly reference?)

My Code is:

var c = CRCFactory.Instance.Create(new CRCConfig()
            {
                HashSizeInBits = 32,
            });
            Console.WriteLine("Enter:");
            var result = c.ComputeHash(Encoding.UTF8.GetBytes(Console.ReadLine()));
            var dt = result.AsHexString();
            Console.WriteLine(dt);
            Console.ReadKey();
brandondahler commented 5 years ago

This is just a year late, but you probably intend:

            var c = CRCFactory.Instance.Create(CRCConfig.CRC32);   // <<===
            Console.WriteLine("Enter:");
            var result = c.ComputeHash(Encoding.UTF8.GetBytes(Console.ReadLine()));
            var dt = result.AsHexString();
            Console.WriteLine(dt);
            Console.ReadKey();

That doesn't explain your error message, but does fix the fact that it was returning 00000000 every time.

Closing because I assume you have probably moved on by now.