Web resource offline package storage and loading method and system

By encrypting and decrypting JavaScript files in offline web resources, the problem of insufficient security of JavaScript files in the existing technology is solved, the storage and access security of offline web resources is improved, and resource files are leaked and hijacked.

CN119808144APending Publication Date: 2025-04-11CHINA CITIC BANK CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411784418.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The existing offline web loading technology lacks secure access measures after decompression is completed. JavaScript files are easily hijacked, resulting in resource files leaks, and security risks.

Method used

During the offline package storage and loading of web resources, JavaScript files are encrypted, encrypted JavaScript files are generated, and the mapping relationship table between the name and the encrypted file is maintained, and the logging relationship table is decrypted and loaded during access.

Benefits of technology

Through the encryption and decryption mechanism, the security of offline web resources is improved, illegal elements are prevented from invading user information, and resource file leakage and three-party hijacking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119808144A_ABST
    Figure CN119808144A_ABST
Patent Text Reader

Abstract

The invention relates to a Web resource off-line package storage and loading method and system, and the method comprises the steps: obtaining a latest resource off-line compressed package from a server, and decompressing the latest resource off-line compressed package to obtain an off-line resource file; the method comprises the following steps of: encrypting a JavaScript file in an offline resource file to generate an encrypted JavaScript file, and storing the encrypted JavaScript file; maintaining a mapping relation table between the name of the JavaScript file in the offline resource file and the encrypted JavaScript file; and querying and encrypting the JavaScript file based on the mapping relation table, decrypting the JavaScript file, loading the JavaScript file, and returning the JavaScript file. By encrypting the JavaScript file in the Web offline resource and decrypting the file during access, the security of the code is ensured, the security of Web offline resource storage and access is improved to a certain extent, and the behavior that lawbreakers intrude mobile phone information of users is effectively prevented.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a method and system for storing and loading a Web resource offline package. Background Art

[0002] In recent years, the mobile application market has flourished, especially the "traffic-level" apps, which have brought better experience to users. This is not only due to the functions of the apps themselves, but also due to the good interactive experience that the apps provide to users. In this context, Web offline loading technology has emerged, providing a new solution to the problem of loading H5 resources on mobile terminals, especially in the current H5+Native hybrid development model, Web offline loading technology plays an increasingly important role. The current Web offline loading technology mainly uses the following solutions to solve the problem of storage access security:

[0003] 1. Verify the signature: Before loading an offline package, verify its signature to ensure the integrity of the content and the reliability of the source. If the signature verification fails, the offline package will be rejected.

[0004] 2. Version check: Check whether the offline package version stored locally is consistent with the latest version on the server. If not, download the latest version from the server and replace the offline package stored locally.

[0005] 3. Load offline package: After verification, load the offline package file from local storage and parse its content for use by the H5 application.

[0006] The style of H5 pages is inconsistent with that of native pages, making debugging difficult and risking hijacking and inserting advertisements. Current Web offline loading technology uses technical means such as signature verification and version control to ensure the security and integrity of H5 offline resource compression packages during download and decompression, but there are still certain security risks. When the H5 offline resource package is decompressed, there is no security access measure for the resource file, especially the JavaScript file in the H5 resource file, which usually contains key code for interacting with the backend server. When the decompression path of the H5 offline resource package is leaked, the resource file is also easily hijacked, causing resource file leakage, which poses certain security risks. Summary of the invention

[0007] To address the deficiencies of the prior art, the present invention ensures the security of the code by encrypting the JavaScript file code in the Web offline resources and decrypting it when accessing it, thereby increasing the security of Web offline resource storage access to a certain extent and effectively preventing criminals from intruding into user information.

[0008] To achieve the above objectives, the technical solutions adopted by the present invention include:

[0009] A method for storing and loading a Web resource offline package, characterized by comprising:

[0010] S1. Obtain the latest offline resource compressed package from the server, and decompress the latest offline resource compressed package to obtain offline resource files;

[0011] S2 encrypts the JavaScript file in the offline resource file, generates an encrypted JavaScript file and stores it;

[0012] S3. Maintain the mapping table between the name of the JavaScript file in the offline resource file and the encrypted JavaScript file;

[0013] S4. Based on the mapping relationship table, the encrypted JavaScript file is queried and decrypted, and the JavaScript file is loaded and returned.

[0014] Furthermore, before obtaining the latest resource offline compressed package from the server and decompressing the latest resource offline compressed package to obtain the offline resource file, the method further includes:

