Encrypted sdkbox_config.json

Hi, Is there a way to hide information inside sdkbox_config.json ? i.e. is it possible to somehow encrypt sdkbox_config.json and let sdkbox to read encrypted config …

I know this was on the roadmap in the early days of sdkbox development but I don’t know if it was implemented. @yinjimmy can help us out.

i.e. currently just nobody care to hide account ids(like ad ids, google iap key )…

@AlexGreen before it was supported, but dont know for what reason they removed encrypted config feature.
Sdkbox is getting worse.

Actually i managed to encrypt some json data, and want to share the solution:
first of all, i’m work on mac, so if you work on win/lin, you should write some util,
similar to the one I provide. The idea of encryption is simple: just xor every byte, and IF encrypted data length == encryption key length, then nobody is managed to decrypt it without key. The simplest source of infinity key bytes is… pseudo random generator! The only downside in standard generator is the initial rnd seed, which is just one plain long int. So, i found a wonderful c++ template PRNG by Matthew Leadbetter (Licensed under the Apache License, http://www.mleadbetter.com/how-to-use-a-pseudorandom-number-generator-a-practical-guide/), whose rnd seed initiated by array of 16 64bit int’s.
Then i wrote some useful osx gui util, binXor, one of purposes to encrypt any drag’n’drop files and generate output as c++ header source files: https://drive.google.com/open?id=1kKsWgKTfd2hReeK-O7bk3vB24_H7j-jD
How to use it:
just run binXor, make sure checkbox “Encrypt data” is checked in settings->general, then drag’n’drop some files (f.e. template sdkbox_config.json i included).
then in your game:

#include "sdkbox_config.h"
#include "PRNG.h"
...
PRNG prng(sdkbox_config_seed_array);
char outBuff[sdkbox_config_len];
for(int i=0; i < sdkbox_config_len; ++i) {
    outBuff[i] = sdkbox_config_array[i] ^ prng.getRandomUnsignedChar();
}
std::string jsonStr(outBuff, sdkbox_config_len);
...
//first init some other sdkbox plugins, which require physical presence of sdkbox_config.json
//(but without IAP section in it!)
//f.e. sdkbox::PluginSdkboxPlay::init();
//and then:
sdkbox::IAP::init(jsonStr.c_str());

I’m already using this technique to cypher important data in my games. Actually, you can cypher any kind of binary data: sprites, sounds, levels, etc. I hope it will help.

is this still working with latest sdkbox version?
I thought it removed, o/w we can use our own logic (Thats no big deal)

Yes, it working right now in my app.

Thank you for the solution! This is really good. To use it in it`s full strength it would be good if sdkbox allows to initialize other services with const char* … like

sdkbox::PluginAdMob::init()
sdkbox::PluginSdkboxPlay::init()

Hi all,

we provide a new api for set sdkbox_config.json from v2.4.1.1 :

#include <sdkbox/Sdkbox.h>
sdkbox::setConfig(const std::string jsonConfig);

the jsonConfig MUST is the content of sdkbox_config.json:

{
  "ios": {
     "AdColony": {
         "appid": "123"
     }
  },
  "android": {
     "AdMob": {}
  }
}

so, developers can

  1. encrypt / decrypt data by yourself
  2. remote config without sdkbox.com

then call sdkbox::setConfig(const std::string jsonConfig) to update the config.

or use sdkbox encrypt solution without remote config:

  1. set xxtea key
#include <sdkbox/Sdkbox.h>
sdkbox::init("", "your_key");
  1. encrypt sdkbox_config.json, the sdkbox command version must >= v1.0.2.2, it has been released on staging server, plz update by sdkbox list --staging.

crypt file

$ sdkbox encrypt -i sdkbox_config.json -o sdkbox_config.json --key your_key

decrypt file

$ sdkbox decrypt -i sdkbox_config.json -o sdkbox_config.json --key your_key

one more thing, make sure call sdkbox::init() or sdkbox::setConfig() before any plugin::init();

Thanks for using SDKBox and any suggestion is welcome.

  • Jimmy

UPDATE:
https://github.com/fffaraz/awesome-cpp#cryptography there are some encrypt libs for you.

3 Likes

Thank you! it is exactly what neccessary. Cool!

When call to “sdkbox::init(”", “your_key”);" should be done ? Before/after/not important of SDKBox.init(this); which is in com.sdkbox.plugin.SDKBoxActivity.OnCreate() ?

it’s a c++ api, not java.

Sure. Is it possible to use this api in android libcocos2dx c++ application?

Someone can use admob sdkbox c++ api in his cocos2dx android application… Is it possible to use this encryption feature in Android cocos2d application similarly? Note that Android libcocos2dx app already initialize sdkbox in sdkbox activity… So would it be OK to call c++ api for initialization later?

It’s ok.

case 1:

sdkbox::init("", "your_key"); // the first argument must set ""
sdkbox::IAP::init();
sdkbox::PluginAdMob::init();

case 2:

sdkbox::setConfig("content of sdkbox_sdkbox.josn");
sdkbox::IAP::init();
sdkbox::PluginAdMob::init();

Add document http://docs.sdkbox.com/en/qa/crypt-sdkbox-config/ .
Hope you like it.

Thanks! tried case 2 - it is working OK.

Hi,

I’ve tried the SDKBox Encrypt Solution follow FAQ (http://docs.sdkbox.com/en/qa/crypt-sdkbox-config/)

Results:

  • iOS: OK
  • Android: (8.0 on Samsung Galaxy 7). NOT OK. The error messages are
    E/SDKBOX_CORE: Checking plugin status for unknown plugin: AdMob
    E/AdMob: AdMob: proxy is null
    E/Facebook: Failed to load config for Facebook
    E/Share: plugin share init native fail

P/S: I’m using AdMob, Facebook and Share and all of them are can not load.

Thanks for your help!

[Updated]
cocos2d-x version 3.17.1
sdkbox version 2.5.0.0

I tried admob, it works.

    std::string jsonConfig = R"(
{
    "ios": {
        "AdMob":{
            "appid": "ca-app-pub-1329374026572143~2708810518",
            "testdevice": "kGADSimulatorID",
            "test":false,
            "safearea":true,
            "ads":{
                "home":{
                    "id":"ca-app-pub-1329374026572143/3847466511",
                    "type":"banner",
                    "alignment":"bottom",
                    "width":320,
                    "height":50
                },
                "top_banner":{
                    "id":"ca-app-pub-1329374026572143/6690628914",
                    "type":"banner",
                    "alignment":"top"
                },
                "gameover":{
                    "id":"ca-app-pub-1329374026572143/4185543717",
                    "type":"interstitial"
                },
                "next_level":{
                    "id":"ca-app-pub-1329374026572143/9390403312",
                    "type":"interstitial"
                },
                "rewarded":{
                    "id":"ca-app-pub-1329374026572143/7991602916",
                    "type":"rewarded_video"
                },
                "rewarded2":{
                    "id":"ca-app-pub-3940256099942544/1712485313",
                    "type":"rewarded_video"
                }
            }
        }
    },
    "android": {
        "AdMob":{
            "appid": "ca-app-pub-1329374026572143~7139010117",
            "testdevice": "kGADSimulatorID",
            "test":false,
            "ads":{
                "home":{
                    "id":"ca-app-pub-1329374026572143/2685130917",
                    "type":"banner",
                    "alignment":"bottom",
                    "width":320,
                    "height":50
                },
                "top_banner": {
                    "id":"ca-app-pub-1329374026572143/3087700911",
                    "type":"banner",
                    "alignment":"top"
                },
                "gameover":{
                    "id":"ca-app-pub-1329374026572143/1092476511",
                    "type":"interstitial"
                },
                "next_level":{
                    "id":"ca-app-pub-1329374026572143/4564434111",
                    "type":"interstitial"
                },
                "rewarded":{
                    "id":"ca-app-pub-1329374026572143/8251968111",
                    "type":"rewarded_video"
                },
                "rewarded2":{
                    "id":"ca-app-pub-3940256099942544/5224354917",
                    "type":"rewarded_video"
                }
            }
        }
    }
}
    )";
    sdkbox::setConfig(jsonConfig);

    // setConfig before PluginXX::init();
    // 
    sdkbox::PluginAdMob::init();

Thanks,

1 Like

Thanks @yinjimmy. You are awesome.

I tried your solution. The results of both iOS and Android are successful.

But, I questioned about “Solution of SDKBox”, and still fail with this solution on Android. Can you try this?

Solution of SDKBox

1. encrypt sdkbox_config.json

# encrypt
sdkbox encrypt -i sdkbox_config.json -o sdkbox_config.json --key your_key

# decrypt
sdkbox decrypt -i sdkbox_config.json -o sdkbox_config.json --key your_key

2. set decrypt key

// AppDelegate.cpp
#include <sdkbox/Sdkbox.h>


sdkbox::init("", "your_key"); // the first argument must set "",
                              // if you don't need remote config
sdkbox::IAP::init();
sdkbox::PluginAdMob::init();

Anyway, thank you so much, I’m going to apply as your guide above.

I have this issue too

case 1 cannot work on Android