Get hash code for a byte array : Binary Bit « Data Types « C# / C Sharp






Get hash code for a byte array

  
//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;
    }
    }
}

   
    
  








Related examples in the same category

1.Using the Bitwise Complement Operators with Various Data TypesUsing the Bitwise Complement Operators with Various Data Types
2.Obtaining the Most Significant or Least Significant Bits of a NumberObtaining the Most Significant or Least Significant Bits of a Number
3.Binary Data TestBinary Data Test
4.Binary Network Byte OrderBinary Network Byte Order
5.Int binary
6.Clone a byte array
7.Count the number of bit
8.Bit Helper
9.Bit shifting for int and long value
10.Returns how many bits are necessary to hold a certain number