[0015] Request the latest resource offline compressed package list from the server, compare it with the local resource offline compressed package list, and update the latest resource offline compressed package.

[0016] Furthermore, encrypting the JavaScript file in the offline resource file, generating and storing the encrypted JavaScript file, includes:

[0017] Determine whether there is a JavaScript file in the offline resource file;

[0018] If there is no JavaScript file in the offline resource file, directly delete the corresponding offline compressed package;

[0019] If there is a JavaScript file in the offline resource file, traverse the JavaScript file set and load the JavaScript file stream;

[0020] If there is a JavaScript file in the offline resource file, traversing the JavaScript file set and loading the JavaScript file stream further includes:

[0021] Determine whether the size of the JavaScript file stream is greater than a preset threshold;

[0022] If the size of the JavaScript file stream is greater than the preset threshold, the preset threshold is used as the minimum unit, the JavaScript file stream is split based on the minimum unit and encrypted, and an encrypted JavaScript file is generated and stored;

[0023] If the size of the JavaScript file stream is not greater than the preset threshold, the JavaScript file stream is directly encrypted to generate and store an encrypted JavaScript file.

[0024] Furthermore, after maintaining the mapping relationship table between the name of the JavaScript file in the offline resource file and the encrypted JavaScript file, the method further comprises:

[0025] Delete the corresponding JavaScript file;

[0026] Delete the corresponding offline compressed package.

[0027] Furthermore, before querying the encrypted JavaScript file based on the mapping relationship table, the method further includes:

[0028] Determine whether the offline resource to be loaded is a JavaScript file resource;

[0029] If the offline resource to be loaded is a JavaScript file resource, query the corresponding encrypted JavaScript file from the mapping relationship table and decrypt it;

[0030] If the offline resource to be loaded is not a JavaScript file resource, the resource data is returned directly.

[0031] Furthermore, if the offline resource to be loaded is a JavaScript file resource, the corresponding encrypted JavaScript file is queried from the mapping relationship table and decrypted, including:

[0032] Determine the number of encrypted JavaScript files;

[0033] When the encrypted JavaScript file is a single one, the encrypted JavaScript file is directly decrypted and the JavaScript file data is returned;

[0034] When there are multiple encrypted JavaScript files, the thread pool is started to call multiple threads to decrypt the encrypted JavaScript files, assemble them into original JavaScript files, and return JavaScript file data.

[0035] The present invention also relates to a Web resource offline package storage and loading system, which is characterized by comprising:

[0036] An acquisition module is used to acquire an offline compressed package of the latest resource from a server, and decompress the offline compressed package of the latest resource to obtain an offline resource file;

[0037] An encryption module, used to encrypt the JavaScript file in the offline resource file, generate an encrypted JavaScript file and store it;

[0038] A maintenance module, used to maintain a mapping relationship table between the name of the JavaScript file in the offline resource file and the encrypted JavaScript file;

[0039] The loading module is used to query the encrypted JavaScript file based on the mapping relationship table and decrypt it, and load and return the JavaScript file.

[0040] The present invention also relates to a computer-readable storage medium, characterized in that a computer program is stored on the storage medium, and the computer program implements the above method when executed by a processor.

[0041] The present invention also relates to an electronic device, characterized in that it comprises a processor and a memory;

[0042] The memory is used to store program instructions;

[0043] The processor is used to execute the above method by calling program instructions.

[0044] The present invention also relates to a computer program product, comprising a computer program and / or instructions, characterized in that the computer program and / or instructions implement the steps of the above method when executed by a processor.

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

[0046] The method and system for storing and loading a Web resource offline package described in the present invention improves the security of Web offline resource storage and access, avoids the leakage problem and the three-party hijacking problem of H5 offline resources to a certain extent, and ensures the security of user data. At present, mobile applications lack effective security storage access measures for stored Web offline package resources, especially after the external party knows the specific storage location of the H5 offline resource on the client, it is easy to obtain the key code in the JavaScript file by decompilation, and then skip some verifications and access the server resources by illegally operating the user information, which increases the risk of user information leakage to a certain extent. The present invention mainly ensures the security of the code by encrypting the JavaScript file code in the Web offline resource and decrypting it when accessing it, which increases the security of Web offline resource storage and access to a certain extent, and effectively prevents the intrusion of criminals into the user's mobile phone information. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.

[0048] Figure 1 A schematic diagram of a method for storing and loading a Web resource offline package according to the present invention;

[0049] Figure 2 A schematic diagram of the structure of a Web resource offline package storage and loading system of the present invention;

