Long time no more, just the recent graduates looking for a job season, a few of the face of the classics of the article more praise, also along with a few more fans.
From the statistical data of the article, the page view is more or through, rather than the usual technical articles. As I have said in previous articles, the amount of money a person can earn depends on his social value, and whether a person can find a good job depends on his actual quality. While it’s good to wrap things up during an interview, it’s easy to overdo it. Reading books helps, but reading technical articles and practicing code is the key to growth. Students who hope to find a job must break through and master the book one by one to make the book play its due role. Otherwise, even if you read 100 sutras, you will not gain knowledge.
Also, working on a project involves more than just writing code. For example, Android projects also include automated construction, and some operations are time-consuming and labor-intensive to be completed by humans. It is very useful to implement some scripts that can liberate manpower and improve efficiency.
I recently wrote a script to decrypt and re-encrypt JSC files in Cocos to improve packaging efficiency in Cocos such as hot updates. Project address: Jump to GitHub
Introduction to the
Through reading Cocos2dx source code found that its script encryption and decryption is xxTEA encryption and decryption.
CocosCreator is built as follows:
- All js scripts used in the project are aggregated into several scripts such as project.js
- If you check the “Zip Compression” option, project.js will be compressed, which will reduce the volume of the package, thereby reducing the package size
- Encrypt the above files with XXtea to generate project.jsc
- Package project. JSC into installation packages such as APK and IPA
When the program runs, it does just the opposite:
- Decryption using XXTEA
- If Zip Compression is selected, decompress the file
- Calling js code
This script is used by CocosCreator to decrypt JSC files into JS files and encrypt JS files into JSC files after compilation.
When CocosCreator is built, whether or not to check the Zip compression option determines the script parameters to be used. View the encryption key and whether Zip compression is enabled in the following location in the Build panel of CocosCreator.
This script runs fine on macOS High Sierra 10.13.6, Python 2.7, and has not been tested in other environments
Directions for use
Command execution:
-
If encryption is used, set the second parameter to encrypt; If decryption is used, the second parameter is set to decrypt. This parameter is mandatory
-
To set the encryption key, add the –key or -k argument along with the encryption key string. If this parameter is not set, a prompt is displayed on the CLI
-
To set it to a non-compression scheme, add the –nozip or -n argument and set it to true. If this parameter is not set, the compression scheme is used by default
An uncompressed scheme is one in which Cocos is compiled without the “Zip compression” option checked
-
Find the.jsc file compiled by CocosCreator in the build/jsb-default/ SRC folder of your project directory. You can specify the path of the file as prompted while the script is running. You can also add a –path or -p parameter to set the file path. If this parameter is not set, a prompt is displayed on the CLI
-
Just run the script
- Encrypt: The decrypted file path is decryptOutput/decrypt.js
- Decrypt: encrypted file path for encryptOutput/projectChanged JSC
-
For example:
- ./edc.py encrypt –key yourkey –nozip true
- ./edc.py decrypt –nozip true
- ./edc.py decrypt
Other Python script references:
- Download the edc.py file in your script directory and import it by using import EDC
- Call edC.decrypt (is_zip, key, jsc_path) or edc.encrypt(is_zip, key, js_path) directly, see the edcexample.py file
If it is a non-interactive script, be sure to pass in valid arguments when calling the method and ensure that they are correct
Parameters that
Parameter names | abbreviations | Whether must | The default value |
---|---|---|---|
encrypt/decrypt | There is no | is | – |
–key | -k | no | – |
–nozip | -n | no | false |
–path | -p | no | – |
Refer to the article
- Cocos is encrypted by default
- Cocos2dx lua decompilation
Copyright statement
This article is from a simple book: search author QinGeneral synchronous posted on CSDN blog: search author lost synchronous posted on wechat official account: AndroidRain can be reproduced without authorization, even without the need to retain the above copyright notice; Please be sure to indicate the author when reprinting.