This page describes the secure variable feature of Hercules.
Before using the secure variable feature, you first have to setup the Hive SDK beforehand.

A secure variable has the following characteristics:

  • It is a encrypted value in memory so that it cannot be retrieved by external tools.
  • Even if the encrypted value is tampered with, it will be verified when it is read.
  • The supported languages include C/C++ and C# (Unity).


How to Use Secure Variable

C# (Unity)

  • Basically, the data types available in C# can be used as a Generic class.
  • There are secure data types that match each data type as follows.
  • Since all basic types are cast to 8-byte types, it is recommended to use 8-byte types, such as using long instead of int and double instead of float.
Basic Type Secured Type Basic Type Secured Type
bool HerculesVar<bool> int HerculesVar<int>
char HerculesVar<char> uint HerculesVar<uint>
sbyte HerculesVar<sbyte> long HerculesVar<long>
byte HerculesVar<byte> ulong HerculesVar<ulong>
short HerculesVar<short> float HerculesVar<float>
ushort HerculesVar<ushort> double HerculesVar<double>
string HerculesString
C# Example

iOS, Android

  • In case of C, whenever you save or read the value of a variable, you must directly call the API, so it is recommended to use C++. C++ has a template class defined.
  • If possible, it is recommended to use the secure variable as a global variable or to use it after placing it in a place where allocation and deallocation are not performed too frequently.
  • Do not put #include statements inside an exteren "C" block.
  • It should be used after the Hive SDK is initialized.

C Example

Reference (C++)

  • Use it when the secure variable is initialized with a value. (the status that an object is allocated)
  • Use it as assigning the final result, which is generated after all the necessary calculations are completed.
  • Refer to the example below. (C++ has operator overloading.)
  • Recommended:
  • Not Recommended (Frequent Access)