Daily Archives: Tuesday, March 22, 2011

Caching with a SHA1 hash (C# 4.0)

Posted by & filed under code.

Here is the cache code: #region don’t process the same address twice if (newEmail.EmailHash == 0) newEmail.EmailHash = newEmail.Email.GetSHA1Hash(); if (emailsToAdd.Contains(newEmail.EmailHash)) { return false; } emailsToAdd.Add(newEmail.EmailHash); #endregion For this implementation, I am returning the hash as a 32-bit integer because I am using it for caching, not security. It’s a little faster to use an […]