Question

Well I am using Google Play service and I have a leaderboard. I am putting highscores from SharedPreferences. Is this safe to prevent changing highscores from external?

I am publishing highscores like this:

        SharedPreferences SP= mContext.getSharedPreferences(
            "com.example", Context.MODE_PRIVATE);

    String HighScore= (SP.getLong("highscore", 0));

And updating leaderboard on google play service:

    Games.Leaderboards.submitScore(getApiClient(),
            getString(R.string.leaderboard_example),
            HighScore);
Was it helpful?

Solution

You can use this approach, just add the encryption over the data. simplest is make the string to Base64. Or strong way would be AES or any other you want and than save that into the Shared prefrences.

Its a little overhead on App but security aspect is covered which fulfills the gap. If you want can add code of Baase64 & AES here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top