Changeset View
Changeset View
Standalone View
Standalone View
src/hash.cpp
// Copyright (c) 2013-2016 The Bitcoin Core developers | // Copyright (c) 2013-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <hash.h> | #include <hash.h> | ||||
#include <crypto/hmac_sha512.h> | #include <crypto/hmac_sha512.h> | ||||
inline uint32_t ROTL32(uint32_t x, int8_t r) { | inline uint32_t ROTL32(uint32_t x, int8_t r) { | ||||
return (x << r) | (x >> (32 - r)); | return (x << r) | (x >> (32 - r)); | ||||
} | } | ||||
uint32_t MurmurHash3(uint32_t nHashSeed, | uint32_t MurmurHash3(uint32_t nHashSeed, Span<const uint8_t> vDataToHash) { | ||||
const std::vector<uint8_t> &vDataToHash) { | |||||
// The following is MurmurHash3 (x86_32), see | // The following is MurmurHash3 (x86_32), see | ||||
// http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp | // http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp | ||||
uint32_t h1 = nHashSeed; | uint32_t h1 = nHashSeed; | ||||
const uint32_t c1 = 0xcc9e2d51; | const uint32_t c1 = 0xcc9e2d51; | ||||
const uint32_t c2 = 0x1b873593; | const uint32_t c2 = 0x1b873593; | ||||
const int nblocks = vDataToHash.size() / 4; | const int nblocks = vDataToHash.size() / 4; | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |