Getting Sha256 signature, my code crashing unreal engine

Im trying to get a sha256 signature for login function.

The string text i get from Widget_Gui input box… for username.
Then in my c++ code i try the following line of code to get a Sha256 signature

FSHA256Signature hashedUserName;
bool hasHashedUserName = FGenericPlatformMisc::GetSHA256Signature(*FString(User_Name), User_Name.Len(), hashedUserName);
UE_LOG(LogTemp, Log, TEXT("hashed user_name: "), *FString(hashedUserName.ToString()));

But this is crashing the unreal engine… im using the LE Extended Standard Library

You are not crashing, you are getting an assert. This is an extremely important distinction.

Seems like the function you’re trying to use was never implemented. You’ll have to find some other way to get a SHA256… maybe using the CryptoPP or OpenSSL libraries that come with unreal? Or you could use a different hash.

1 Like

Got it working… prehaps its not best solution but its working for me.

I using the sha256.h and sha256.cpp file from zedwood function. found here C++ sha256 function :: zedwood.com

Jah need to insert the #define _CRT_SECURE_NO_WARNINGS in the sha256.cpp

Because the function expects std.string and not fstring … jah need to convert them like this FString hash_user_name = *FString(sha256(TCHAR_TO_UTF8(*User_Name)).c_str());

Then jah can get the code working and jah got a nice sha256 hash signature.

1 Like