# Is this engine bugs? CryptoPP

**URL:** <https://forums.unrealengine.com/t/is-this-engine-bugs-cryptopp/74445>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [September 24, 2016, 2:22pm UTC](https://forums.unrealengine.com/t/is-this-engine-bugs-cryptopp/74445 "2016-09-24T14:22:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Syntopia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Syntopia](https://forums.unrealengine.com/u/Syntopia)\
**Post date:** [September 24, 2016, 2:22pm UTC](https://forums.unrealengine.com/t/is-this-engine-bugs-cryptopp/74445/1 "2016-09-24T14:22:58Z")

</div>

Hello,

I need sha256 and some other cryptographic algorithms. I know that from version 4.11 to the engine include support Crypt ++. However, I was not at hand engine build from source, and I would like to always have the latest version of Crypt ++. I added to the engine library and headers as the ThirdParty being guided this article:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

After preparation (create Third Person from template, create cryptlib.lib,and add lib as ThirdParty),

![10ab1019cd7f5c5205a38ca83d5c2e79fd201eeb.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)  
 ![17df867c1fb3cecb6994adabc85603b50897a7cc.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

```auto

//.build.cs

using UnrealBuildTool;
using System.IO;
using System; // Console.WriteLine("");

public class MyProject : ModuleRules
{

    private string ModulePath
    {
        get { return ModuleDirectory; }
    }

    private string ThirdPartyPath
    {
        get { return Path.GetFullPath( Path.Combine( ModulePath, "../../ThirdParty/" ) ); }
    }
	
    public MyProject(TargetInfo Target)
    {
        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });

        string LibrariesPath = Path.Combine(ThirdPartyPath, "CryptoPP", "Libraries");
	string IncludesPath = Path.Combine(ThirdPartyPath, "CryptoPP", "Includes");

        Console.WriteLine("... LibrariesPath -> " + LibrariesPath);
        Console.WriteLine("... IncludesPath -> " + IncludesPath);

        PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "cryptlib.lib"));
        PublicIncludePaths.Add(IncludesPath);

    }   
}

```

I import #include “cryptlib.h” in MyProjectCharacter.cpp to check availability and get the following error:

```auto

1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(588): warning C4266: 'void FOutputDevice::Serialize(const TCHAR *,ELogVerbosity::Type,const FName &,const double)': no override available for virtual member function from base 'FOutputDevice'; function is hidden
1> e:\program files\epic games\4.13\engine\source\runtime\core\public\Misc/OutputDevice.h(250): note: see declaration of 'FOutputDevice::Serialize'
1> E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\Guid.h(7): note: see declaration of 'FOutputDevice'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(642): error C2143: syntax error: missing ';' before '<'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(642): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(642): error C2238: unexpected token(s) preceding ';'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(645): error C2143: syntax error: missing ';' before '<'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(645): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(645): error C2238: unexpected token(s) preceding ';'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\CoreUObject\Public\UObject\CoreNet.h(260): warning C4242: 'initializing': conversion from 'int32' to 'uint16', possible loss of data
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\CoreUObject\Public\Serialization\ArchiveUObject.h(1658): error C2143: syntax error: missing ';' before '<'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\CoreUObject\Public\Serialization\ArchiveUObject.h(1658): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\CoreUObject\Public\Serialization\ArchiveUObject.h(1658): error C2238: unexpected token(s) preceding ';'

```

This time, **I copied all headers of crypt++**.

I started to search for the reason, I thought that the library is not available, wrong way or I did something wrong.

Created for test a library with simple mathematical operation (addition and subtraction) as written here:

Walkthrough: Creating and Using a Static Library (C++)

> **[Walkthrough: Create and use a static library (C++)](https://docs.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-static-library-cpp?redirectedfrom=MSDN&view=msvc-170)**
>
> Use C++ to create a static library (.lib) in Visual Studio.

Added to the project in the same way, it worked! **no errors, .lib 100% loaded correctly!**

Now back to the Crypto ++, I decided to **add only the headers needed to compile #include "cryptlib.h"**

![17df867c1fb3cecb6994adabc85603b50897a7cc.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

Compiled without errors. Next I add headers to #include “sha.h”  
Added this headers:

![8e879fdf5652ade257bd29b8cd5fe50ebc9f1299.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

Everything is compiled. Now I want to get the hash sha256, for this I add another couple of necessary headers:

![6fa748ced39f462e12bed163cddbfdeb53ac4ce2.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

Everything is good, I create function and assign a button, include headers:

```auto

#include "sha.h"
#include "filters.h"
#include "hex.h"

void AMyProjectCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
        // crypto test
	PlayerInputComponent->BindAction("T", IE_Pressed, this, &AMyProjectCharacter::CryptoTest);
}

void AMyProjectCharacter::CryptoTest()
{
	CryptoPP::SHA256 hash;
	std::string message = "baron";
	std::string digest;

	CryptoPP::StringSource s(message, true, new CryptoPP::HashFilter(hash, new CryptoPP::HexEncoder(new CryptoPP::StringSink(digest))));

	FString HappyHash(digest.c_str());

	GLog->Log(HappyHash);;
}

```

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Now I get to receive a hash clicking T-key in the game, **it works!**

 ![11.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/9/1/91a6238766142ff9da7cd476d9b50b336217bc73.jpeg)

**But now whan I press Clear/ReBuild MyProject and I again can not compile and give an error the same as if I added all the headers Crypt ++ at once:**

```auto

1>------ Rebuild All started: Project: MyProject, Configuration: Development_Editor x64 ------
1> Cleaning MyProjectEditor Binaries...
1> Creating makefile for MyProjectEditor (no existing makefile)
1> Performing full C++ include scan (no include cache file)
1> Parsing headers for MyProjectEditor
1> Running UnrealHeaderTool "C:\Users\Vadim\Documents\Unreal Projects\MyProject\MyProject.uproject" "C:\Users\Vadim\Documents\Unreal Projects\MyProject\Intermediate\Build\Win64\MyProjectEditor\Development\MyProjectEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
1> Reflection code generated for MyProjectEditor in 3,3700004 seconds
1> Performing 8 actions (2 in parallel)
1> [2/8] Resource PCLaunch.rc
1> PCH.MyProject.h.cpp
1> [3/8] Resource ModuleVersionResource.rc.inl
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(588): warning C4266: 'void FOutputDevice::Serialize(const TCHAR *,ELogVerbosity::Type,const FName &,const double)': no override available for virtual member function from base 'FOutputDevice'; function is hidden
1> e:\program files\epic games\4.13\engine\source\runtime\core\public\Misc/OutputDevice.h(250): note: see declaration of 'FOutputDevice::Serialize'
1> E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\Guid.h(7): note: see declaration of 'FOutputDevice'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(642): error C2143: syntax error: missing ';' before '<'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(642): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(642): error C2238: unexpected token(s) preceding ';'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(645): error C2143: syntax error: missing ';' before '<'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(645): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\Core\Public\Misc\AutomationTest.h(645): error C2238: unexpected token(s) preceding ';'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\CoreUObject\Public\UObject\CoreNet.h(260): warning C4242: 'initializing': conversion from 'int32' to 'uint16', possible loss of data
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\CoreUObject\Public\Serialization\ArchiveUObject.h(1658): error C2143: syntax error: missing ';' before '<'
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\CoreUObject\Public\Serialization\ArchiveUObject.h(1658): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>E:\Program Files\Epic Games\4.13\Engine\Source\Runtime\CoreUObject\Public\Serialization\ArchiveUObject.h(1658): error C2238: unexpected token(s) preceding ';'
1>ERROR : UBT error : Failed to produce item: C:\Users\Vadim\Documents\Unreal Projects\MyProject\Binaries\Win64\UE4Editor-MyProject.dll
1> Total build time: 20,60 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(46,5): error MSB3073: The command ""E:\Program Files\Epic Games\4.13\Engine\Build\BatchFiles\Rebuild.bat" MyProjectEditor Win64 Development "C:\Users\Vadim\Documents\Unreal Projects\MyProject\MyProject.uproject" -waitmutex" exited with code -1.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

```

I think that this is probably an engine bug, why do I get compile only than I do it step by step, adding headers one by one?

Engine 4.13

There is also a question on ansvers, without solution, the same mistake with the source built crypt ++ =\

[https://answers.unrealengine.com/questions/404387/how-to-include-the-new-cryptopp-lib-in-411.html](https://answers.unrealengine.com/questions/404387/how-to-include-the-new-cryptopp-lib-in-411.html)

If you want I can send project. Sorry for my English 🙂

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [September 24, 2016, 5:16pm UTC](https://forums.unrealengine.com/t/is-this-engine-bugs-cryptopp/74445/2 "2016-09-24T17:16:04Z")

</div>

Given that the engine already builds with CryptoPP, I think your best bet would be to check out the full engine source, then fold in the newer CryptoPP source as a replacement for what’s in there now (basically, merge-new-version,) and then fix whatever API breakage may have happened.  
Once you’ve done that, you can send a pull request to Epic, too, for updating to the latest version.

---

<div class="post-metadata">

**Author:** ![Syntopia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Syntopia](https://forums.unrealengine.com/u/Syntopia)\
**Post date:** [September 25, 2016, 11:28am UTC](https://forums.unrealengine.com/t/is-this-engine-bugs-cryptopp/74445/3 "2016-09-25T11:28:43Z")

</div>

I don’t know what this error means, even close and how to solve it.

Fortunately, this is not the only one cryptographic library. I compile the latest version of OpenSSL to .lib and add as the ThirdParty, it worked immediately and without error.

Here’s how to get the hash for example:

```auto

// SHA256
#include <iomanip>
#include <sstream>
#include <string>
#include <openssl/sha.h>

...

FString AMyProjectCharacter::SHA256(const FString UEStr)
{
	std::string str(TCHAR_TO_UTF8(*UEStr));

	unsigned char hash[SHA256_DIGEST_LENGTH];
	SHA256_CTX sha256;
	SHA256_Init(&sha256);
	SHA256_Update(&sha256, str.c_str(), str.size());
	SHA256_Final(hash, &sha256);
	std::stringstream ss;

	for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
	{
		ss << std::hex << std::setw(2) << std::setfill('0') << (int)hash*;
	}

	return ss.str().c_str();
}

void AMyProjectCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
	...

	// crypto test
	PlayerInputComponent->BindAction("T", IE_Pressed, this, &AMyProjectCharacter::CryptoTest);
}

void AMyProjectCharacter::CryptoTest()
{
	GLog->Log(SHA256("baron")); // output 99c2bb3e7c93dd54a206c77388ee09708e39db1a6f544ff6887612495bce3920
}

```

---

<div class="post-metadata">

**Author:** ![Syedhs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Syedhs](https://forums.unrealengine.com/u/Syedhs)\
**Post date:** [September 25, 2016, 11:34pm UTC](https://forums.unrealengine.com/t/is-this-engine-bugs-cryptopp/74445/4 "2016-09-25T23:34:08Z")

</div>

Just make sure source code are not there within the ‘Source’ folders even though they are not added to Project File (vcproj/sln). UBT behavior is to compile every source code (CPP/H) even though they are not added. This maybe is your case.

---

<div class="post-metadata">

**Author:** ![indikman](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@indikman](https://forums.unrealengine.com/u/indikman)\
**Post date:** [December 11, 2016, 11:41am UTC](https://forums.unrealengine.com/t/is-this-engine-bugs-cryptopp/74445/5 "2016-12-11T11:41:48Z")

</div>

Hi Syntopia,

Really appreciate if you could send a step by step process on compiling the OpenSSL and using it in unreal engine. I’m a newbie to Unreal and C++

---

<div class="post-metadata">

**Author:** ![indikman](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@indikman](https://forums.unrealengine.com/u/indikman)\
**Post date:** [December 11, 2016, 1:52pm UTC](https://forums.unrealengine.com/t/is-this-engine-bugs-cryptopp/74445/6 "2016-12-11T13:52:03Z")

</div>

Hi, Can you provide a good proceedure of compiling OpenSSL and integrating it with unreal?
