27 lines
642 B
C++
27 lines
642 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
#include <string_view>
|
|
#include <span>
|
|
|
|
namespace eterpack {
|
|
|
|
// Standard Metin2 / IEEE 802.3 CRC32 (polynomial 0xEDB88320)
|
|
uint32_t GetCRC32(const char* buf, size_t len);
|
|
uint32_t GetCaseCRC32(const char* buf, size_t len);
|
|
|
|
inline uint32_t GetCRC32(std::string_view str) {
|
|
return GetCRC32(str.data(), str.size());
|
|
}
|
|
|
|
inline uint32_t GetCaseCRC32(std::string_view str) {
|
|
return GetCaseCRC32(str.data(), str.size());
|
|
}
|
|
|
|
inline uint32_t GetCRC32(std::span<const uint8_t> data) {
|
|
return GetCRC32(reinterpret_cast<const char*>(data.data()), data.size());
|
|
}
|
|
|
|
} // namespace eterpack
|