summaryrefslogtreecommitdiff
path: root/src/mongo/crypto/sha_block.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/crypto/sha_block.h')
-rw-r--r--src/mongo/crypto/sha_block.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/crypto/sha_block.h b/src/mongo/crypto/sha_block.h
index 443ef36ebf4..da61684976e 100644
--- a/src/mongo/crypto/sha_block.h
+++ b/src/mongo/crypto/sha_block.h
@@ -31,6 +31,7 @@
#include <array>
#include <cstddef>
#include <string>
+#include <third_party/murmurhash3/MurmurHash3.h>
#include <vector>
#include "mongo/base/data_range.h"
@@ -192,6 +193,19 @@ public:
return !(*this == other);
}
+ /**
+ * Custom hasher so SHABlocks can be used in unordered data structures.
+ *
+ * ex: std::unordered_set<SHABlock, SHABlock::Hash> shaSet;
+ */
+ struct Hash {
+ std::size_t operator()(const SHABlock& shaBlock) const {
+ uint32_t hash;
+ MurmurHash3_x86_32(shaBlock.data(), SHABlock::kHashLength, 0, &hash);
+ return hash;
+ }
+ };
+
private:
// The backing array of bytes for the sha block
HashType _hash;