[0050] Figure 3 The figure is a schematic structural diagram of an electronic device of the present invention. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with the specific embodiments of the present application and the corresponding drawings. It should be understood that the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments, and these embodiments are only used to illustrate the present application and are not used to limit the scope of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0052] like Figure 1 As shown, the embodiment of the present invention discloses a method for storing and loading a Web resource offline package, and the steps of the method include:

[0053] Step S1. Obtain the latest resource offline compressed package from the server, and decompress the latest resource offline compressed package to obtain an offline resource file.

[0054] In this embodiment, the offline resource file includes a JavaScript file, wherein the JavaScript file is used to store key codes for interacting with the server.

[0055] When the APP is started, it requests the latest offline resource compressed package list from the server, compares it with the local offline resource compressed package list, and updates the latest offline resource compressed package. When updating the offline package, it obtains the latest offline resource compressed package from the server, decompresses the compressed package, and generates an H5 offline resource file.

[0056] Step S2: Encrypt the JavaScript file in the offline resource file, generate an encrypted JavaScript file and store it.

[0057] Specifically, encrypting the JavaScript file in the offline resource file, generating and storing the encrypted JavaScript file, includes:

[0058] Determine whether there is a JavaScript file in the offline resource file;

[0059] If there is no JavaScript file in the offline resource file, directly delete the corresponding offline compressed package;

[0060] If there is a JavaScript file in the offline resource file, traverse the JavaScript file set and load the JavaScript file stream;

[0061] If there is a JavaScript file in the offline resource file, traversing the JavaScript file set and loading the JavaScript file stream further includes:

[0062] Determine whether the size of the JavaScript file stream is greater than a preset threshold;

[0063] If the size of the JavaScript file stream is greater than the preset threshold, the preset threshold is used as the minimum unit, the JavaScript file stream is split based on the minimum unit and encrypted, and an encrypted JavaScript file is generated and stored;

[0064] If the size of the JavaScript file stream is not greater than the preset threshold, the JavaScript file stream is directly encrypted to generate and store an encrypted JavaScript file.

[0065] In this embodiment, when there is a JavaScript file resource, the JavaScript file set is traversed, and the JavaScript file stream is loaded respectively to determine whether the JavaScript file stream is larger than a preset threshold of 200kb. If it is larger than 200kb, the JavaScript file stream is split, and the JavaScript file stream is split every 200kb, and then the split JavaScript file stream is stored using symmetric encryption. If it is not larger than 200kb, the JavaScript file stream is directly stored using symmetric encryption.

[0066] In this embodiment, the preset threshold can be set according to resource conditions.

[0067] In this embodiment, the JavaScript file stream may also be encrypted in an asymmetric encryption manner.

[0068] Step S3: Maintain a mapping relationship table between the name of the JavaScript file in the offline resource file and the encrypted JavaScript file.

[0069] In this embodiment, after the encrypted JavaScript file is generated, a mapping relationship table between the name of the original JavaScript file and the encrypted JavaScript file is maintained, and the original JavaScript file is deleted after the operation is completed.

[0070] Furthermore, after traversing the JavaScript file set, the original offline compressed package is deleted.

[0071] Step S4: Based on the mapping relationship table, the encrypted JavaScript file is queried and decrypted, and the JavaScript file is loaded and returned.

[0072] When an APP application accesses a Web offline resource, before WebView loads the H5 offline resource, it determines whether the offline resource to be loaded is a JavaScript file resource:

[0073] If the offline resource to be loaded is not a JavaScript file resource, the resource data is returned directly;

[0074] If the offline resource to be loaded is a JavaScript file resource, the corresponding encrypted JavaScript file is searched from the maintained mapping relationship table;

[0075] Furthermore, when the encrypted JavaScript file is a single one, the encrypted JavaScript file is directly decrypted and the JavaScript file data is returned to WebView;

[0076] Furthermore, when there are multiple encrypted JavaScript files, the thread pool is started to call multiple threads to decrypt the encrypted JavaScript files. After the decryption is completed, they are assembled into the original JavaScript files and the JavaScript file data is returned to WebView.

[0077] In this embodiment, decryption may be performed using an asymmetric decryption method.

[0078] like Figure 2 As shown, the embodiment of the present invention discloses a Web resource offline package storage and loading system, the structure of which includes:

[0079] An acquisition module is used to acquire an offline compressed package of the latest resource from a server, and decompress the offline compressed package of the latest resource to obtain an offline resource file;

[0080] An encryption module, used to encrypt the JavaScript file in the offline resource file, generate an encrypted JavaScript file and store it;

