2018-11-04 20:33:37 +00:00
|
|
|
|
namespace Roadie.Library.Extensions
|
2018-11-03 21:21:36 +00:00
|
|
|
|
{
|
|
|
|
|
public static class ByteExt
|
|
|
|
|
{
|
2019-07-10 04:08:27 +00:00
|
|
|
|
//public static int ComputeHash(this byte[] data)
|
|
|
|
|
//{
|
|
|
|
|
// if (data == null || data.Length == 0) return 0;
|
|
|
|
|
// unchecked
|
|
|
|
|
// {
|
|
|
|
|
// const int p = 16777619;
|
|
|
|
|
// var hash = (int)2166136261;
|
2018-11-03 21:21:36 +00:00
|
|
|
|
|
2019-07-10 04:08:27 +00:00
|
|
|
|
// for (var 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;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2018-11-03 21:21:36 +00:00
|
|
|
|
}
|
2018-11-04 20:33:37 +00:00
|
|
|
|
}
|