SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
SHA256.cpp
Go to the documentation of this file.
1
#include <
sourcepp/crypto/SHA256.h
>
2
3
#include <tomcrypt.h>
4
5
#include <
sourcepp/crypto/Globals.h
>
6
7
using namespace
sourcepp
;
8
9
std::array<std::byte, 32>
crypto::computeSHA256
(std::span<const std::byte> buffer) {
10
if
(!
LTM_MATH
||
SHA256_INDEX
< 0 || buffer.empty()) {
11
return
{};
12
}
13
14
hash_state sha256;
15
sha256_init(&sha256);
16
sha256_process(&sha256,
reinterpret_cast<
const
unsigned
char
*
>
(buffer.data()), buffer.size());
17
18
std::array<std::byte, 32>
final
{};
19
sha256_done(&sha256,
reinterpret_cast<
unsigned
char
*
>
(
final
.data()));
20
return
final
;
21
}
Globals.h
SHA256.h
sourcepp::crypto::LTM_MATH
const bool LTM_MATH
Definition
Globals.cpp:7
sourcepp::crypto::SHA256_INDEX
const int SHA256_INDEX
Definition
Globals.cpp:13
sourcepp::crypto::computeSHA256
std::array< std::byte, 32 > computeSHA256(std::span< const std::byte > buffer)
Definition
SHA256.cpp:9
sourcepp
Definition
LZMA.h:11
src
sourcepp
crypto
SHA256.cpp
Generated on
for SourcePP by
1.16.1