A resource encryption and decryption method, system and medium for Cocos game package

By encrypting and decrypting the resource of the game package packaged using cocoscreator, the problem of the game package being easily decompressed and stolen is solved, and high-complexity encryption and security improvements are achieved.

CN114130033BActive Publication Date: 2025-05-02SUZHOU JIUGONG DIGITAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111374154.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-19
Publication Date
2025-05-02
Estimated Expiration
2041-11-19

AI Technical Summary

Technical Problem

In the prior art, game packages packaged using cocoscreator are easily decompressed and stolen, resulting in game resources leakage and infringement.

Method used

Provides a resource encryption and decryption method for Cocos game package. By obtaining the game package packaging process, configuring the offset encryption algorithm and secret key, performing offset iterative encryption operations, generating an encrypted game resource package, and decrypting operations based on the risk list and call status.

Benefits of technology

It realizes high-complex encryption of source files that originally did not support encryption in the game package, improves the security of the game package, prevents the game package from being decompressed and called, and makes up for the shortcomings of the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114130033B_ABST
    Figure CN114130033B_ABST
Patent Text Reader

Abstract

The invention discloses a resource encryption and decryption method, system and medium of a Cocos game package. The method comprises the following steps: obtaining a Cocos game package based on a packaging process and a process completion benchmark; traversing game resources in the Cocos game package based on resource types to obtain a first resource to be encrypted; performing a resource format conversion operation on the first resource to be encrypted to obtain a second resource array to be encrypted; configuring an offset encryption algorithm, an encryption key, a decryption key and a risk list; performing an offset iterative encryption operation on the second resource array to be encrypted based on the offset encryption algorithm, the encryption key and the decryption key to obtain an encrypted game resource package; configuring a decryption algorithm based on the offset iterative encryption operation, and performing a resource decryption operation based on the risk list and the decryption algorithm. The invention can realize high-complexity encryption of source files that originally do not support encryption in a game package packaged by using cocoscreator.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of game resource processing, and in particular to a resource encryption and decryption method, system and medium for a Cocos game package. Background Art

[0002] In the prior art, cocoscreator is usually used to package games. The data resources in the game package generated by this method are all unencrypted original image resources, and the original image resources do not support encryption. Therefore, the unencrypted resources will make the game package easy to be decompressed and stolen, thereby leaking important resource information of the game and causing the game to be infringed. Summary of the invention

[0003] The present invention mainly solves the problem in the prior art that a game package packaged by cocoscreator is easily decompressed and stolen.

[0004] In order to solve the above technical problems, a technical solution adopted by the present invention is: to provide a resource encryption and decryption method of a Cocos game package, comprising the following steps:

[0005] Steps to obtain resources to be encrypted:

[0006] Obtain a game package packaging process; set a process completion benchmark, a resource type, and a resource conversion format; obtain a Cocos game package based on the packaging process and the process completion benchmark; traverse the game resources in the Cocos game package based on the resource type to obtain a first resource to be encrypted; perform a resource format conversion operation on the first resource to be encrypted based on the resource conversion format to obtain a second resource array to be encrypted;

[0007] Game resource encryption and decryption steps:

[0008] Configure an offset encryption algorithm, an encryption key, a decryption key and a risk list; perform an offset iterative encryption operation on the second resource array to be encrypted based on the offset encryption algorithm, the encryption key and the decryption key to obtain an encrypted game resource package; detect the calling status of the encrypted game resource package, configure a decryption algorithm based on the offset iterative encryption operation, and perform a resource decryption operation based on the risk list, the calling status and the decryption algorithm.

[0009] As an improved solution, the step of obtaining the Cocos game package based on the packaging process and the process completion benchmark further includes:

[0010] Identify the process information of the packaging process, and compare the process information with the process completion benchmark; when the process information matches the process completion benchmark, obtain the storage address of the game package; access the storage address, extract the data packet in the storage address that matches the process information, and obtain the Cocos game package.

[0011] As an improved solution, the step of traversing the game resources in the Cocos game package based on the resource type to obtain the first resource to be encrypted further includes:

[0012] Identify a plurality of attribute information respectively corresponding to a plurality of the game resources in the Cocos game package; use a screening algorithm to screen out first attribute information matching the resource type from the plurality of the attribute information; and set the game resource corresponding to the first attribute information as the first resource to be encrypted.

[0013] As an improved solution, the resource format conversion operation includes:

[0014] Convert the first resource to be encrypted into resource data whose data format matches the resource conversion format to obtain third resource data to be encrypted;

[0015] Setting a first storage threshold; identifying a storage occupancy value of the third resource data to be encrypted; calculating a quotient of the storage occupancy value and the first storage threshold to obtain a resource array reference value;

[0016] A resource array container is configured based on the first storage threshold and the resource array reference value; and the third resource data to be encrypted is imported into the resource array container to obtain the second resource array to be encrypted.

[0017] As an improved solution, the offset iterative encryption operation includes:

