Comparing Checksums

Posted by Sean Feldman on ASP.net Weblogs See other posts from ASP.net Weblogs or by Sean Feldman
Published on Sun, 30 May 2010 23:24:00 GMT Indexed on 2010/05/30 23:34 UTC
Read the original article Hit count: 375

Filed under:

This is something trivial, yet got me to think for a little. I had two checksums, one received from a client invoking a service, another one calculated once data sent into service is received. Checksums are plain arrays of bytes. I wanted to have comparison to be expressed as simple as possible. Quick google search brought me to a post that dealt with the same issue. But linq expression was too chatty and I think the solution was a bit muddy.

So I looked a bit more into linq options presented in the post, and this is what ended up using:

var matching = original_checksum.SequenceEqual(new_checksum);

Sometimes things are so simple, we tend to overcomplicate them.

© ASP.net Weblogs or respective owner

Related posts about c#