summaryrefslogtreecommitdiff
path: root/Source/Core/Common/CRC32.cpp
blob: c09a578196e07c2ee36f14ba7ca5bccd53bbfb90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Copyright 2021 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "Common/CRC32.h"

#include <zlib.h>

namespace Common
{
u32 ComputeCRC32(std::string_view data)
{
  const Bytef* buf = reinterpret_cast<const Bytef*>(data.data());
  uInt len = static_cast<uInt>(data.size());
  // Use zlibs crc32 implementation to compute the hash
  u32 hash = crc32(0L, Z_NULL, 0);
  hash = crc32(hash, buf, len);
  return hash;
}
}  // namespace Common