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.
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...