Method and system for encrypting zip file

By using asymmetric encryption algorithm and combination technology of data block numbering and random arrangement in the ZIP file encryption method, the problem that traditional ZIP file encryption methods are vulnerable to known plaintext attacks is solved, and higher data security and integrity are achieved.

CN119939611APending Publication Date: 2025-05-06FUJIAN TQ ONLINE INTERACTIVE INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311457270.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-03
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

Traditional ZIP file encryption methods use weaker encryption algorithms and are vulnerable to known plaintext attacks, thus failing to provide high enough data security.

Method used

Asymmetric encryption algorithm is used to combine data block numbering and random arrangement. The specific steps include reading the initial ZIP file, encrypting the data area, numbering and random arrangement of data blocks, increasing file header storage bytes, and saving the encrypted ZIP file.

Benefits of technology

Improve the security of ZIP files, prevent known plaintext attacks, enhance the confidentiality and integrity of data, and meet the needs of modern data security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119939611A_ABST
    Figure CN119939611A_ABST
Patent Text Reader

Abstract

The invention relates to a zip file encryption method and system, and the method comprises the steps: reading an initial zip file, and obtaining three data blocks, including a data area, a directory area and a directory end mark; encrypting the data area to obtain an encrypted data area; numbering the encrypted data area, the directory area and the directory end mark; randomly arranging the encrypted data area, the directory area and the directory end mark according to the serial numbers to generate a new zip file, and obtaining a serial number string according to the serial number sequence; adding storage bytes to a file header of the new zip file; the zip file added with the storage bytes is stored, known plaintext attacks can be prevented, the confidentiality and integrity of data are improved, and the requirement for modern data security can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of data security, in particular to a zip file encryption method and system thereof. Background Art

[0002] ZIP file is a common file compression and archive format, and has become one of the standard formats for many operating systems and applications. ZIP file allows users to pack multiple files and folders into a single ZIP archive file, thereby reducing the file size and facilitating transmission and storage; traditional ZIP file encryption methods use weak encryption algorithms, usually based on the standard Zip 2.0 encryption method, which requires users to provide a password, and then uses the CRC32 checksum algorithm to mix the password, random seed and file content together to create an encrypted data block.

[0003] The disadvantage of the prior art is that the traditional ZIP file encryption method adopts a weak encryption algorithm, which is vulnerable to the threat of known plaintext attacks and thus cannot provide sufficiently high data security. Summary of the invention

[0004] In order to overcome the problem that the ZIP file encryption method in the prior art adopts a weak encryption algorithm and is easily threatened by known plaintext attacks, thereby failing to provide sufficiently high data security, the purpose of the present invention is to provide a zip file encryption method and system thereof, which can ensure absolute confidentiality and integrity of data.

[0005] The present invention is implemented by the following scheme:

[0006] A method for encrypting a zip file, the method steps are as follows:

[0007] Step 1: Read the initial zip file and obtain three data blocks, including the data area, directory area and directory end mark;

[0008] Step 2: Encrypt the data area to obtain an encrypted data area;

[0009] Step 3: Number the encrypted data area, directory area and directory end mark;

[0010] Step 4: Randomly arrange the encrypted data area, directory area and directory end mark according to the number, generate a new zip file, and obtain a serial number string according to the number sequence;

[0011] Step 5: Add storage bytes to the header of the new zip file;

[0012] Step 6: Save the zip file with increased storage bytes.

[0013] Furthermore, step 2 is further specified as follows: encrypting the data area of ​​the initial zip file using an asymmetric encryption algorithm and a public key.

[0014] Furthermore, step 3 is further specified as follows: the encrypted data area, the directory area and the directory end mark are numbered by Arabic numerals.

[0015] Furthermore, step 4 is further specified as follows: using a random algorithm to arrange the number of the encrypted data area, the number of the directory area and the number of the directory end mark to obtain a serial number string, and the encrypted data area, the directory area and the directory end mark generate a new zip file according to the order of the serial number string.

[0016] Furthermore, step 5 is further specified as follows: the storage bytes are divided into 13 bytes, and the 13 bytes are used to store the serial number string, the encrypted data area, the directory area and the directory end mark, wherein 1 byte is used to store the serial number string, 4 bytes store the size of the encrypted data area, 4 bytes store the size of the directory area, and 4 bytes store the size of the directory end mark.

