5#include "Containers/Array.h"
6#include "Containers/Map.h"
7#include "Containers/StringConv.h"
8#include "Containers/StringFwd.h"
9#include "Containers/StringView.h"
10#include "Containers/UnrealString.h"
12#include "HAL/PlatformCrt.h"
13#include "HAL/PreprocessorHelpers.h"
14#include "HAL/UnrealMemory.h"
15#include "Misc/AssertionMacros.h"
16#include "Misc/CString.h"
18#include "Serialization/Archive.h"
19#include "Serialization/BufferReader.h"
20#include "Serialization/MemoryLayout.h"
21#include "Stats/Stats.h"
22#include "Stats/Stats2.h"
23#include "String/BytesToHex.h"
24#include "String/HexToBytes.h"
25#include "Templates/UnrealTemplate.h"
27#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2
28#include "Async/AsyncWork.h"
41
42
70
71
72
73
74
75
76 void Update(
const uint8* input, uint64 inputLen);
79
80
81
82
83
84
88
89
90
91
94 return HashBytes((
unsigned char*)
TCHAR_TO_ANSI(String), FCString::Strlen(String));
98
99
100
101
112 for (int32 i = 0; i < 16; i++)
128 void Encode( uint8* output,
const uint32* input, int32 len );
129 void Decode( uint32* output,
const uint8* input, int32 len );
202
203
204
213
214
217
218
219
220
221
224#define HASHES_SHA_DIVIDER "+++"
249 inline void ToString(TCHAR* Dest,
bool bNullTerminate)
const
252 for (
int i = 0; i < Count; ++i)
255 Dest[i * 2] = NibbleToTChar(Val >> 4);
256 Dest[i * 2 + 1] = NibbleToTChar(Val & 15);
261 Dest[Count * 2] =
TEXT(
'\0');
267 check(Src.Len() == GetStringLen());
290 return *
reinterpret_cast<
const uint32*>(InKey
.Hash);
295 friend inline FStringBuilderBase& operator<<(FStringBuilderBase& Builder,
const FSHAHash& InHash) { UE::String::BytesToHex(InHash.Hash, Builder);
return Builder; }
296 friend inline FAnsiStringBuilderBase& operator<<(FAnsiStringBuilderBase& Builder,
const FSHAHash& InHash) { UE::String::BytesToHex(InHash.Hash, Builder);
return Builder; }
327 void Update(
const uint8 *data, uint64 len);
340 GetHash(reinterpret_cast<uint8*>(&Digest)
);
348
349
350
351
352
353
354 static void HashBuffer(
const void* Data, uint64 DataSize, uint8* OutHash);
357
358
359
360
361
362
371
372
373
374
375
376
377
378
379
380 static void HMACBuffer(
const void* Key, uint32 KeySize,
const void* Data, uint64 DataSize, uint8* OutHash);
383
384
385
386
387
388
389
393
394
395
396
397
398
399
400
401
402 static bool GetFileSHAHash(
const TCHAR* Pathname, uint8 Hash[20],
bool bIsFullPackageHash=
true);
417
418
443
444
445
446
447
448
449
450
451
455 bool bInShouldDeleteBuffer,
456 const TCHAR* InPathname,
457 bool bInIsUnfoundHashAnError)
467
468
472
473
480
481
493 RETURN_QUICK_DECLARE_CYCLE_STAT(FAsyncSHAVerify, STATGROUP_ThreadPoolAsyncTasks);
498
499
500
501
502
503
504
505
509
510
511
516
517
518
519
520
521
522
523
524
529 const TCHAR* SHASourcePathname,
530 bool bIsPersistent=
false,
531 bool bInIsUnfoundHashAnError=
false
548
549
550
551
552
#define DECLARE_INTRINSIC_TYPE_LAYOUT(T)
FGuid MD5HashToGuid(const FMD5Hash &Hash)
void appOnFailSHAVerification(const TCHAR *FailedPathname, bool bFailedDueToMissingHash)
#define TCHAR_TO_ANSI(str)
UE_NODISCARD FString BytesToHex(const uint8 *Bytes, int32 NumBytes)
void BytesToHex(const uint8 *Bytes, int32 NumBytes, FString &Out)
#define UE_ARRAY_COUNT(array)
virtual void Serialize(void *V, int64 Length)
bool bIsUnfoundHashAnError
FAsyncSHAVerify(void *InBuffer, uint64 InBufferSize, bool bInShouldDeleteBuffer, const TCHAR *InPathname, bool bInIsUnfoundHashAnError)
FORCEINLINE TStatId GetStatId() const
FBufferReaderBase(void *Data, int64 Size, bool bInFreeOnClose, bool bIsPersistent=false)
bool bIsUnfoundHashAnError
~FBufferReaderWithSHA() override
FBufferReaderWithSHA(void *Data, int64 Size, bool bInFreeOnClose, const TCHAR *SHASourcePathname, bool bIsPersistent=false, bool bInIsUnfoundHashAnError=false)
virtual FString GetArchiveName() const
!it would be cool if these were implemented as subclasses of
static FString HashBytes(const uint8 *input, uint64 inputLen)
static FString HashAnsiString(const TCHAR *String)
void Transform(uint32 *state, const uint8 *block)
void Final(uint8 *digest)
void Encode(uint8 *output, const uint32 *input, int32 len)
void Decode(uint32 *output, const uint8 *input, int32 len)
void Update(const uint8 *input, uint64 inputLen)
void GetHash(uint8 *puDest)
void Update(const uint8 *data, uint64 len)
static void HashBuffer(const void *Data, uint64 DataSize, uint8 *OutHash)
static TMap< FString, uint8 * > ScriptSHAHashMap
static TMap< FString, uint8 * > FullFileSHAHashMap
void UpdateWithString(const TCHAR *data, uint32 len)
static void HMACBuffer(const void *Key, uint32 KeySize, const void *Data, uint64 DataSize, uint8 *OutHash)
static FSHAHash HashBuffer(const void *Data, uint64 DataSize)
static bool GetFileSHAHash(const TCHAR *Pathname, uint8 Hash[20], bool bIsFullPackageHash=true)
static void InitializeFileHashesFromBuffer(uint8 *Buffer, uint64 BufferSize, bool bDuplicateKeyMemory=false)
void Transform(const uint8 *buffer, uint64 len)
friend uint32 GetTypeHash(const FSHAHash &InKey)
friend bool LoadFromCompactBinary(FCbFieldView Field, FSHAHash &OutHash)
friend void LexFromString(FSHAHash &Hash, const TCHAR *)
void FromString(const FStringView &Src)
void ToString(TCHAR *Dest, bool bNullTerminate) const
static constexpr int32 GetStringLen()
friend bool operator<(const FSHAHash &X, const FSHAHash &Y)
friend bool operator==(const FSHAHash &X, const FSHAHash &Y)
friend FString LexToString(const FSHAHash &)
friend bool operator!=(const FSHAHash &X, const FSHAHash &Y)
void AppendString(FString &Out) const
void IntrinsicToString(const FSHAHash &Object, const FTypeLayoutDesc &TypeDesc, const FPlatformTypeLayoutParameters &LayoutParams, FMemoryToStringContext &OutContext)
friend void LexFromString(FMD5Hash &Hash, const TCHAR *)
const uint8 * GetBytes() const
const int32 GetSize() const
static FMD5Hash HashFileFromArchive(FArchive *Ar, TArray< uint8 > *ScratchPad=nullptr)
friend FString LexToString(const FMD5Hash &)
friend bool operator!=(const FMD5Hash &LHS, const FMD5Hash &RHS)
friend bool operator==(const FMD5Hash &LHS, const FMD5Hash &RHS)
FCbWriter & WriteCompactBinary(FCbWriter &Writer) const
friend bool LoadFromCompactBinary(FCbFieldView Field, FMD5Hash &OutHash)
static FMD5Hash HashFile(const TCHAR *InFilename, TArray< uint8 > *Buffer=nullptr)
static void Free(void *Original)
static FORCEINLINE void * Memset(void *Dest, uint8 Char, SIZE_T Count)
static FORCEINLINE int32 Memcmp(const void *Buf1, const void *Buf2, SIZE_T Count)
static FORCEINLINE void * Memcpy(void *Dest, const void *Src, SIZE_T Count)