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.
1
#include <
sourcepp/crypto/CRC32.h
>
2
3
#include <BufferStream.h>
4
#include <tomcrypt.h>
5
6
#include <
sourcepp/crypto/Globals.h
>
7
8
using namespace
sourcepp
;
9
10
uint32_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
}
CRC32.h
Globals.h
sourcepp::crypto::LTM_MATH
const bool LTM_MATH
Definition
Globals.cpp:7
sourcepp::crypto::computeCRC32
uint32_t computeCRC32(std::span< const std::byte > buffer)
Definition
CRC32.cpp:10
sourcepp
Definition
LZMA.h:11
src
sourcepp
crypto
CRC32.cpp
Generated on
for SourcePP by
1.16.1