[0081] A maintenance module, used to maintain a mapping relationship table between the name of the JavaScript file in the offline resource file and the encrypted JavaScript file;

[0082] The loading module is used to query the encrypted JavaScript file based on the mapping relationship table and decrypt it, and load and return the JavaScript file.

[0083] In the embodiment of the present invention, the user starts the App and updates the latest H5 resource offline compressed package. At this time, the client application will perform a series of operations such as decompression, determining whether the decompressed resource directory contains JavaScript files, traversing JavaScript files, loading JavaScript file streams, encrypting JavaScript file streams to generate encrypted JavaScript files, etc. When the user accesses the H5 offline resource, the WebView container determines whether the JavaScript file resource is loaded before loading the resource, and then goes through a series of actions such as enabling threads, decryption, loading resources, and rendering resources, and finally the client application presents the result to the user.

[0084] By using this system, the above-mentioned operation processing method can be executed and the corresponding technical effects can be achieved.

[0085] An embodiment of the present invention also provides a computer-readable storage medium capable of implementing all the steps in the method in the above embodiment, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, all the steps in the method in the above embodiment are implemented.

[0086] The embodiment of the present invention further provides an electronic device for executing the above method, as a device for implementing the method, and its structure is as follows: Figure 3 As shown, the electronic device 300 includes: a processor 301 and a memory 303. The processor 301 and the memory 303 are connected, such as through a bus 302. Optionally, the electronic device 300 may also include a transceiver 304. It should be noted that in actual applications, the transceiver 304 is not limited to one. It is understandable that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the specific structure of the electronic device 300. In other embodiments of the present application, the electronic device 300 may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware. Optionally, the electronic device may also include a display screen 305 for displaying images, or receiving user operation instructions when necessary.

[0087] The processor 301 is applied in the embodiment of the present application to implement the method shown in the above method embodiment. The transceiver 304 may include a receiver and a transmitter. The transceiver 304 is applied in the embodiment of the present application to implement the function of the electronic device of the embodiment of the present application communicating with other devices when executed.

[0088] Processor 301 may be a CPU (Central Processing Unit), a general purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 301 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0089] The processor 301 may also include one or more processing units, for example, the processor 301 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processor (NPU). Among them, different processing units may be independent devices or integrated into one or more processors. Among them, the controller may be the nerve center and command center of the electronic device 300. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions. A memory may also be set in the processor 301 for storing instructions and data. In some embodiments, the memory in the processor 301 is a high-speed cache memory. The memory may store instructions or data that the processor 301 has just used or circulated. If the processor 301 needs to use the instruction or data again, it may be directly called from the memory. Repeated access is avoided, the waiting time of the processor 301 is reduced, and the efficiency of the system is improved.

[0090] The processor 301 can run the method provided in the embodiment of the present application. The processor 301 can include different devices. For example, when a CPU and a GPU are integrated, the CPU and the GPU can cooperate to execute the method provided in the embodiment of the present application, for example, part of the algorithm in the method is executed by the CPU, and another part of the algorithm is executed by the GPU to obtain faster processing efficiency.

[0091] The bus 302 may include a path to transmit information between the above components. The bus 302 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 302 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0092] The memory 303 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), or may include a high-speed random access memory, or may include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this.

[0093] Optionally, the memory 303 is used to store application code for executing the solution of the present application, and the execution is controlled by the processor 301. The processor 301 is used to execute the application code stored in the memory 303 to implement the method provided in any embodiment of the present application.

[0094] The memory 303 can be used to store computer executable program codes, which include instructions. The processor 301 executes various functional applications and data processing of the electronic device 300 by running the instructions stored in the memory 303. The memory 303 may include a program storage area and a data storage area. Among them, the program storage area may store the code of the operating system, application program, etc. The data storage area may store data created during the use of the electronic device 300 (such as images, videos, etc. collected by the camera application), etc.

[0095] The memory 303 may also store one or more computer programs corresponding to the method provided in the embodiment of the present application. The one or more computer programs are stored in the above-mentioned memory 303 and are configured to be executed by the one or more processors 301. The one or more computer programs include instructions, and the above-mentioned instructions can be used to execute each step in the above-mentioned corresponding embodiment.

[0096] Of course, the code of the method provided in the embodiment of the present application can also be stored in an external memory. In this case, the processor 301 can run the code of the method stored in the external memory through the external memory interface, and the processor 301 can control the running process.

