SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
Adler32.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::computeAdler32(std::span<const std::byte> buffer) {
11 if (!LTM_MATH || buffer.empty()) {
12 return 0;
13 }
14
15 adler32_state adler32{};
16 // do NOT call init! must start zeroed, init changes this (necessary for GCF)
17 adler32_update(&adler32, reinterpret_cast<const unsigned char*>(buffer.data()), buffer.size());
18
19 uint32_t final;
20 adler32_finish(&adler32, &final, sizeof(final));
21 BufferStream::swap_endian(&final);
22 return final;
23}
const bool LTM_MATH
Definition Globals.cpp:7
uint32_t computeAdler32(std::span< const std::byte > buffer)
Definition Adler32.cpp:10