Get hash code for a byte array

image_pdfimage_print
   
 
//http://www.bouncycastle.org/
//MIT X11 License


using System;
using System.Text;

namespace Org.BouncyCastle.Utilities
{

    /// <summary> General array utilities.</summary>
    public sealed class Arrays
    {
    public static int GetHashCode(byte[] data)
    {
      if (data == null)
      {
        return 0;
      }

      int i = data.Length;
      int hc = i + 1;

      while (--i >= 0)
      {
        hc *= 257;
        hc ^= data[i];
      }

      return hc;
    }
    }
}

   
     


This entry was posted in Data Types. Bookmark the permalink.