A full-disk file packing and decryption method and system

By using a full-disk file packaging encryption and decryption method, and employing recursive traversal and interference number linked list techniques, the security and efficiency issues in data transmission are solved, achieving fast encryption and decryption, and making it suitable for data protection in various application scenarios.

CN116800411BActive Publication Date: 2026-05-12SHANDONG SINOCHIP SEMICON CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANDONG SINOCHIP SEMICON CO LTD
Filing Date
2023-04-06
Publication Date
2026-05-12

Smart Images

  • Figure CN116800411B_ABST
    Figure CN116800411B_ABST
Patent Text Reader

Abstract

The application provides a full-disk file packing encryption and decryption method and system, and belongs to the technical field of data encryption. The application encrypts all data in a folder into a ciphertext file by defining a packing encryption rule, and adds certain interference numbers in the encryption process according to the rule, so that the difficulty of file cracking is greatly increased; the ciphertext file can be decrypted and restored according to the rule by using a matched decryption software tool. The application has the beneficial effects of good reliability and high security strength.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method and system for encrypting and decrypting full-disk files, belonging to the field of data encryption technology. Background Technology

[0002] With the widespread use of the internet, more and more people are choosing to transmit data online. While this is convenient, it also significantly increases the risk of data breaches. For organizations and individuals handling confidential information, data leaks can lead to incalculable losses. Therefore, in certain situations, secure storage devices (such as secure USB drives) are often used for data transfer. However, if the password is lost, the data will be at risk of being leaked.

[0003] In addition, traditional full-disk encryption methods encrypt data across the entire disk's capacity, which is extremely inefficient when storing a small number of files. Therefore, a method is needed that can encrypt all files on the entire removable storage medium, or encrypt a single specified folder, while also offering high security, speed, and efficiency. Summary of the Invention

[0004] The purpose of this invention is to provide a method for encrypting and decrypting all files on a single disk. By adding a certain number of interference numbers according to rules, the difficulty of cracking the files is greatly increased, and the encryption speed is fast and efficient.

[0005] To achieve the above objectives, the present invention employs the following technical solution:

[0006] A method for encrypting and decrypting full-disk files includes an encryption process and a decryption process. The specific steps of the encryption process are as follows:

[0007] Step 1: Recursively traverse the target folder, store the traversed directory tree information in a directory tree linked list defined by rules, and obtain file information, including the number and size of files;

[0008] Step 2: Obtain a random number from the USB cryptographic module and request a set of key ID numbers;

[0009] Step 3: Determine the number of interferences based on the obtained file information, generate N sets of interference data blocks of different sizes, and form an interference number linked list;

[0010] Step 4: Initialize the USB cryptographic module. Use the random number and the key corresponding to the key ID to form the real key for encryption and initialize the encryption algorithm.

[0011] Step 5: Generate a 512-byte ciphertext file header and store the interference number linked list into the ciphertext file;

[0012] Step 6: Start the encryption process, encrypt the data in the folder, randomly insert interference numbers during encryption, update the interference number linked list, and record the position of each interference number segment;

[0013] Step 7: Complete encryption and generate the final ciphertext file;

[0014] The specific steps of the decryption process are as follows:

[0015] Step 1: Obtain the encrypted file, parse the file header to confirm whether it has been tampered with. If it has not been tampered with, obtain the key ID and random number, and initialize the USB cryptographic module.

[0016] Step 2: Parse the interference number linked list, extract the file tree linked list based on the interference number linked list, decrypt the file linked list, and restore the file tree.

[0017] Step 3: Decrypt the first root file data packet, find the next position in the linked list, decrypt the data packet, restore the entire file tree, search the interference number list in real time to discard interference number data blocks, calculate the correct file header offset, and form the file tree directory.

[0018] Step 4: Select either full decryption or single file decryption based on the file tree directory. Reverse decrypt the encryption algorithm to extract the ciphertext data, and send the ciphertext data to the USB password module. Decryption is complete.

[0019] Preferably, each block of the interference number is 512 bytes, and the size of the interference number is N×512, where N is a random number ranging from 1 to 2048.

[0020] Preferably, the random number obtained from the USB password module is 32 bytes.

[0021] Preferably, the specific method for confirming whether the encrypted file has been tampered with during the decryption process is as follows: read the first 512 bytes of the encrypted file and perform a CRC check to determine whether the CRC check values ​​are consistent. If the CRC check values ​​are consistent, then the encrypted file has not been tampered with.

[0022] Preferably, the ciphertext file structure includes a 512-byte header, a linked list of interference numbers, ciphertext with interference data blocks, and the end of the file.

[0023] A full-disk file packaging encryption and decryption system includes an encryption / decryption host and a USB password module.

[0024] The encryption / decryption host can run encryption / decryption algorithms to encrypt and decrypt target files.

[0025] The USB cryptographic module is used to manage keys and generate random numbers, and to store encrypted ciphertext files.

[0026] The advantages of this invention are as follows: By mapping all data on the hard drive into a single folder during the encryption process, it facilitates the management of encrypted files and also supports encryption of individual folders, meeting various application scenarios. During the packaging process, random interference numbers are inserted, significantly increasing the difficulty of cracking the files and improving security. It features high reliability and strong security. Attached Figure Description

[0027] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof.

[0028] Figure 1 This is a schematic diagram of the encryption process of the present invention.

[0029] Figure 2 This is a schematic diagram of the decryption and restoration process of the present invention.

[0030] Figure 3 This is a schematic diagram of the file tree and encrypted storage structure of the present invention. Detailed Implementation