[0017] Furthermore, it also includes a decryption process, which is: reading the zip file in step 6, parsing the file header of the zip file to obtain the serial number string, the encrypted data area size, the directory area size and the directory end mark size, extracting the encrypted data area, the directory area and the directory end mark according to the serial number string and the encrypted data area size, the directory area size and the directory end mark size, creating a private key, using an asymmetric decryption algorithm and the private key to decrypt the encrypted data area to obtain the original data area, and sequentially composing the original data area, the directory area and the directory end mark into an initial zip file, and saving the initial zip file locally.

[0018] A zip file encryption system, the system comprising: a reading module, a data area encryption module, a numbering module, an arrangement module, a file header encryption module, and a storage module;

[0019] The reading module is used to read the initial zip file and obtain three data blocks, including a data area, a directory area and a directory end mark;

[0020] The data area encryption module is used to encrypt the data area to obtain an encrypted data area;

[0021] The numbering module is used to number the encrypted data area, the directory area and the directory end mark;

[0022] The arrangement module is used to randomly arrange the encrypted data area, the directory area and the directory end mark according to the numbering, generate a new zip file, and obtain a sequence number string according to the numbering sequence;

[0023] The file header encryption module is used to increase storage bytes in the file header of the new zip file;

[0024] The storage module is used to store the zip file after the storage bytes are increased.

[0025] Furthermore, the data area encryption module is further specifically: using an asymmetric encryption algorithm and a public key to encrypt the data area of ​​the initial zip file.

[0026] Furthermore, the numbering module is further specified as follows: the encrypted data area, the directory area and the directory end mark are numbered by Arabic numerals.

[0027] Furthermore, the arrangement module is further specified as follows: using a random algorithm to arrange the number of the encrypted data area, the number of the directory area and the number of the directory end mark to obtain a serial number string, and the encrypted data area, the directory area and the directory end mark generate a new zip file according to the order of the serial number string.

[0028] Furthermore, the file header encryption module is further specified as follows: the storage bytes are divided into 13 bytes, and the 13 bytes are used to store the serial number string, the encrypted data area, the directory area and the directory end mark, wherein 1 byte is used to store the serial number string, 4 bytes store the size of the encrypted data area, 4 bytes store the size of the directory area, and 4 bytes store the size of the directory end mark.

[0029] Furthermore, it also includes a decryption module, which first reads the encrypted zip file in the storage module, parses the file header of the zip file to obtain the serial number string, the encrypted data area size, the directory area size and the directory end mark size, extracts the encrypted data area, the directory area and the directory end mark according to the serial number string and the encrypted data area size, the directory area size and the directory end mark size, creates a private key, uses an asymmetric decryption algorithm and the private key to decrypt the encrypted data area to obtain the original data area, and sequentially composes the original data area, directory area and directory end mark into an initial zip file, and saves the initial zip file locally.

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

[0031] The present invention provides a zip file encryption method and system thereof, which combines asymmetric encryption with data block numbering and random arrangement to improve the security of ZIP files, can prevent known plaintext attacks, improve the confidentiality and integrity of data, and meet the needs of modern data security. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 is a flow chart of the method of the present invention;

[0033] Figure 2It is a structural block diagram of the system of the present invention. DETAILED DESCRIPTION

[0034] The present invention will be further described below in conjunction with the accompanying drawings.

[0035] See also Figure 1 , a zip file encryption method, the method steps are as follows:

[0036] Step 1: Read the initial zip file and obtain three data blocks, including the data area, directory area and directory end mark;

[0037] Step 2: Encrypt the data area to obtain an encrypted data area;

[0038] Step 3: Number the encrypted data area, directory area and directory end mark;

[0039] Step 4: Randomly arrange the encrypted data area, directory area and directory end mark according to the number, generate a new zip file, and obtain a serial number string according to the number sequence;

[0040] Step 5: Add storage bytes to the header of the new zip file;

[0041] Step 6: Save the zip file with increased storage bytes.

[0042] The present invention will be further described below in conjunction with a specific embodiment:

[0043] A method for encrypting a zip file, the method being as follows:

[0044] (1) Reading the original ZIP file: The encryption module reads the Demo.zip file and obtains three data blocks, namely, the data area A, the directory area B, and the directory end mark C. The sizes of these three data blocks are 100, 200, and 300 bytes respectively.

[0045] (2) Data area encryption: Use the RSA algorithm and public key P to encrypt data area A to obtain an encrypted data area D, whose size is 200 bytes.

[0046] (3) Data block numbering: The directory area B is numbered 1, the directory end mark C is numbered 2, and the encrypted data area D is numbered 3.

