SHA256 Hashing for AuthToken Complete
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Game/ShooterGameMode.h"
|
||||
|
||||
#include "GenericPlatform/GenericPlatformMisc.h"
|
||||
#include "Containers/UnrealString.h"
|
||||
#include "GameLiftClpTypes.h"
|
||||
#include "GameLift/GameLiftClp.h"
|
||||
#include "openssl/sha.h"
|
||||
|
||||
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogShooterGameMode);
|
||||
@@ -45,8 +48,34 @@ void AShooterGameMode::InitGame(const FString& MapName, const FString& Options,
|
||||
|
||||
FString AShooterGameMode::GetSHA256Hash(const FString& InString)
|
||||
{
|
||||
if (InString.IsEmpty()) return TEXT("da39a3ee5e6b4b0d3255bfef95601890afd80709");
|
||||
|
||||
// if (InString.IsEmpty()) return TEXT("da39a3ee5e6b4b0d3255bfef95601890afd80709");
|
||||
|
||||
if (InString.IsEmpty())
|
||||
return TEXT("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
|
||||
|
||||
FSHA256Signature Hash;
|
||||
|
||||
// Use OpenSSL to compute the SHA-256 hash
|
||||
|
||||
FTCHARToUTF8 Utf8(InString);
|
||||
const uint8* Bytes = reinterpret_cast<const uint8*>(Utf8.Get());
|
||||
uint32 Length = Utf8.Length() * sizeof(UTF8CHAR);
|
||||
|
||||
|
||||
SHA256_CTX Sha256Context;
|
||||
SHA256_Init(&Sha256Context);
|
||||
SHA256_Update(&Sha256Context, Bytes,Length);
|
||||
SHA256_Final(Hash.Signature, &Sha256Context);
|
||||
|
||||
return Hash.ToString();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
FSHA1 Sha;
|
||||
FTCHARToUTF8 Utf8(InString);
|
||||
Sha.Update((uint8*)Utf8.Get(), Utf8.Length() * sizeof(UTF8CHAR));
|
||||
@@ -57,7 +86,7 @@ FString AShooterGameMode::GetSHA256Hash(const FString& InString)
|
||||
// 40-char hex (SHA1 = 160 bits)
|
||||
return FString::Printf(TEXT("%08X%08X%08X%08X%08X"),
|
||||
Hash[0], Hash[1], Hash[2], Hash[3], Hash[4]);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
void AShooterGameMode::InitGameLift()
|
||||
|
||||
Reference in New Issue
Block a user