[0018] Configure the first empty array and the first empty data packet; set the string conversion format;

[0019] Integrate the second to-be-encrypted resource array, the encryption key and the decryption key into the first empty array to obtain a third to-be-encrypted array; call the offset encryption algorithm to perform offset processing on the third to-be-encrypted array to obtain a fourth offset array;

[0020] The fourth offset array is converted into an encrypted string according to the string conversion format; the encrypted string is imported into the first empty data packet to obtain a fourth encrypted data packet; the fourth encrypted data packet is the encrypted game resource packet.

[0021] As an improved solution, the offset encryption algorithm for the offset processing logic of the third array to be encrypted includes:

[0022] Setting a data offset formula and a key offset formula; setting a first data reference offset value, a first encryption reference offset value, and a first decryption reference offset value based on the encryption key and the decryption key;

[0023] Identify the first data in the second array of resources to be encrypted, and set the first data as reference offset data; identify the first encryption character in the encryption key, identify the first decryption character in the decryption key, and set the first encryption character and the first decryption character as reference encryption character and reference decryption character respectively; perform an offset step on the reference offset data, the reference encryption character, and the reference decryption character based on the first data reference offset value, the first encryption reference offset value, and the first decryption reference offset value;

[0024] The offset step includes: performing offset processing on the reference offset data based on the first data reference offset value to obtain first offset data; performing offset processing on the reference encrypted character based on the first encryption reference offset value to obtain a first encrypted offset character; performing offset processing on the reference decrypted character based on the first decryption reference offset value to obtain a first decrypted offset character; and performing an offset value iteration step based on the first offset data, the first encrypted offset character and the first decrypted offset character.

[0025] The offset value iteration step includes: substituting the first offset data into the data offset formula to obtain a second data base offset value; substituting the first encryption offset character into the key offset formula to obtain a second encryption base offset value; substituting the first decryption offset character into the key offset formula to obtain a second decryption base offset value; identifying new base offset data of the second array of resources to be encrypted, identifying new base encryption characters of the encryption key, and identifying new base decryption characters of the decryption key; returning to the offset step based on the second data base offset value, the second encryption base offset value, the second decryption base offset value, the new base offset data, the new base encryption characters, and the new base decryption characters.

[0026] As an improved solution, the step of performing a resource decryption operation based on the risk list, the call status and the decryption algorithm further includes:

[0027] When the calling state is that there is a first user calling the encrypted game resource package, performing the resource decryption operation;

[0028] The resource decryption operation includes: obtaining the first user information of the first user, and determining whether there is second user information matching the first user information in the risk list; if so, deleting the encrypted game resource package and performing an alarm operation; if not, calling the decryption algorithm to decrypt the encrypted game resource package.

[0029] As an improved solution, the resource conversion format is: binary format; the decryption algorithm is an operation algorithm configured according to a processing logic opposite to the offset iterative encryption operation; the first data reference offset value includes: an array first offset value, an array last offset value and an AND logical encryption value.

[0030] The present invention also provides a Cocos game package resource encryption and decryption method and a Cocos game package resource encryption and decryption system, comprising:

[0031] Module for acquiring resources to be encrypted and module for encrypting and decrypting game resources;

[0032] The to-be-encrypted resource acquisition module is used to acquire the game package packaging process and set the process completion benchmark, resource type and resource conversion format; the to-be-encrypted resource acquisition module acquires the Cocos game package based on the packaging process and the process completion benchmark; the to-be-encrypted resource acquisition module traverses the game resources in the Cocos game package based on the resource type to obtain the first to-be-encrypted resource; the to-be-encrypted resource acquisition module performs a resource format conversion operation on the first to-be-encrypted resource based on the resource conversion format to obtain a second to-be-encrypted resource array;

[0033] The game resource encryption and decryption module is used to configure an offset encryption algorithm, an encryption key, a decryption key and a risk list; the game resource encryption and decryption module performs an offset iterative encryption operation on the second resource array to be encrypted based on the offset encryption algorithm, the encryption key and the decryption key to obtain an encrypted game resource package; the game resource encryption and decryption module detects the calling status of the encrypted game resource package, the game resource encryption and decryption module configures a decryption algorithm based on the offset iterative encryption operation, and the game resource encryption and decryption module performs a resource decryption operation based on the risk list, the calling status and the decryption algorithm.

[0034] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the resource encryption and decryption method of the Cocos game package are implemented.

[0035] The beneficial effects of the present invention are:

[0036] 1. The resource encryption and decryption method of the Cocos game package described in the present invention can realize high-complexity encryption of source files that originally do not support encryption in the game package packaged by cocoscreator, and the encryption algorithm used has clever logic and is easy to call but not easy to crack. It does not affect the packaging process of game resources and also improves the security of the game package, preventing the game package from being decompressed and called, and makes up for the shortcomings of the prior art.