[0047] (4) Randomly arrange the data blocks: Use a random algorithm to arrange the numbers of the data blocks and obtain the serial number string 213. According to the order of the serial number string, the data blocks are arranged in the order of C, B, and D to generate a new file (DemoEncrypt.zip).

[0048] (5) Add file header: Add 13 bytes of header information to the head of the DemoEncrypt.zip file, of which 1 byte stores the serial number string 213, 4 bytes store the size of directory area C (300), 4 bytes store the size of directory area B (200), and 4 bytes store the size of encrypted data area D (200).

[0049] Save encrypted file: The encryption module saves the newly generated DemoEncrypt.zip file to the local file system. This file contains the encrypted data and the corresponding header information.

[0050] Taking the DemoEncrypt.zip encrypted file generated above as an example, it is explained how to restore the encrypted file to Demo.zip through the decryption module.

[0051] (1) Read the encrypted ZIP file: Read the DemoEncrypt.zip file.

[0052] (2) Parse the file header: Read the 13-byte header from the beginning of DemoEncrypt.zip, and then read the 1, 4, 4, and 4 bytes from the header in sequence.

[0053] (3) Extracting data blocks: From the header, we can get the serial number string 213, which shows that the data blocks are arranged in the order of C, B, and D. Based on the size of the data blocks, we can extract three data blocks from DemoEncrypt.zip: the directory end mark C, the directory area B, and the encrypted data area D.

[0054] (4) Decrypt the data area: Create a private key S corresponding to the public key P, use the RSA algorithm and private key S to decrypt the encrypted data area D (data block D) to obtain the original data area A.

[0055] (5) Reconstruct the ZIP file: The data area A (data block A), directory area B (data block B) and directory end mark C (data block C) are sequentially combined into a new ZIP file Demo.zip.

[0056] (6) Save the decrypted file: Save the Demo.zip file to a local file.

[0057] See also Figure 2 , a zip file encryption system, the system comprising: a reading module, a data area encryption module, a numbering module, an arrangement module, a file header encryption module and a storage module;

[0058] The reading module is used to read the initial zip file and obtain three data blocks, including a data area, a directory area and a directory end mark;

[0059] The data area encryption module is used to encrypt the data area to obtain an encrypted data area;

[0060] The numbering module is used to number the encrypted data area, the directory area and the directory end mark;

[0061] The arrangement module is used to randomly arrange the encrypted data area, the directory area and the directory end mark according to the numbering, generate a new zip file, and obtain a sequence number string according to the numbering sequence;

[0062] The file header encryption module is used to increase storage bytes in the file header of the new zip file;

[0063] The storage module is used to store the zip file after the storage bytes are increased.

[0064] In one embodiment of the present invention, the data area encryption module is further specifically: using an asymmetric encryption algorithm and a public key to encrypt the data area of ​​the initial zip file.

[0065] In one embodiment of the present invention, the numbering module is further specified as follows: the encrypted data area, the directory area and the directory end mark are numbered by Arabic numerals.

[0066] In one embodiment of the present invention, the arrangement module is further specified as follows: using a random algorithm to arrange the number of the encrypted data area, the number of the directory area and the number of the directory end mark to obtain a serial number string, and the encrypted data area, the directory area and the directory end mark generate a new zip file according to the order of the serial number string.

[0067] In one embodiment of the present invention, the file header encryption module is further specified as follows: the storage bytes are divided into 13 bytes, and the 13 bytes are used to store the size of the serial number string, the encrypted data area, the directory area and the directory end mark, wherein 1 byte is used to store the serial number string, 4 bytes store the size of the encrypted data area, 4 bytes store the size of the directory area, and 4 bytes store the size of the directory end mark.

[0068] In one embodiment of the present invention, it also includes a decryption module, which first reads the encrypted zip file in the storage module, parses the file header of the zip file to obtain the serial number string, the encrypted data area size, the directory area size and the directory end mark size, extracts the encrypted data area, the directory area and the directory end mark according to the serial number string and the encrypted data area size, the directory area size and the directory end mark size, creates a private key, uses an asymmetric decryption algorithm and the private key to decrypt the encrypted data area to obtain the original data area, and sequentially composes the original data area, directory area and directory end mark into an initial zip file, and saves the initial zip file locally.

[0069] In summary, the present invention provides a zip file encryption method and system thereof, which combines asymmetric encryption with data block numbering and random arrangement to improve the security of ZIP files, prevent known plaintext attacks, improve the confidentiality and integrity of data, and meet the needs of modern data security.

[0070] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.

Claims