[0097] The display screen 305 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 300 may include 1 or N display screens 305, where N is a positive integer greater than 1. The display screen 305 can be used to display information input by a user or information provided to a user and various graphical user interfaces (GUI). For example, the display screen 305 can display photos, videos, web pages, or files.

[0098] The electronic device provided in the embodiment of the present application is applicable to any embodiment of the above method. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, which will not be repeated here.

[0099] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0100] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A system that specifies the functions of a box or multiple boxes.

[0101] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction system, which is implemented in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0102] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in a box or multiple boxes. Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they know the basic creative concept. Therefore, the attached claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0103] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for storing and loading a Web resource offline package, characterized in that: include: S1. Obtain the latest offline resource compressed package from the server, and decompress the latest offline resource compressed package to obtain offline resource files; S2 encrypts the JavaScript file in the offline resource file, generates an encrypted JavaScript file and stores it; S3. Maintain the mapping table between the name of the JavaScript file in the offline resource file and the encrypted JavaScript file; S4. Based on the mapping relationship table, the encrypted JavaScript file is queried and decrypted, and the JavaScript file is loaded and returned.

2. The method according to claim 1, characterized in that Before obtaining the latest resource offline compressed package from the server and decompressing the latest resource offline compressed package to obtain the offline resource file, the method further includes: Request the latest resource offline compressed package list from the server, compare it with the local resource offline compressed package list, and update the latest resource offline compressed package.

3. The method according to claim 1, characterized in that The step of encrypting the JavaScript file in the offline resource file, generating and storing the encrypted JavaScript file includes: Determine whether there is a JavaScript file in the offline resource file; If there is no JavaScript file in the offline resource file, directly delete the corresponding offline compressed package; If there is a JavaScript file in the offline resource file, traverse the JavaScript file set and load the JavaScript file stream; If there is a JavaScript file in the offline resource file, traversing the JavaScript file set and loading the JavaScript file stream further includes: Determine whether the size of the JavaScript file stream is greater than a preset threshold; If the size of the JavaScript file stream is greater than the preset threshold, the preset threshold is used as the minimum unit, the JavaScript file stream is split based on the minimum unit and encrypted, and an encrypted JavaScript file is generated and stored; If the size of the JavaScript file stream is not greater than the preset threshold, the JavaScript file stream is directly encrypted to generate and store an encrypted JavaScript file.

4. The method according to claim 1, characterized in that After maintaining the mapping relationship table between the name of the JavaScript file in the offline resource file and the encrypted JavaScript file, the method includes: Delete the corresponding JavaScript file; Delete the corresponding offline compressed package.

5. The method according to claim 1, characterized in that Before querying the encrypted JavaScript file based on the mapping relationship table, the method includes: Determine whether the offline resource to be loaded is a JavaScript file resource; If the offline resource to be loaded is a JavaScript file resource, query the corresponding encrypted JavaScript file from the mapping relationship table and decrypt it; If the offline resource to be loaded is not a JavaScript file resource, the resource data is returned directly.

6. The method according to claim 5, characterized in that If the offline resource to be loaded is a JavaScript file resource, querying the corresponding encrypted JavaScript file from the mapping relationship table and decrypting it includes: Determine the number of encrypted JavaScript files; When the encrypted JavaScript file is a single one, the encrypted JavaScript file is directly decrypted and the JavaScript file data is returned; When there are multiple encrypted JavaScript files, the thread pool is started to call multiple threads to decrypt the encrypted JavaScript files, assemble them into original JavaScript files, and return JavaScript file data.

7. A Web resource offline package storage and loading system, characterized in that: include: An acquisition module is used to acquire an offline compressed package of the latest resource from a server, and decompress the offline compressed package of the latest resource to obtain an offline resource file; An encryption module, used to encrypt the JavaScript file in the offline resource file, generate an encrypted JavaScript file and store it; A maintenance module, used to maintain a mapping relationship table between the name of the JavaScript file in the offline resource file and the encrypted JavaScript file; The loading module is used to query the encrypted JavaScript file based on the mapping relationship table and decrypt it, and load and return the JavaScript file.

8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

9. An electronic device, characterized in that: including a processor and a memory; The memory is used to store program instructions; The processor is configured to execute the method according to any one of claims 1 to 6 by calling program instructions.

10. A computer program product comprising a computer program and / or instructions, characterized in that: When the computer program and / or the instructions are executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Packing method and unpacking method for resource files

    CN106022014A

  • File encryption and decryption method and device

    CN111611606A

  • Data processing method and apparatus, system, server, and electronic device

    CN112889055A

  • Security implementation within a browser

    US20100223456A1