[0037] 2. The resource encryption and decryption system of the Cocos game package described in the present invention can realize high-complexity encryption of source files that originally do not support encryption in the game package packaged by cocoscreator through the mutual cooperation of the resource acquisition module to be encrypted and the game resource encryption and decryption module. The encryption algorithm used has clever logic and is easy to call but not easy to crack. It does not affect the packaging process of game resources and also improves the security of the game package, preventing the game package from being decompressed and called, thereby making up for the shortcomings of the prior art.

[0038] 3. The computer-readable storage medium described in the present invention can realize the cooperation between the encrypted resource acquisition module and the game resource encryption and decryption module, thereby realizing high-complexity encryption of the source files that originally do not support encryption in the game package packaged by cocoscreator. The encryption algorithm used has clever logic and is easy to call but not easy to crack. It does not affect the packaging process of game resources and also improves the security of the game package, preventing the game package from being decompressed and called, making up for the shortcomings of the prior art and effectively improving the operability of the resource encryption and decryption method of the Cocos game package. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 It is a flow chart of the resource encryption and decryption method of the Cocos game package described in Example 1 of the present invention;

[0041] Figure 2 is a schematic diagram of a specific flow chart of step S100 in embodiment 1 of the present invention;

[0042] Figure 3 is a schematic diagram of a specific flow chart of step S200 in embodiment 1 of the present invention;

[0043] Figure 4It is an architecture diagram of the resource encryption and decryption system of the Cocos game package described in Example 2 of the present invention. DETAILED DESCRIPTION

[0044] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present invention.

[0045] In the description of the present invention, it should be noted that the embodiments described in the present invention are only part of the embodiments of the present invention, rather than all of the embodiments; based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present invention.

[0046] In the description of the present invention, it should be noted that the terms “first”, “second”, “third” and “fourth” are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0047] In the description of the present invention, it should be noted that: cocoscreator is a game development engine.

[0048] Example 1

[0049] This embodiment provides a method for encrypting and decrypting resources of a Cocos game package, such as Figure 1~Figure 3 As shown, the following steps are included:

[0050] S100, the step of obtaining resources to be encrypted, specifically includes:

[0051] S110, obtaining the game package packaging process; in this embodiment, considering that the game package needs to be encrypted after packaging, it is necessary to monitor the game package packaging process;

[0052] S120, setting the process completion benchmark, resource type and resource conversion format; in this embodiment, considering that the important resources in the game package and the resources that are difficult to encrypt are picture resources, it is necessary to encrypt the picture resources, so the resource type is picture class; the process completion benchmark is that Cocos packages the game resources to a completed state; when encrypting picture resources, only binary data can be processed, and the picture is composed of pixel point data and color value data, so starting from this, the resource conversion format is designed to be binary format;

[0053] S130, obtaining a Cocos game package based on the packaging process and the process completion benchmark;

[0054] Specifically, the process information of the packaging process is identified, and the process information is compared with the process completion benchmark; when the process information matches the process completion benchmark, it means that Cocos has completed the packaging of the game and has generated a corresponding game package, so the storage address of the game package is obtained, and the storage address is the packaging destination corresponding to the game packaged by Cocos, including but not limited to the text information of the storage path; the storage address is accessed, and the data packet matching the process information in the storage address is extracted, and the data packet is the game packaged by Cocos; in this step S100, the main purpose is to complete the initialization configuration operation and the related game package acquisition operation, and provide a data basis for subsequent encryption operations. At the same time, the corresponding game package is obtained through the form of process verification, which ensures the integrity of the data. At the same time, during the process monitoring process, dangerous users are prevented from interfering with or intruding the packaging process, which improves security to a certain extent;

[0055] Correspondingly, part of the implementation code of step S130 is as follows:

[0056] callForEach(GetAllBuildTextures(buildResults), (uuid, next) => {

[0057] var file = buildResults.getNativeAssetPath(uuid);

[0058] if(file.substr(-3) === 'png') { / / Image ending with png

[0059] EncryptOnePng(file, next, next);

[0060] } else {

[0061] next();

[0062] }

[0063] }, () => {

[0064] _log('encrypt Pngs Finish');

[0065] callback && callback();

[0066] });

[0067] S140, traversing the game resources in the Cocos game package based on the resource type to obtain a first resource to be encrypted;

[0068] Specifically, several attribute information respectively corresponding to several game resources in the Cocos game package are identified; the attribute information includes but is not limited to the resource type, resource storage format, resource occupancy value, resource ID information, etc. of the game resource; a screening algorithm is used to screen out the first attribute information matching the resource type from the several attribute information; in this embodiment, the screening algorithm uses a regular matching algorithm to further improve the efficiency of screening and the operability of the method; the game resource corresponding to the first attribute information is set as the first resource to be encrypted; the first resource to be encrypted is the resource that is difficult to encrypt in the original Cocos game package, and in this embodiment, it is a picture resource;