[0031] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0032] Example 1

[0033] A method for encrypting and decrypting full-disk files includes an encryption process and a decryption process. The specific steps of the encryption process are as follows:

[0034] Step 1: Recursively traverse the target folder, store the traversed directory tree information in a directory tree linked list defined by rules, and obtain file information, including the number and size of files.

[0035] Step 2: Obtain a 32-byte random number from the USB cryptographic module and request a set of key ID numbers.

[0036] Step 3: Determine the number of interference numbers based on the obtained file information, generate N sets of interference data blocks of different sizes, and form an interference number linked list; each interference block is 512 bytes, and the size of the interference number is N×512, where N is a random number ranging from 1 to 2048.

[0037] Step 4: Initialize the USB cryptographic module. Use the random number and the key corresponding to the key ID to form the real key for encryption and initialize the encryption algorithm.

[0038] Step 5: Generate a 512-byte ciphertext file header and store the interference number linked list into the ciphertext file.

[0039] Step 6: Start the encryption process, encrypt the data in the folder, randomly insert interference numbers during encryption, update the interference number linked list, and record the position of each interference number segment.

[0040] Step 7: Complete encryption and generate the final ciphertext file; the ciphertext file structure includes a 512-byte header, a chain of interference numbers, ciphertext with interference data blocks, and the end of the file.

[0041] The specific steps of the decryption process are as follows:

[0042] Step 1: Obtain the encrypted file, parse the file header to confirm whether it has been tampered with, read the first 512 bytes of the encrypted file for CRC check, and determine whether the CRC check values ​​are consistent. If the CRC check values ​​are consistent, the encrypted file has not been tampered with; if it has not been tampered with, obtain the key ID and random number, and initialize the USB cryptographic module.

[0043] Step 2: Parse the interference number linked list, extract the file tree linked list based on the interference number linked list, decrypt the file linked list, and restore the file tree.

[0044] Step 3: Decrypt the first root file data packet, find the next position in the linked list, decrypt the data packet, restore the entire file tree, search the interference number list in real time to discard interference number data blocks, calculate the correct file header offset, and form the file tree directory.

[0045] Step 4: Select either full decryption or single file decryption based on the file tree directory. Reverse decrypt the encryption algorithm to extract the ciphertext data, and send the ciphertext data to the USB password module. Decryption is complete.

[0046] Example 2

[0047] A full-disk file packaging encryption and decryption system includes an encryption / decryption host and a USB password module; the encryption / decryption host can run encryption and decryption algorithms to encrypt and decrypt target files; the USB password module is used to manage keys and generate random numbers, and store encrypted ciphertext files.

[0048] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for encrypting and decrypting all files on a single disk, characterized in that, The process includes encryption and decryption. The specific steps of the encryption process are as follows: Step 1: Recursively traverse the target folder, store the traversed directory tree information in a directory tree linked list defined by rules, and obtain file information, including the number and size of files; Step 2: Obtain a random number from the USB cryptographic module and request a set of key ID numbers; Step 3: Determine the number of interferences based on the obtained file information, generate N sets of interference data blocks of different sizes, and form an interference number linked list; Step 4: Initialize the USB cryptographic module. Use the random number and the key corresponding to the key ID to form the real key for encryption and initialize the encryption algorithm. Step 5: Generate a 512-byte ciphertext file header and store the interference number linked list into the ciphertext file; Step 6: Start the encryption process, encrypt the data in the folder, randomly insert interference numbers during encryption, update the interference number linked list, and record the position of each interference number segment; Step 7: Complete encryption and generate the final ciphertext file; The specific steps of the decryption process are as follows: Step 1: Obtain the encrypted file, parse the file header to confirm whether it has been tampered with. If it has not been tampered with, obtain the key ID and random number, and initialize the USB cryptographic module. Step 2: Parse the interference number linked list, extract the file tree linked list based on the interference number linked list, decrypt the file linked list, and restore the file tree; Step 3: Decrypt the first root file data packet, find the next position of the linked list, decrypt the data packet, restore the entire file tree, search the interference number list in real time to discard interference number data blocks, calculate the correct file header offset, and form the file tree directory. Step 4: Select either full decryption or single file decryption based on the file tree directory. Reverse decrypt the encryption algorithm to extract the ciphertext data, and send the ciphertext data to the USB password module. Decryption is complete.

2. The method for encrypting and decrypting full-disk files according to claim 1, characterized in that, Each block of the interference number is 512 bytes, and the size of the interference number is N×512, where N is a random number ranging from 1 to 2048.

3. The method for encrypting and decrypting full-disk files according to claim 1, characterized in that, The random number obtained from the USB password module is 32 bytes.

4. The method for encrypting and decrypting full-disk files according to claim 1, characterized in that, The specific method for confirming whether the encrypted file has been tampered with during the decryption process is as follows: Read the first 512 bytes of the encrypted file and perform a CRC check to determine whether the CRC check values ​​are consistent. If the CRC check values ​​are consistent, then the encrypted file has not been tampered with.

5. The method for encrypting and decrypting full-disk files according to claim 1, characterized in that, The ciphertext file structure includes a 512-byte header, a linked list of interference numbers, ciphertext with interference data blocks, and the end of the file.

6. A full-disk file packaging and encryption / decryption system, characterized in that, The full-disk file packaging encryption and decryption method described in any one of claims 1-5 can be used, including an encryption / decryption host and a USB password module; The encryption / decryption host can run encryption / decryption algorithms to encrypt and decrypt target files; The USB cryptographic module is used to manage keys and generate random numbers, and to store encrypted ciphertext files.