Book Image

Cocos2d-x Cookbook

By : Akihiro Matsuura
Book Image

Cocos2d-x Cookbook

By: Akihiro Matsuura

Overview of this book

Table of Contents (18 chapters)
Cocos2d-x Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using encrypted zip files


In a smartphone, the game frequently downloads a zip file from the server to update resources. These assets are generally the main targets for hackers. They can decode these assets to manipulate information in a game system. Hence, security for these assets is very important. In this case, zip is encrypted to protect against cheaters. In this recipe, you will learn how to unzip an encrypted zip file with a password.

Getting ready

Cocos2d-x has an unzip library. However, encryption/decryption is disabled in this library. That's why we have to enable the crypt option in unzip.cpp. This file's path is cocos2d/external/unzip/unzip.cpp. You will have to comment out line number 71 of unzip.cpp to enable the crypt option.

//#ifndef NOUNCRYPT
//        #define NOUNCRYPT
//#endif

When we tried to build in Cocos2d-x version 3.7, an error occurred in unzip.h in line 46, as shown in the following code:

#include "CCPlatformDefine.h"

You have to edit the following code to remove this...