1. A method for encrypting a zip file, characterized in that: The method steps are as follows: Step 1: Read the initial zip file and obtain three data blocks, including the data area, directory area and directory end mark; Step 2: Encrypt the data area to obtain an encrypted data area; Step 3: Number the encrypted data area, directory area and directory end mark; Step 4: Randomly arrange the encrypted data area, directory area and directory end mark according to the number, generate a new zip file, and obtain a serial number string according to the number sequence; Step 5: Add storage bytes to the header of the new zip file; Step 6: Save the zip file with increased storage bytes.

2. A zip file encryption method according to claim 1, characterized in that: Step 2 is further specifically as follows: encrypting the data area of ​​the initial zip file using an asymmetric encryption algorithm and a public key.

3. A zip file encryption method according to claim 1, characterized in that: Step 3 is further specified as follows: the encrypted data area, directory area and directory end mark are numbered by Arabic numerals.

4. A zip file encryption method according to claim 1, characterized in that: Step 4 is further specified as follows: using a random algorithm to arrange the number of the encrypted data area, the number of the directory area and the number of the directory end mark to obtain a serial number string, and generating a new zip file according to the order of the serial number string for the encrypted data area, the directory area and the directory end mark.

5. A zip file encryption method according to claim 1, characterized in that: Step 5 is further specified as follows: the storage bytes are divided into 13 bytes, and the 13 bytes are used to store the size of the serial number string, the encrypted data area, the directory area and the directory end mark, wherein 1 byte is used to store the serial number string, 4 bytes store the size of the encrypted data area, 4 bytes store the size of the directory area, and 4 bytes store the size of the directory end mark.

6. A zip file encryption method according to claim 1, characterized in that: The method further includes a decryption process, which comprises: reading the zip file in step 6, parsing the file header of the zip file to obtain a serial number string, an encrypted data area size, a directory area size, and a directory end mark size, extracting the encrypted data area, the directory area, and the directory end mark according to the serial number string and the encrypted data area size, the directory area size, and the directory end mark size, creating a private key, decrypting the encrypted data area using an asymmetric decryption algorithm and the private key to obtain the original data area, sequentially composing the original data area, the directory area, and the directory end mark into an initial zip file, and saving the initial zip file locally.

7. A zip file encryption system, characterized in that: The system comprises: a reading module, a data area encryption module, a numbering module, an arrangement module, a file header encryption module and a storage module; The reading module is used to read the initial zip file and obtain three data blocks, including a data area, a directory area and a directory end mark; The data area encryption module is used to encrypt the data area to obtain an encrypted data area; The numbering module is used to number the encrypted data area, the directory area and the directory end mark; The arrangement module is used to randomly arrange the encrypted data area, the directory area and the directory end mark according to the numbering, generate a new zip file, and obtain a sequence number string according to the numbering sequence; The file header encryption module is used to increase storage bytes in the file header of the new zip file; The storage module is used to store the zip file after the storage bytes are increased.

8. A zip file encryption system according to claim 7, characterized in that: The data area encryption module is further specifically: using an asymmetric encryption algorithm and a public key to encrypt the data area of ​​the initial zip file.

9. A zip file encryption system according to claim 7, characterized in that: The numbering module is further specified as follows: the encrypted data area, the directory area and the directory end mark are numbered by Arabic numerals.

10. A zip file encryption system according to claim 7, characterized in that: The arrangement module is further specified as follows: using a random algorithm to arrange the number of the encrypted data area, the number of the directory area and the number of the directory end mark to obtain a sequence string, and the encrypted data area, the directory area and the directory end mark generate a new zip file according to the order of the sequence string.

11. A zip file encryption system according to claim 7, characterized in that: The file header encryption module is further specified as follows: the storage bytes are divided into 13 bytes, and the 13 bytes are used to store the size of the serial number string, the encrypted data area, the directory area and the directory end mark, among which 1 byte is used to store the serial number string, 4 bytes store the size of the encrypted data area, 4 bytes store the size of the directory area, and 4 bytes store the size of the directory end mark.

12. A zip file encryption system according to claim 7, characterized in that: The method also includes a decryption module, which first reads the encrypted zip file in the storage module, parses the file header of the zip file to obtain a serial number string, an encrypted data area size, a directory area size and a directory end mark size, extracts the encrypted data area, the directory area and the directory end mark according to the serial number string and the encrypted data area size, the directory area size and the directory end mark size, creates a private key, uses an asymmetric decryption algorithm and the private key to decrypt the encrypted data area to obtain the original data area, sequentially composes the original data area, the directory area and the directory end mark into an initial zip file, and saves the initial zip file locally.