Open Dagdelo opened 6 years ago
Corrected code:
ITHARE_OBF_NOINLINE OBFI6(int) fibonacci(OBFI6(int) num)
{
static std::map<OBFI6(int), OBFI6(int)> cache{{0, 0}, {1, 1}};
auto found = cache.find(num);
if (found != std::end(cache)) {
// For debugging purposes, to check that the cache is doing something
std::cout << OBFS5L("Found in cache: ").value() << num << OBFS5L(" -> ").value() << found->second << '\n';//sometimes we may need to add ".value()" to obfuscated variables/constants
return found->second;
}
OBFI6(int) result = fibonacci(num - 1) + fibonacci(num - 2);
cache[num] = result;
return result;
}
int main()
{
int num;//cannot obfuscate parameters passed by reference to standard library (in this case - to cin >>); can obfuscate after reading from cin if necessary
do{
std::cout << "i: ";
std::cin >> num;
}while(num < 3);
OBFI6(int) res = fibonacci(num);
std::cout << num << OBFS5L("th fibonacci number: ").value() << res << std::endl;
}
A few minor notes: for it to compile, you have to tell your compiler to use C++17, and to add #include
Ok. thx.
Hi! I'm trying to apply the same obfuscation in the obftest.cpp in this simple Fibonacci Recursive with Memoisation.
I stoped here... Rly don't know how to finish the code for trying compiling.