[0069] S150, performing a resource format conversion operation on the first resource to be encrypted based on the resource conversion format to obtain a second resource array to be encrypted; Step S150 is a connecting step. On the one hand, the format of the resource to be encrypted is converted, which not only unifies the resource format for unified calling or processing, but also solves the problem that the image resource is difficult to encrypt, and provides a data basis for subsequent encryption operations;

[0070] Specifically, the resource format conversion operation includes: converting the first resource to be encrypted into resource data whose data format matches the resource conversion format to obtain the third resource data to be encrypted; the third resource data to be encrypted is the image resource data in binary format, and the data must be read in binary format during subsequent encryption, reading and calling; setting a first storage threshold; in this embodiment, the first storage threshold is 1 byte; identifying the storage occupancy value of the third resource data to be encrypted; the storage occupancy value is the size of the third resource data to be encrypted, such as 100 bytes; calculating the quotient of the storage occupancy value and the first storage threshold to obtain a resource array reference value; because the subsequent encryption operation mainly adopts the offset encryption algorithm, it is necessary to convert the resource into an array form for separate storage to facilitate subsequent encryption operations; the resource array reference value represents how many resource array containers need to be configured; therefore, the resource array container is configured based on the first storage threshold and the resource array reference value to obtain a resource array container with a resource array reference value size of the first storage threshold; importing the third resource data to be encrypted into the resource array container to obtain the second resource array to be encrypted; in this embodiment, the second resource array to be encrypted is an array of 1 byte;

[0071] Correspondingly, part of the implementation code of step S150 is as follows:

[0072] function EncryptOnePng(file, cbk, fail) {

[0073] / / _log('Compressing: ' + file)

[0074] / / if(file.indexOf('resources / native / 0c / 0c') != -1)

[0075] {

[0076] fs.readFile(file,'binary',function(err,data)

[0077] {

[0078] if(err)

[0079] _log(err);

[0080] else

[0081] S200, game resource encryption and decryption steps, specifically including:

[0082] S210, configure the offset encryption algorithm, encryption key, decryption key and risk list; in this embodiment, the encryption key and decryption key are set according to the specific encryption requirements, the encryption key and decryption key are in the form of character strings, and are related to each other; the risk list is based on the high-risk access users or bad access users or blacklist access users in the game resources downloaded or obtained from the network data security center, and is used to provide corresponding user verification during the decryption operation, and further control the call security of the encrypted game package;

[0083] S220, performing an offset iterative encryption operation on the second array of resources to be encrypted based on the offset encryption algorithm, the encryption key, and the decryption key to obtain an encrypted game resource package;

[0084] Specifically, the offset iterative encryption operation includes: configuring a first empty array and a first empty data packet; the first empty array and the first empty data packet are both empty format containers for data to be stored; setting a string conversion format; the string conversion format is an array-to-string format, and the string format is the same as the format of the binary resource data before being converted into an array form; integrating the second resource array to be encrypted, the encryption key and the decryption key into the first empty array to obtain a third array to be encrypted; in this embodiment, not only the game resource data is iteratively offset, but also the encryption key and the decryption key are iteratively offset, thereby further improving security; When the decryption key is integrated into the first empty array, the encryption key and the decryption key are also converted into the form of long arrays respectively; the offset encryption algorithm is called to perform offset processing on the third array to be encrypted to obtain a fourth offset array; the fourth offset array is converted into an encrypted string according to the string conversion format; the encrypted string is imported into the first empty data packet to obtain a fourth encrypted data packet; when the data is offset processed, the data itself is changed, which does not affect the location and occupancy of the data. After the offset processing, the data is observed again in the form of garbled code, which is extremely safe and not easy to be cracked, so the fourth encrypted data packet is the encrypted game resource package;

[0085] Specifically, the offset encryption algorithm includes the following processing logic for the offset of the third array to be encrypted:

[0086] A data offset formula and a key offset formula are set; a first data reference offset value, a first encryption reference offset value and a first decryption reference offset value are set based on the encryption key and the decryption key; specifically, the first data reference offset value includes: an array first offset value, an array last offset value, a logical encryption value and a golden constant; correspondingly, the data content of the first encryption reference offset value and the first decryption reference offset value is the same as the data content of the first data reference offset value, and both include a first related value, a last related value, a logically related encryption value and a golden constant; correspondingly, in this embodiment, the data offset formula and the key offset formula are set according to specific circumstances; the formulas are all mathematical formulas used for iterative adjustment of the first data reference offset value, the first encryption reference offset value and the first decryption reference offset value during subsequent step loop iterations, including but not limited to mathematical formulas and value ranges;

[0087] Correspondingly, the main offset iteration principle is: identifying the first data in the second to-be-encrypted resource array, setting the first data as the reference offset data; identifying the first encryption character in the encryption key, identifying the first decryption character in the decryption key, setting the first encryption character and the first decryption character as the reference encryption character and the reference decryption character respectively; performing the offset step on the reference offset data, the reference encryption character and the reference decryption character based on the first data reference offset value, the first encryption reference offset value and the first decryption reference offset value;

[0088] The offset step includes: performing offset processing on the benchmark offset data based on the first data benchmark offset value to obtain first offset data; performing offset processing on the benchmark encrypted character based on the first encryption benchmark offset value to obtain a first encrypted offset character; performing offset processing on the benchmark decrypted character based on the first decryption benchmark offset value to obtain a first decrypted offset character; performing an offset value iteration step based on the first offset data, the first encrypted offset character and the first decrypted offset character; correspondingly, the specific principle of the offset processing takes the benchmark offset data as an example: right-shifting the benchmark offset data in the original data structure by the same number of bits as the last offset value of the array, which is two bits in this embodiment, and complementing the first bit of the right-shifted data with The value of the first offset value of the array is the same. In this embodiment, the first offset value of the array is 0, so 0 is added on the left; the data finally obtained after the offset plus the position is bound with the logical encryption value to obtain the final first offset data; the processing process of the first encrypted offset character and the first decrypted offset character is the same as the above principle; correspondingly, the resource data after the offset processing is already in garbled form, and the difficulty of cracking is extremely high. At the same time, the logical encryption value added in the offset processing will further increase the difficulty of decryption. When decrypting, the same logical value must be entered for matching before decryption can be successful, which makes the resources in the originally complex garbled form more secure; correspondingly, after executing the above steps once, the obtained results, i.e., the first offset data, the first The encrypted offset character and the first decrypted offset character are substituted into the data offset formula and the key offset formula to obtain new reference offset data, and then the unencrypted data in the array is offset processed according to the reference offset data. In this iterative process, the encryption key data of each step will change according to the result of the offset processing in the previous step, which is extremely difficult to crack. In this embodiment, the data offset formula and the key offset formula are set according to the golden constant, and the result of each iteration can be increased by the golden constant, thereby achieving the change of each reference offset data, which is extremely safe; finally, after the loop iteration is completed until all the data in the array are offset processed, the encryption operation is terminated; therefore, the offset value iteration step includes: substituting the first offset data into the data The first encryption offset character is substituted into the key offset formula to obtain a second encryption offset value; the first decryption offset character is substituted into the key offset formula to obtain a second decryption offset value; the new offset data of the second resource array to be encrypted is identified, the new base encryption character of the encryption key is identified, and the new base decryption character of the decryption key is identified; based on the second data base offset value, the second encryption base offset value, the second decryption base offset value, the new base offset data, the new base encryption character and the new base decryption character, the offset step is returned; through this step, a high-security encryption operation of the data is performed, which makes up for the shortcomings of the prior art;

[0089] Correspondingly, part of the implementation code of step S220 is as follows:

[0090] function xxtea_encrypt(str, key) {

[0091] if (str == "") {

[0092] return "";

[0093] }

[0094] / / Convert the passed in image string to be offset into a long array;

[0095] var v = str2long(str, true);

[0096] / / Convert the passed secret key into a long array;

[0097] var k = str2long(key, false);

[0098] var n = v.length - 1;

[0099] / / z is the last value of the array, y is the first value of the array, and delta is a fixed golden constant;

[0100] var z = v[n], y = v[0], delta = 0x9E3779B9;

[0101] / / Define the initialization value, q is the number of loop iterations;

[0102] var mx, e, q = Math.floor(6 + 52 / (n + 1)), sum = 0;

[0103] / / Loop through each round of encryption;

[0104] while (q-- > 0) {

[0105] / / Each time add the result of the previous round to the golden constant;

[0106] sum = sum + delta;

[0107] / / Shift the obtained value right by 2 bits, fill the left side with 0, and perform bitwise AND logic on the result and 3;

[0108] e = sum >>> 2 & 3;

[0109] S230, detecting the calling state of the encrypted game resource package, configuring a decryption algorithm based on the offset iterative encryption operation, and performing a resource decryption operation based on the risk list, the calling state and the decryption algorithm;

[0110] Specifically, this step takes into account the application of a specific game package. Although it is encrypted, it cannot prevent normal users from calling it. Therefore, when the calling state is that there is a first user calling the encrypted game resource package, the first user needs to run the game, so the resource decryption operation is performed;

[0111] The resource decryption operation includes: obtaining the first user information of the first user, and determining whether there is second user information matching the first user information in the risk list; if so, it means that the first user is an illegal user and there is a risk of misappropriation of game resources, so the misappropriation of the game resource package is blocked from the source, so the encrypted game resource package is deleted, and an alarm operation is performed, and the alarm operation is to send a message to the management background of the game resource package, such as the mobile terminal of the administrator, or to make a voice prompt call; if not, it means that the user is a normal user, so the decryption algorithm is called to decrypt the encrypted game resource package; specifically, in this embodiment, the decryption algorithm is an operation algorithm configured according to a processing logic opposite to the offset iterative encryption operation, and the decryption algorithm is used specifically for decrypting the game resource package encrypted by this method; considering security, the decryption algorithm and the game resource package are not configured in the same data file.

[0112] Example 2

[0113] This embodiment is based on the inventive concept of the resource encryption and decryption method of the Cocos game package described in Example 1, and provides a resource encryption and decryption system for the Cocos game package, such as Figure 4 As shown, it includes: a module for acquiring resources to be encrypted and a module for encrypting and decrypting game resources;

[0114] In the resource encryption and decryption system of the Cocos game package, the resource acquisition module to be encrypted is used to obtain the game package packaging process and set the process completion benchmark, resource type and resource conversion format; the resource acquisition module to be encrypted obtains the Cocos game package based on the packaging process and the process completion benchmark; the resource acquisition module to be encrypted traverses the game resources in the Cocos game package based on the resource type to obtain the first resource to be encrypted; the resource acquisition module to be encrypted performs a resource format conversion operation on the first resource to be encrypted based on the resource conversion format to obtain a second resource array to be encrypted;

[0115] Specifically, the to-be-encrypted resource acquisition module identifies the process information of the packaging process, and compares the process information with the process completion benchmark; when the process information matches the process completion benchmark, the to-be-encrypted resource acquisition module acquires the storage address of the game package; the to-be-encrypted resource acquisition module accesses the storage address, and extracts the data packet in the storage address that matches the process information, to obtain the Cocos game package;

[0116] Specifically, the resource acquisition module to be encrypted identifies a number of attribute information respectively corresponding to a number of the game resources in the Cocos game package; the resource acquisition module to be encrypted uses a screening algorithm to filter out first attribute information matching the resource type from the number of the attribute information; the resource acquisition module to be encrypted sets the game resource corresponding to the first attribute information as the first resource to be encrypted;

[0117] Specifically, the resource format conversion operation includes: the resource acquisition module to be encrypted converts the first resource to be encrypted into resource data whose data format matches the resource conversion format, and obtains the third resource data to be encrypted; the resource acquisition module to be encrypted sets a first storage threshold; the resource acquisition module to be encrypted identifies the storage occupancy value of the third resource data to be encrypted; the resource acquisition module to be encrypted calculates the quotient of the storage occupancy value and the first storage threshold to obtain a resource array reference value; the resource acquisition module to be encrypted configures a resource array container based on the first storage threshold and the resource array reference value; the resource acquisition module to be encrypted imports the third resource data to be encrypted into the resource array container to obtain the second resource array to be encrypted.

[0118] In the resource encryption and decryption system of the Cocos game package, the game resource encryption and decryption module is used to configure an offset encryption algorithm, an encryption key, a decryption key and a risk list; the game resource encryption and decryption module performs an offset iterative encryption operation on the second array of resources to be encrypted based on the offset encryption algorithm, the encryption key and the decryption key to obtain an encrypted game resource package; the game resource encryption and decryption module detects the calling state of the encrypted game resource package, the game resource encryption and decryption module configures a decryption algorithm based on the offset iterative encryption operation, and the game resource encryption and decryption module performs a resource decryption operation based on the risk list, the calling state and the decryption algorithm;

[0119] Specifically, the offset iterative encryption operation includes: the game resource encryption and decryption module configures a first empty array and a first empty data packet; the game resource encryption and decryption module sets a string conversion format; the game resource encryption and decryption module integrates the second to-be-encrypted resource array, the encryption key and the decryption key into the first empty array to obtain a third to-be-encrypted array; the game resource encryption and decryption module calls the offset encryption algorithm to perform offset processing on the third to-be-encrypted array to obtain a fourth offset array; the game resource encryption and decryption module converts the fourth offset array into an encrypted string according to the string conversion format; the game resource encryption and decryption module imports the encrypted string into the first empty data packet to obtain a fourth encrypted data packet; the fourth encrypted data packet is the encrypted game resource packet;

[0120] Specifically, the offset encryption algorithm includes the following processing logic for the offset of the third array to be encrypted:

[0121] The game resource encryption and decryption module sets a data offset formula and a key offset formula; the game resource encryption and decryption module sets a first data reference offset value, a first encryption reference offset value and a first decryption reference offset value based on the encryption key and the decryption key;

[0122] The game resource encryption and decryption module identifies the first data in the second array of resources to be encrypted, and sets the first data as the reference offset data; the game resource encryption and decryption module identifies the first encryption character in the encryption key, and identifies the first decryption character in the decryption key, and sets the first encryption character and the first decryption character as the reference encryption character and the reference decryption character respectively; the game resource encryption and decryption module performs an offset step on the reference offset data, the reference encryption character and the reference decryption character based on the first data reference offset value, the first encryption reference offset value and the first decryption reference offset value;

[0123] The offset step includes: the game resource encryption and decryption module performs an offset process on the reference offset data based on the first data reference offset value to obtain the first offset data; the game resource encryption and decryption module performs an offset process on the reference encrypted character based on the first encryption reference offset value to obtain the first encrypted offset character; the game resource encryption and decryption module performs an offset process on the reference decrypted character based on the first decryption reference offset value to obtain the first decrypted offset character; the game resource encryption and decryption module performs an offset value iteration step based on the first offset data, the first encrypted offset character and the first decrypted offset character;

[0124] The offset value iteration step includes: the game resource encryption and decryption module substitutes the first offset data into the data offset formula to obtain a second data base offset value; the game resource encryption and decryption module substitutes the first encryption offset character into the key offset formula to obtain a second encryption base offset value; the game resource encryption and decryption module substitutes the first decryption offset character into the key offset formula to obtain a second decryption base offset value; the game resource encryption and decryption module identifies the new base offset data of the second array of resources to be encrypted, and identifies the new base encryption character of the encryption key, and the game resource encryption and decryption module identifies the new base decryption character of the decryption key; the game resource encryption and decryption module returns to the offset step based on the second data base offset value, the second encryption base offset value, the second decryption base offset value, the new base offset data, the new base encryption character and the new base decryption character.

[0125] Specifically, when the calling status is that there is a first user calling the encrypted game resource package, the game resource encryption and decryption module performs the resource decryption operation; the resource decryption operation includes: the game resource encryption and decryption module obtains the first user information of the first user, and determines whether there is second user information matching the first user information in the risk list; if so, the game resource encryption and decryption module deletes the encrypted game resource package and performs an alarm operation; if not, the game resource encryption and decryption module calls the decryption algorithm to decrypt the encrypted game resource package.

[0126] Example 3

[0127] This embodiment provides a computer-readable storage medium, including:

[0128] The storage medium is used to store computer software instructions used to implement the resource encryption and decryption method of the Cocos game package described in the above-mentioned embodiment 1, which includes a program for executing the above-mentioned program set for the resource encryption and decryption method of the Cocos game package; specifically, the executable program can be built into the resource encryption and decryption system of the Cocos game package described in embodiment 2, so that the resource encryption and decryption system of the Cocos game package can implement the resource encryption and decryption method of the Cocos game package described in embodiment 1 by executing the built-in executable program.

[0129] In addition, the computer-readable storage medium of this embodiment may adopt any combination of one or more computer-readable storage media, wherein the computer-readable storage medium includes electrical, optical, electromagnetic, infrared or semiconductor systems, devices or components, or any combination thereof.

[0130] Different from the prior art, the resource encryption and decryption method, system and medium of a Cocos game package of the present application can perform high-complexity encryption on the source files that originally do not support encryption in the game package packaged by cocoscreator through the present method, and the encryption algorithm used has clever logic and is easy to call but not easy to crack. It does not affect the packaging process of game resources and also improves the security of the game package. The system provides effective technical features for the method, ultimately preventing the game package from being decompressed and called, and making up for the shortcomings of the prior art.

[0131] The serial numbers of the embodiments disclosed in the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0132] A person skilled in the art will appreciate that all or part of the steps for implementing the above embodiments may be accomplished by hardware, or may be accomplished by a program to instruct the relevant hardware. The program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk, or an optical disk, etc.

[0133] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for encrypting and decrypting resources of a Cocos game package, characterized in that: The following steps are involved: Steps to obtain resources to be encrypted: Get the game package packaging process; Set the process completion benchmark, resource type and resource conversion format; obtain the Cocos game package based on the packaging process and the process completion benchmark; traverse the game resources in the Cocos game package based on the resource type to obtain the first resource to be encrypted; perform a resource format conversion operation on the first resource to be encrypted based on the resource conversion format to obtain a second resource array to be encrypted; Game resource encryption and decryption steps: Configure the offset encryption algorithm, encryption key, decryption key and risk list; perform the offset iterative encryption operation on the second array of resources to be encrypted based on the offset encryption algorithm, encryption key and decryption key to obtain an encrypted game resource package; detect the call status of the encrypted game resource package, configure the decryption algorithm based on the offset iterative encryption operation, and perform the resource decryption operation based on the risk list, the call status and the decryption algorithm; The offset iterative encryption operation includes: configuring a first empty array and a first empty data packet; setting a string conversion format; integrating the second to-be-encrypted resource array, the encryption key and the decryption key into the first empty array to obtain a third to-be-encrypted array; calling an offset encryption algorithm to perform offset processing on the third to-be-encrypted array to obtain a fourth offset array; converting the fourth offset array into an encrypted string according to the string conversion format; importing the encrypted string into the first empty data packet to obtain a fourth encrypted data packet; the fourth encrypted data packet is an encrypted game resource packet; The offset processing logic of the offset encryption algorithm for the third array to be encrypted includes: setting a data offset formula and a key offset formula; setting a first data reference offset value, a first encryption reference offset value, and a first decryption reference offset value based on the encryption key and the decryption key; identifying the first data in the second array of resources to be encrypted, and setting the first data as reference offset data; identifying the first encryption character in the encryption key, identifying the first decryption character in the decryption key, and setting the first encryption character and the first decryption character as reference encryption characters and reference decryption characters respectively; performing an offset step on the reference offset data, the reference encryption character, and the reference decryption character based on the first data reference offset value, the first encryption reference offset value, and the first decryption reference offset value; The offset step includes: performing offset processing on the reference offset data based on the first data reference offset value to obtain the first offset data; performing offset processing on the reference encrypted character based on the first encryption reference offset value to obtain the first encrypted offset character; performing offset processing on the reference decrypted character based on the first decryption reference offset value to obtain the first decrypted offset character; and performing an offset value iteration step based on the first offset data, the first encrypted offset character and the first decrypted offset character. The offset value iteration step includes: substituting the first offset data into the data offset formula to obtain the second data base offset value; substituting the first encryption offset character into the key offset formula to obtain the second encryption base offset value; substituting the first decryption offset character into the key offset formula to obtain the second decryption base offset value; identifying the new base offset data of the second resource array to be encrypted, identifying the new base encryption character of the encryption key, and identifying the new base decryption character of the decryption key; returning to the offset step based on the second data base offset value, the second encryption base offset value, the second decryption base offset value, the new base offset data, the new base encryption character and the new base decryption character.

2. A method for encrypting and decrypting resources of a Cocos game package according to claim 1, characterized in that: The step of obtaining the Cocos game package based on the packaging process and the process completion benchmark further includes: Identify the process information of the packaging process, and compare the process information with the process completion benchmark; when the process information matches the process completion benchmark, obtain the storage address of the game package; access the storage address, extract the data packet in the storage address that matches the process information, and obtain the Cocos game package.

3. A method for encrypting and decrypting resources of a Cocos game package according to claim 2, characterized in that: The step of traversing the game resources in the Cocos game package based on the resource type to obtain the first resource to be encrypted further includes: Identify a plurality of attribute information respectively corresponding to a plurality of the game resources in the Cocos game package; use a screening algorithm to screen out first attribute information matching the resource type from the plurality of the attribute information; and set the game resource corresponding to the first attribute information as the first resource to be encrypted.

4. A method for encrypting and decrypting resources of a Cocos game package according to claim 3, characterized in that: The resource format conversion operation includes: Convert the first resource to be encrypted into resource data whose data format matches the resource conversion format to obtain third resource data to be encrypted; Setting a first storage threshold; identifying a storage occupancy value of the third resource data to be encrypted; calculating a quotient of the storage occupancy value and the first storage threshold to obtain a resource array reference value; A resource array container is configured based on the first storage threshold and the resource array reference value; and the third resource data to be encrypted is imported into the resource array container to obtain the second resource array to be encrypted.

5. A method for encrypting and decrypting resources of a Cocos game package according to claim 1, characterized in that: The step of performing a resource decryption operation based on the risk list, the call status and the decryption algorithm further includes: When the calling state is that there is a first user calling the encrypted game resource package, performing the resource decryption operation; The resource decryption operation includes: obtaining the first user information of the first user, and determining whether there is second user information matching the first user information in the risk list; if so, deleting the encrypted game resource package and performing an alarm operation; if not, calling the decryption algorithm to decrypt the encrypted game resource package.

6. A method for encrypting and decrypting resources of a Cocos game package according to claim 5, characterized in that: The resource conversion format is: binary format; The decryption algorithm is an operation algorithm configured according to a processing logic opposite to the offset iterative encryption operation; The first data reference offset value includes: an array first offset value, an array last offset value and an AND logic encryption value.

7. A Cocos game package resource encryption and decryption system based on a Cocos game package resource encryption and decryption method according to any one of claims 1 to 6, characterized in that: include: Module for acquiring resources to be encrypted and module for encrypting and decrypting game resources; The resource acquisition module to be encrypted is used to obtain the game package packaging process and set the process completion benchmark, resource type and resource conversion format; the resource acquisition module to be encrypted obtains the Cocos game package based on the packaging process and the process completion benchmark; The to-be-encrypted resource acquisition module traverses the game resources in the Cocos game package based on the resource type to obtain a first to-be-encrypted resource; the to-be-encrypted resource acquisition module performs a resource format conversion operation on the first to-be-encrypted resource based on the resource conversion format to obtain a second to-be-encrypted resource array; The game resource encryption and decryption module is used to configure an offset encryption algorithm, an encryption key, a decryption key and a risk list; the game resource encryption and decryption module performs an offset iterative encryption operation on the second array of resources to be encrypted based on the offset encryption algorithm, the encryption key and the decryption key to obtain an encrypted game resource package; The game resource encryption and decryption module detects the calling status of the encrypted game resource package, configures a decryption algorithm based on the offset iterative encryption operation, and performs a resource decryption operation based on the risk list, the calling status and the decryption algorithm.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the resource encryption and decryption method of the Cocos game package described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Distributed data set encryption and decryption

    CA3213857A1

  • Circle scattering migration code-transfer ciphering method

    CN101226705A