SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
CRC32.cpp
Go to the documentation of this file.
2
3#include <BufferStream.h>
4#include <tomcrypt.h>
5
7
8using namespace sourcepp;
9
10uint32_t crypto::computeCRC32(std::span<const std::byte> buffer) {
11 if (!LTM_MATH || buffer.empty()) {
12 return 0;
13 }
14
15 crc32_state crc32;
16 crc32_init(&crc32);
17 crc32_update(&crc32, reinterpret_cast<const unsigned char*>(buffer.data()), buffer.size());
18
19 uint32_t final;
20 crc32_finish(&crc32, &final, sizeof(final));
21 BufferStream::swap_endian(&final);
22 return final;
23}
const bool LTM_MATH
Definition Globals.cpp:7
uint32_t computeCRC32(std::span< const std::byte > buffer)
Definition CRC32.cpp:10