2019-02-21 03:59:07 +01:00
|
|
|
/*
|
|
|
|
* IXHash.h
|
|
|
|
* Author: Benjamin Sergeant
|
|
|
|
* Copyright (c) 2018 Machine Zone. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-22 06:24:53 +01:00
|
|
|
#include "IXHash.h"
|
2019-02-21 03:59:07 +01:00
|
|
|
|
|
|
|
namespace ix
|
|
|
|
{
|
2019-02-22 06:24:53 +01:00
|
|
|
uint64_t djb2Hash(const std::vector<uint8_t>& data)
|
2019-02-21 03:59:07 +01:00
|
|
|
{
|
|
|
|
uint64_t hashAddress = 5381;
|
|
|
|
|
2019-02-22 06:24:53 +01:00
|
|
|
for (auto&& c : data)
|
2019-02-21 03:59:07 +01:00
|
|
|
{
|
|
|
|
hashAddress = ((hashAddress << 5) + hashAddress) + c;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hashAddress;
|
|
|
|
}
|
|
|
|
}
|