Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
MemoryHasher.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Misc/AssertionMacros.h"
7#include "HAL/UnrealMemory.h"
8#include "Math/NumericLimits.h"
9#include "Containers/UnrealString.h"
10#include "UObject/NameTypes.h"
11#include "Logging/LogMacros.h"
12#include "CoreGlobals.h"
13#include "Serialization/MemoryArchive.h"
14#include "Misc/SecureHash.h"
15#include "Hash/Blake3.h"
16
17/**
18 * Archive for hashing arbitrary data
19 */
20template <typename HashBuilder, typename HashDigest>
22{
23public:
26 {
27 this->SetIsSaving(true);
28 this->SetIsPersistent(false);
29 }
30
31 virtual void Serialize(void* Data, int64 Num) override
32 {
33 BuilderState.Update(reinterpret_cast<uint8*>(Data), Num);
34 }
35
36 HashDigest Finalize()
37 {
38 return BuilderState.Finalize();
39 }
40
41 /**
42 * Returns the name of the Archive. Useful for getting the name of the package a struct or object
43 * is in when a loading error occurs.
44 *
45 * This is overridden for the specific Archive Types
46 **/
47 virtual FString GetArchiveName() const override { return TEXT("TMemoryHasherTemplate"); }
48
49 int64 TotalSize() override
50 {
51 return 0;
52 }
53
54protected:
55
56 /** Context data needed to build the hash */
57 HashBuilder BuilderState;
58};
59
60using FMemoryHasherSHA1 = TMemoryHasher<FSHA1, FSHAHash>;
61using FMemoryHasherBlake3 = TMemoryHasher<FBlake3, FBlake3Hash>;
#define TEXT(x)
Definition Platform.h:1108
HashBuilder BuilderState
virtual FString GetArchiveName() const override
virtual void Serialize(void *Data, int64 Num) override
int64 TotalSize() override
HashDigest Finalize()