summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Hash.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common/Hash.cpp')
-rw-r--r--Source/Core/Common/Hash.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/Core/Common/Hash.cpp b/Source/Core/Common/Hash.cpp
index d0b05ec7b6..692745cb0a 100644
--- a/Source/Core/Common/Hash.cpp
+++ b/Source/Core/Common/Hash.cpp
@@ -5,6 +5,8 @@
#include <algorithm>
#include <cstring>
+#include <zlib.h>
+
#include "Common/BitUtils.h"
#include "Common/CPUDetect.h"
#include "Common/CommonFuncs.h"
@@ -529,4 +531,14 @@ void SetHash64Function()
ptrHashFunction = &GetMurmurHash3;
}
}
+
+u32 ComputeCRC32(std::string_view data)
+{
+ const Bytef* buf = reinterpret_cast<const Bytef*>(data.data());
+ uInt len = static_cast<uInt>(data.size());
+ // Use zlib's crc32 implementation to compute the hash
+ u32 hash = crc32(0L, Z_NULL, 0);
+ hash = crc32(hash, buf, len);
+ return hash;
+}
} // namespace Common