CSharp examples for System:Byte Array
Computes the hash of the given bytes array.
/*/*from ww w . j a va 2s . c om*/ * Copyright (c) 2011-2014, Longxiang He <helongxiang@smeshlink.com>, * SmeshLink Technology Co. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY. * * This file is part of the CoAP.NET, a CoAP framework in C#. * Please see README for more information. */ using System.Text; using System; public class Main{ /// <summary> /// Computes the hash of the given bytes array. /// </summary> public static Int32 ComputeHash(params Byte[] data) { unchecked { const Int32 p = 16777619; Int32 hash = (Int32)2166136261; for (Int32 i = 0; i < data.Length; i++) hash = (hash ^ data[i]) * p; hash += hash << 13; hash ^= hash >> 7; hash += hash << 3; hash ^= hash >> 17; hash += hash << 5; return hash; } } }