- Support all types of file encryption. For Cocos2d-X, except for .ttf;.mp3;.ogg, which requires Streaming mode (generally audio playback and font resolution memory usage, performance requirements), all other file types can be encrypted.
- Security, refuse to use the string fool to store the key, improve the difficulty of cracking (don’t ask me if this solution can be cracked, the Internet is not absolutely safe, to the hacker compiling the HOOK system API level, cracking is only a matter of time)
- By default, data is compressed with zlib, then encrypted with AES-CBC. Finally , the size of the APK or iPA package is basically the same as that of no encryption. If the compression is not performed first, the file data redundancy information is greatly reduced after encryption, and the size of file data does not decrease after compression. The final package will be very large than non-encryption, whether it is an APK or iPA is a zip algorithm compression format.
- High-performance decryption, AES-CBC decryption in memory is to reuse the original memory, and the decompression process will get the original data size from the signature, effectively avoiding frequent memory alloc/free or memory waste during decompression.
Use steps :
Download x-studio365 10.0.3300.1001 at http://x-studio365.com/dl.php?host=local And install
Next, you can use the command line to encrypt resources.
x-studio365 -c -enc -cfg=D:\encrypt-cfg.xml -i=D:\OriginalRes1 -o=D:\EncryptedRes1
Parameter description :
-cfg=[file]: Specify the encryption configuration file for the encryption tool to save the encryption key and other encryption options
-i=[path]: Specify the encrypted input directory
-o=[path]: Specify the encrypted output directory
Other parameter description :
-j2: Enable dual-threaded cryptographic resources
-ft=*.png;*.csb: Specify the resource encryption file type
-dc=.ttf;.mp3;.ogg: Specifies file types for copy directly, some types of files may not need to be encrypted
(1) For the first encryption, the encryption tool will automatically generate the ivec and key required by the AES-CBC encryption mode , and the encryption config will be stored in the encrypt-cfg.xml file for set the key in the decryption runtime. the key/ivce is stored as C++ bytes array format.
(2) If the encryption configuration file specified by the
-cfgoption already exists , the tool reads the encryption option from it , but if the same option is specified in both the configuration file and the command line parameters, the command line parameters override the encryption configuration file. the configuration file will be updated.
(3) If you specify encrypt-cfg.xml already exist and need to change the key, then you only need to delete ivec and key elements from the encrypt-cfg.xml.
Cocos2d-X Demo : https://github.com/halx99/x-studio365/tree/master/encrypt-demo/cpp-empty-test , Based on the latest Cocos2d-X-3.17.1, and the decryption runtime also have test on Cocos2d-X-3.10, but you need change FileUtilsWin32's constructor access permission from
For lua porject, at win32 please move encryption key/ivec setup code to