4#include "../Common/CompilerMacrosExport.h"
5#include "../Common/CompilerMacrosLifetimeBound.h"
6#ifndef SC_EXPORT_LIBRARY_HASHING
7#define SC_EXPORT_LIBRARY_HASHING 0
9#define SC_HASHING_EXPORT SC_COMPILER_LIBRARY_EXPORT(SC_EXPORT_LIBRARY_HASHING)
11#include "../Common/PlatformMacrosType.h"
12#include "../Common/Span.h"
36 static constexpr auto MD5_DIGEST_LENGTH = 16;
37 static constexpr auto SHA1_DIGEST_LENGTH = 20;
38 static constexpr auto SHA256_DIGEST_LENGTH = 32;
40 uint8_t hash[32] = {0};
43 Span<const uint8_t> toBytesSpan()
const SC_LANGUAGE_LIFETIME_BOUND {
return {hash, size}; }
66 [[nodiscard]]
bool add(Span<const uint8_t> data);
80 alignas(uint64_t)
char buffer[104];
81#elif SC_PLATFORM_WINDOWS
82 alignas(uint64_t)
char buffer[16];
85#elif SC_PLATFORM_LINUX
Compute MD5, SHA1 or SHA256 hash for stream of data.
Definition Hashing.h:33
Hashing()
Initializes an Hashing struct.
bool add(Span< const uint8_t > data)
Add data to be hashed.
~Hashing()
Destroys an Hashing struct.
bool setType(Type newType)
Set type of hash to compute.
Type
Definition Hashing.h:46
@ TypeMD5
Compute MD5 hash for the incoming stream of bytes.
Definition Hashing.h:47
@ TypeSHA1
Compute SHA1 hash for the incoming stream of bytes.
Definition Hashing.h:48
@ TypeSHA256
Compute SHA256 hash for the incoming stream of bytes.
Definition Hashing.h:49
bool getHash(Result &res)
Finalize hash computation that has been pushed through Hashing::add.