A file processing method, device, server, equipment and storage medium
By dividing the file into multiple fragmented data streams and dynamically adjusting its size according to the memory space for hash value calculation, it solves the problem of memory usage and calculation failure caused by excessively large files, and reduces the need for physical storage by uploading while calculating. dependence, improving file processing efficiency and resource utilization.
Patent Information
- Application Number
- CN201911223078.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-12-03
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2039-12-03
AI Technical Summary
In cloud storage, when the file is too large, the local device needs to occupy a large amount of memory space for hash value calculation, resulting in long calculation time and calculation failure when there is insufficient memory. Moreover, encrypted file processing relies on physical storage space, which can easily lead to cache failure and resource waste. .
Divide the file into multiple fragmented data streams, dynamically adjust the fragment size according to the available local memory space, read and calculate hash values one by one, avoid relying on excessive memory space, and upload while calculating during encryption processing, reducing Dependence on physical storage.
It improves file processing efficiency, avoids excessive occupation of memory and storage space, ensures the success rate of hash value calculation and encryption processing, and reduces resource occupation and operational complexity.
Smart Images

Figure CN112905542B
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a file processing method, device, equipment and storage medium, and a file verification method and server based on hash verification. Background Art
[0002] Cloud storage is an online storage model that stores data on multiple virtual servers hosted by a third party. The party that needs data storage can meet its data storage needs by leasing storage space from the third party. Since cloud storage can meet the access speed and real-time data access of the front-end server or database, it has been recognized and applied by more and more users.
[0003] For local devices, when uploading files to cloud storage, it is necessary to calculate the hash value of the entire file content and upload it to the cloud storage, which will store the hash value to verify the integrity of the uploaded file. When the local device calculates the hash value of the entire file content, it needs to occupy the memory space corresponding to the file. The larger the file, the more memory space is required, and the longer the calculation wait time is. If the local device does not have enough memory space, the hash value calculation of the entire file will fail.
[0004] In addition, due to the hosted storage of files and in order to ensure the security of data, when using storage services, the service itself will usually encrypt the files before uploading them. The encrypted file processing process will temporarily occupy the device's memory space and physical storage space. Summary of the invention
[0005] The embodiments of the present application provide a file processing method, apparatus, device, storage medium, and a file verification method and server based on hash verification, which avoid occupying too much memory space when the entire file is too large, and avoid the problem of failure in calculating the hash value of the entire file when the memory space of the local device is insufficient, thereby improving the processing efficiency of the entire file.
[0006] In the first aspect, the embodiment of the present application provides a file processing method, which can read the 1st file shard data stream to the Nth file shard data stream from the file to be processed into the local memory, calculate the hash value of each file shard data stream one by one, and iterate in sequence to obtain the complete hash value of the file to be processed. In the prior art, when the file to be processed is too large, if the local memory space is sufficient, it will load the file to be processed into the local memory at one time for hash value calculation. At this time, the file to be processed will occupy a large memory space and the time to wait for the hash value calculation will be long. If the memory space of the local memory is insufficient, the hash value calculation of the file to be processed will fail, until the used memory space of the local memory is released, and then all the files to be processed will be read into the local memory for hash value calculation, which will slow down the processing efficiency of the entire file to be processed.
[0007] Therefore, the technical solution disclosed in the embodiment of the present application is adopted, which segments the entire file to be processed into multiple file segment data streams, and the sizes of the multiple file segment data streams are implemented based on the available memory space of the local memory. When each file segment data stream is read into the local memory in turn for iterative calculation of the hash value, it does not rely on an excessively large local memory space, and can meet the memory requirements of each file segment data stream when performing hash calculation in the local memory, thereby avoiding file loading and hash value calculation failure.
[0008] A file processing method disclosed in an embodiment of the present application specifically includes:
[0009] Reading a first file segment data stream of the file to be processed from the file to be processed into a local memory, and calculating a first hash value of the first file;
[0010] Perform loop processing, read the mth file shard data stream into the local memory in sequence, and calculate the mth hash value based on the m-1th hash value and the mth file shard data stream, wherein m is an integer from 2 to N in sequence, until the calculation for the Nth file shard data stream is completed, so as to obtain the Nth hash value as the complete hash value of the file to be processed, wherein the first file shard data stream to the Nth file shard data stream constitute the complete file of the file to be processed, N is an integer not less than 2, and m is an integer from 2 to N in sequence;
[0011] Based on the complete hash value, the processing of the to-be-processed file is completed.
[0012] In a possible implementation of the first aspect described above, the method for processing files may be a ciphertext data stream method and a file upload method, wherein the method for uploading files may be divided into unencrypted upload and encrypted upload.
[0013] In a possible implementation of the first aspect above, when the file to be processed is uploaded without encryption, the size of the available memory space of the local memory is first monitored in real time, and then, based on the size of the available memory space, the first file segment data stream whose data stream size does not exceed the size of the available memory space is read from the file to be processed into the local memory, and after completing the hash value calculation of the first file segment data stream, the hash value of the first file segment data stream is temporarily cached in the local memory, and after completing the hash value calculation of the first file segment data stream, the first file segment data stream is released from the local memory, and then, based on the size of the available memory space of the local memory, the second file segment data stream is read from the file to be processed into the local memory, and after completing the hash value calculation of the second file segment data stream, the hash value of the second file segment data stream is iterated with the hash value of the first file segment data stream to obtain the hash values of the first two file segment data streams and temporarily cache them in the local memory.
[0014] The above processing flow is looped until the complete hash value of the file to be processed is iteratively calculated and then uploaded to the file receiving end. Then, the above-mentioned file segment data streams that have been read are loaded into the local memory in sequence and uploaded to the file receiving end in sequence. The file receiving end uses the complete hash value to verify the complete file to be processed that is spliced together from the received file segment data streams. It is worth noting that if there is sufficient available memory space in the local memory, the files to be processed can also be loaded into the local memory at one time and uploaded directly to the file receiving end.
[0015] In a possible implementation of the first aspect, when the file to be processed is encrypted and uploaded, the size of the available memory space of the local memory is first monitored in real time, and then, based on the size of the available memory space, the first file fragment data stream whose data stream size does not exceed the size of the available memory space is read from the file to be processed into the local memory, and the first file fragment data stream is encrypted to obtain the first encrypted file fragment data stream, and then a hash value is calculated for the first encrypted file fragment data stream. After the hash value calculation of the first encrypted file fragment data stream is completed, the first hash value is temporarily stored in the local memory to release the first encrypted file fragment data stream, and then based on the size of the available memory space of the local memory, the mth file fragment data stream is read from the file to be processed in fragments into the local memory to complete the encryption processing of the mth file fragment data stream, and the mth hash value is calculated based on the m-1th hash value and the ciphertext stream of the processed mth encrypted file fragment data stream, until the processing of N file fragment data streams is completed, the complete hash value of the encrypted ciphertext stream of the file to be processed is obtained, and the complete hash value is uploaded to the file receiving end.
[0016] Next comes the uploading of the encrypted file to be processed. The file segment data streams that have been segmented in the above process are read sequentially into the local memory, and after encrypting the N file segment data streams in the local memory in turn, the ciphertext stream of the obtained file segment data stream is directly uploaded to the file receiving end while being encrypted. The file receiving end then splices the ciphertext streams of the received file segment data streams and verifies them using the complete hash value. In this way, the encrypted file segment data stream is directly uploaded to the file receiving end while being encrypted, and it does not rely on the physical storage space of the local device, thus avoiding the occupation and dependence on the physical storage space of the local device.
[0017] In a possible implementation of the first aspect above, the file receiving end may be a server device for uploading files to be processed.
[0018] In a possible implementation of the first aspect above, the server device is specifically a cloud storage server.
[0019] In a possible implementation of the first aspect above, the file processing method may be a method for encrypting a file. For the file encryption method, first, the size of the available memory space of the local memory is monitored in real time, and then, based on the size of the available memory space, a first file fragment data stream whose data stream size does not exceed the size of the available memory space is read from the file to be processed into the local memory, and the first file fragment data stream is encrypted to obtain a first encrypted file fragment data stream, and then a hash value is calculated for the first encrypted file fragment data stream. After completing the hash value calculation for the first encrypted file fragment data stream, the first hash value is temporarily stored in the local memory. The first encrypted file shard data stream is released, and then based on the size of the available memory space in the local memory, the mth file shard data stream is read from the file to be processed in segments into the local memory, and the encryption processing of the mth file shard data stream is completed. The mth hash value is calculated based on the m-1th hash value and the ciphertext stream of the processed mth encrypted file shard data stream, until the processing of N file shard data streams is completed, the complete hash value of the ciphertext stream of the encrypted file to be processed is obtained, and the encryption of the entire file to be processed is completed. The encrypted entire file to be processed can be cached in the physical storage of the local device and verified using the complete hash value.
[0020] In a possible implementation of the first aspect above, the encryption processing of the file to be processed may be performed by using a symmetric encryption algorithm.
[0021] In a possible implementation of the first aspect, the sizes of the N file segment data streams are determined according to the available size of the local memory. With the addition of different processes, the available size of the local memory changes in real time. Taking the video file to be processed as a 5GB video file as an example, when reading the video file, the available size of the local memory is first monitored. If the available size of the local memory is 2MB at this time, in order to ensure the processing speed of the video file, the 1MB file content at the beginning of the video file is selected to be read into the local memory. See the above description to complete the hash value calculation or encryption processing process of the 1MB file content.
[0022] After that, the available size of the local memory is monitored again. If the available size of the local memory is 3MB at this time, in order to ensure the processing speed of the video file, the file content of the video file after 1MB is sequentially read into the local memory. Refer to the above-described process of completing the hash value calculation or encryption processing of the 2MB file content, and the above processing flow is looped until the complete hash value of the file to be processed is completed. It can be understood that the file size of the read file segmentation data stream can also be the same as the available space of the local memory. Therefore, the size of the file segmentation data stream in the embodiment of the present application is dynamically adjusted according to the available size of the local memory, that is, the size of each file segmentation data stream can be of different sizes, so as to adapt well to the available space of the local memory, avoiding the problem of insufficient available space in the local memory causing the processing failure of the file to be processed or the slow processing speed.
[0023] In a possible implementation of the first aspect above, in order to ensure uniformity of the file shards to be processed, the sizes of the N file shard data streams are equal.
[0024] In a possible implementation of the first aspect above, in order to match the encryption algorithm and avoid the problem of iterative calculation errors of the hash value of the file to be processed, the sizes of the N file fragment data streams are all integer multiples of 16 bytes. It should be noted that if the file to be processed cannot be evenly divided into 16 bytes or integer multiples of 16 bytes, the last file fragment data stream of the file to be processed may not be 16 bytes or an integer multiple of 16 bytes.
[0025] In a second aspect, an embodiment of the present application discloses a file verification method based on hash verification, which is applied to a file receiving end. The file verification method based on hash verification includes:
[0026] receiving a complete hash value corresponding to the complete file to be processed;
[0027] Receiving N file fragment data streams formed by the to-be-processed file fragments, wherein N is an integer greater than 1;
[0028] splicing the N file fragment data streams to obtain the complete file to be processed;
[0029] The complete hash value is used to verify the complete file to be processed obtained by splicing.
[0030] In a possible implementation of the second aspect above, the file receiving end is a server device for uploading files to be processed.
[0031] In a possible implementation of the second aspect above, the server device is a cloud storage server.
[0032] In a third aspect, an embodiment of the present application discloses a device for file processing, the device for file processing comprising:
[0033] A reading module, used for reading a first file segment data stream of the file to be processed from the file to be processed into the local memory, and calculating a first hash value of the first file;
[0034] A loop processing module, used for loop processing, sequentially reading the mth file shard data stream into the local memory, and calculating the mth hash value based on the m-1th hash value and the mth file shard data stream, wherein m is an integer from 2 to N in sequence, until the calculation for the Nth file shard data stream is completed, so as to obtain the Nth hash value as the complete hash value of the file to be processed; wherein the first file shard data stream to the Nth file shard data stream constitute the complete file of the file to be processed, N is an integer not less than 2, and m is an integer from 2 to N in sequence;
[0035] Based on the complete hash value, the processing of the to-be-processed file is completed.
[0036] In some embodiments of the present application, the file processing device is a device for uploading files, and the file uploading device includes:
[0037] An upload module is used to upload each of the N file segment data streams from the local memory to the file receiving end in the order of the files to be processed based on the complete hash value, or to upload the complete file to be processed from the local memory to the file receiving end.
[0038] In some embodiments of the present application, the file processing device is a ciphertext data stream device, and the ciphertext data stream device includes:
[0039] An encryption processing module is used to read the N file fragment data streams of the complete file to be processed into the local memory in sequence for encryption processing based on the complete hash value of the file to be processed, or read the complete file to be processed into the local memory for encryption processing.
[0040] In a fourth aspect, an embodiment of the present application discloses a file verification device based on hash verification, and the file verification device based on hash verification includes:
[0041] A first receiving module, configured to receive a complete hash value corresponding to a complete file to be processed;
[0042] A second receiving module, configured to receive N file fragment data streams formed by the to-be-processed file fragments, wherein N is an integer greater than 1;
[0043] A splicing module, used for splicing the N file fragment data streams to obtain the complete file to be processed;
[0044] A verification module is used to verify the complete file to be processed obtained by splicing using the complete hash value.
[0045] In a fifth aspect, an embodiment of the present application discloses a device, the device comprising:
[0046] A memory for storing a processing program;
[0047] A processor, wherein when executing the processing program, the processor implements the steps of any one of the file processing methods described above.
[0048] In a sixth aspect, an embodiment of the present application discloses a computer-readable storage medium, on which a processing program is stored, and when a processor executes the processing program, the steps of the file processing method as described in any one of the above are implemented.
[0049] In a seventh aspect, an embodiment of the present application discloses a server, the server comprising:
[0050] A memory, used for storing a verification program;
[0051] A processor, wherein when executing the verification program, the processor implements the steps of any of the above-mentioned file verification methods based on hash verification.
[0052] In an eighth aspect, an embodiment of the present application discloses a system, including the above-mentioned device and server.
[0053] Other features and corresponding beneficial effects of the present application are described in the latter part of the specification, and it should be understood that at least some of the beneficial effects become obvious from the records in the specification of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 A schematic diagram of a file upload scenario and a system structure according to an embodiment of the present application;
[0055] FIG. 2( a ) is a flowchart of a method for uploading a file disclosed in an embodiment of the present application.
[0056] FIG. 2( b ) is a schematic diagram of a specific implementation of S21 in FIG. 2( a ) disclosed in an embodiment of the present application;
[0057] FIG2( c ) is a schematic diagram of a flow chart of a method for uploading a ciphertext data stream disclosed in an embodiment of the present application;
[0058] FIG2( d ) is a schematic diagram of a flow chart of a file encryption method disclosed in an embodiment of the present application;
[0059] Figure 3 A schematic diagram of a method flow for file processing disclosed in an embodiment of the present application;
[0060] Figure 4 A flowchart of a file verification method based on hash verification disclosed in an embodiment of the present application;
[0061] Figure 5 A schematic diagram of the structure of a file processing device disclosed in an embodiment of the present application;
[0062] Figure 6 A schematic diagram of the structure of a file verification device based on hash verification disclosed in an embodiment of the present application;
[0063] Figure 7 A schematic diagram of the structure of an electronic device disclosed in an embodiment of the present application;
[0064] Figure 8 A schematic diagram of the structure of a SOC disclosed in an embodiment of the present application;
[0065] Fig. 9 A schematic diagram of the structure of a system disclosed in an embodiment of the present application;
[0066] Fig.10 A schematic diagram of the workflow of a thread model of a system disclosed in an embodiment of the present application;
[0067] Fig.11 A schematic diagram of the calculation process of a complete hash value of a file to be processed disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0068] The following specific embodiments illustrate the implementation of the present application, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. Although the description of the present application will be introduced in conjunction with the preferred embodiment, this does not mean that the features of this invention are limited to this implementation. On the contrary, the purpose of introducing the invention in conjunction with the implementation is to cover other options or modifications that may extend based on the claims of the present application. In order to provide a deep understanding of the present application, the following description will include many specific details. The present application can also be implemented without using these details. In addition, in order to avoid confusion or blurring the focus of the present application, some specific details will be omitted in the description. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0069] It should be noted that in this specification, similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0070] The technical solution of the present application will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.
[0071] It is understood that, as used herein, the term "module" may refer to or include an application specific integrated circuit (ASIC),
[0072] Electronic circuits, processors (shared, dedicated, or group) and / or memories executing one or more software or firmware programs, combinatorial logic circuits, and / or other appropriate hardware components that provide the described functionality, or can be part of these hardware components.
[0073] It is understood that in each embodiment of the present application, the processor may be a microprocessor, a digital signal processor, a microcontroller, etc., and / or any combination thereof. According to another aspect, the processor may be a single-core processor, a multi-core processor, etc., and / or any combination thereof.
[0074] When the local device calculates the hash value of the entire content of the entire file, if the entire file is too large, it will take up a large memory space and the calculation waiting time will be relatively long. If the memory space of the local device is insufficient, the hash value calculation of the entire file will fail, slowing down the upload efficiency of the entire file. In addition, before the local device uploads the file to the cloud storage, the uploaded file needs to be encrypted. In the prior art, the traditional means is to load the file to be uploaded into the local memory at one time for encryption and temporarily store the encrypted file to be uploaded in the physical storage space of the local device, and then calculate the complete hash value of the entire file to be processed in the local memory. After calculating the complete hash value, the complete hash value and the encrypted file to be processed are uploaded to the cloud storage end. In this way, the encryption of the files to be uploaded and the calculation of the hash values are completely dependent on the available size of the local memory, and the caching of the encrypted files to be processed is also completely dependent on the physical storage space of the local device. When the physical storage space of the local device is insufficient, it is easy to cause the encrypted files to be processed to fail to be cached in the local physical storage space. In addition, after the encrypted files to be processed are uploaded, it is necessary to clear the encrypted files to be processed cached in the physical storage space of the local device, which is cumbersome. Moreover, if the encrypted files to be processed are not cached in the physical storage space of the local device in time, the physical storage space of the local device will be ineffectively occupied, reducing the effective utilization rate of the physical storage space of the local device.
[0075] In an embodiment of the present application, the local device may be a terminal device such as a computer, a mobile phone, or a PDA, and the file receiving end may be an online storage device such as a cloud storage server. The local device processes the files to be processed, and the file receiving end receives the processed files to be processed or other processing information (such as a complete hash value) uploaded by the local device.
[0076] For the local device, the processing of the file to be processed includes: calculating the complete hash value of the file to be processed, encrypting the file to be processed and calculating the hash value of the encrypted file to be processed, calculating the complete hash value of the file to be processed and uploading the complete hash value and the file to be processed, encrypting the file to be processed and calculating the complete hash value of the encrypted file to be processed and uploading the complete hash value and the encrypted file to be processed.
[0077] A file uploading method disclosed in an embodiment of the present application is described below with reference to the accompanying drawings.
[0078] Figure 1 FIG. 1 shows a diagram of a scenario and system for implementing file upload according to an embodiment of the present application. Figure 1As shown, terminal 100 and terminal 200 are connected to each other via network 300, and files can be transferred between them, including downloading and uploading. Terminal 100 can correspond to the device provided in the embodiment of the present application, and terminal 200 can be the server provided in the embodiment of the present application.
[0079] The terminal 200 may be implemented as a cloud storage server device, or as a storage node of distributed storage, etc. In the following description, the terminal 200 is implemented as a cloud storage server as an example.
[0080] When the terminal 100 needs to upload a file to the server, it needs to calculate the hash value of the entire file to be processed, that is, the entire content of the file to be uploaded and upload it to the server. The cloud storage stores the hash value to perform integrity verification on the uploaded file.
[0081] FIG2(a) is a flowchart of a method for uploading a file disclosed in an embodiment of the present application. The method for uploading a file as shown in FIG2(a) includes:
[0082] Step S20: Read the first file segment data stream of the to-be-processed file from the to-be-processed file into the local memory. The file to be uploaded to the server, i.e., the to-be-processed file, is processed in segments, and each segment file is called a file segment data stream. The number of segmented file segment data streams is an integer greater than 2, counted as N. The following is described by taking N as 6 as an example.
[0083] The size of each file segment data stream can be predetermined, for example, each file segment data stream is specified to be no larger than a preset size, for example, in megabytes M. In the file upload operation, the file needs to be processed in the local memory of the terminal 100 and then sent to the external server (terminal 200) through the network. In the scenario where the memory of the terminal 100 may be limited, the size of each file segment data stream can be determined based on the size of the available memory capacity remaining in the current terminal 100, that is, the size of each file segment data stream does not exceed the size of the available memory capacity remaining in the current terminal 100.
[0084] Step S21: loop processing is performed for each subsequent file segment data stream, and each file segment data stream is read from the to-be-processed file in sequence, and the hash value of the current file segment data stream is calculated based on the hash value obtained from the previous file segment data stream and the current file segment data stream. Until the hash value of the last file segment data stream, i.e., the sixth file segment data stream, and the previous file segment data stream, i.e., the fifth file segment data stream, are combined, the hash value for the last file segment data stream, i.e., the sixth hash value, is obtained, and the sixth hash value is used as the hash value of the complete file to be processed.
[0085] In the process of processing each file segment data stream, after completing the processing of the file segment data stream of the current segment, the file segment data stream can be released from the local memory to release the memory space.
[0086] Step S22: Upload the complete hash value to the file receiving end.
[0087] Step S23: Read the 1st file segment data stream to the Nth file segment data stream into the local memory in sequence according to the same rules as steps S20 and S21, and upload the 1st file segment data stream to the Nth file segment data stream to the server as the file receiving end in sequence.
[0088] It is worth noting that if the available memory space of the local memory monitored in real time is sufficient (meeting the space requirements for loading the complete file to be processed), the complete file to be processed is directly loaded into the local memory. After the encryption of the entire file to be processed is completed in the local memory, the encrypted complete file to be processed is uploaded to the file receiving end.
[0089] The following is a description of the loop processing in the file upload method according to the embodiment of the present application with reference to FIG2(b). As shown in FIG2(b), the step 21 shown in FIG2(b) includes the following steps:
[0090] Step S211: read the mth file segment data stream into the local memory, where m is an integer from 2 to N. For example, as the beginning of the loop, first read the second file segment data stream into the local memory.
[0091] Step S212: Based on the hash value calculated last time, i.e., the m-1th hash value corresponding to the (m-1)th file segment data stream, the m-1th hash value and the mth file segment data stream are iteratively calculated to obtain the mth hash value. For example, for the processing of the second file segment data stream, the hash value corresponding to the second file segment data stream is obtained based on the first hash value corresponding to the first file segment data stream and the second file segment data stream.
[0092] Step S213, the count of m is increased by 1.
[0093] Step S214, determine whether the currently processed file segment data stream is the last file segment data stream of the file to be processed, that is, determine whether the current m is equal to N (optionally 6) after counting in step S213. If m is less than N, return to repeat step S211, otherwise go to step S215.
[0094] Step S215, completing the calculation of the Nth file segment data stream, and obtaining the Nth hash value as the complete hash value of the file to be processed.
[0095] FIG2( c ) is a flow chart of a method for uploading a ciphertext data stream disclosed in an embodiment of the present application.
[0096] The method for uploading the ciphertext data stream shown in FIG2(c) includes:
[0097] Step S24: reading the first file segment data stream of the file to be processed from the file to be processed into the local memory.
[0098] The size of each file segment data stream can be predetermined, for example, each file segment data stream is specified to be no larger than a preset size, for example, in megabytes M. In the file upload operation, the file needs to be processed in the local memory of the terminal 100 and then sent to the external server (terminal 200) through the network. In the scenario where the memory of the terminal 100 may be limited, the size of each file segment data stream can be determined based on the size of the available memory capacity remaining in the current terminal 100, that is, the size of each file segment data stream does not exceed the size of the available memory capacity remaining in the current terminal 100.
[0099] Step S25: read the first file segment data stream into the local memory, and encrypt the first file segment data stream.
[0100] Step S26: Calculate the first hash value of the encrypted first file segment data stream in the local memory to complete the processing of the first file segment data stream, and temporarily cache the first hash value in the local memory.
[0101] It is worth noting that after the processing of the first file fragment data stream is completed, the first file fragment data stream and the encrypted first file fragment data stream are released from the local memory, which occupies less memory space while avoiding occupying the physical storage space of the local device.
[0102] Step S27: perform loop processing to sequentially read the mth file fragment data stream whose file size does not exceed the available memory space size of the local memory at the current moment from the files to be processed.
[0103] Step S28: Read the mth file segment data stream into the local memory, and encrypt the mth file segment data stream.
[0104] Step S29: Based on the m-1th hash value of the encrypted m-1th file shard data stream, iteratively calculate the m-1th hash value and the encrypted mth file shard data stream to obtain the mth hash value, until the calculation of the Nth file shard data stream is completed, and the Nth hash value is obtained as the complete hash value of the file to be processed.
[0105] The value range of m is an integer from 2 to N.
[0106] Step S241: Upload the complete hash value to the file receiving end.
[0107] Step S242: sequentially read the first file segment data stream to the Nth file segment data stream into the local memory, and sequentially encrypt the first file segment data stream to the Nth file segment data stream in the local memory.
[0108] Step S243: uploading the encrypted first file segment data stream to the Nth file segment data stream from the local memory to the file receiving end in sequence.
[0109] It is worth noting that if the available memory space of the local memory monitored in real time is sufficient (meeting the space requirements for loading the file to be processed), the file to be processed is directly loaded into the local memory. After the encryption of the entire file to be processed is completed in the local memory, the encrypted and complete file to be processed is uploaded to the file receiving end.
[0110] In some embodiments of the present application, the encryption processing of the file to be processed may be performed by using a symmetric encryption algorithm.
[0111] In order to avoid miscalculations in the subsequent hash calculation of the to-be-processed file after the encryption process is performed using a symmetric encryption algorithm, in some embodiments of the present application, the size of the first file shard data stream to the Nth file shard data stream needs to be set to an integer multiple of 16 bytes. It should be noted that if the to-be-processed file cannot be evenly divided into 16 bytes or an integer multiple of 16 bytes, the last file shard data stream of the to-be-processed file may not be 16 bytes or an integer multiple of 16 bytes. If the available memory space of the local memory of the local device is sufficient (such as greater than 2M), in order to speed up the encryption speed of the to-be-processed file content, the size of the file shard data stream read this time can be set to 1M. The available memory space of the local memory of the local device is small (such as less than 1M). In order to reduce the problem of failure to load data caused by insufficient local memory, the file size of the file shard data stream read this time can be set to 10K. Therefore, in the embodiment of the present application, the size of the sharded first file shard data stream to the Nth file shard data stream is dynamically adjusted according to the size of the available memory space of the local memory monitored in real time.
[0112] The process of the loop processing shown in step S27 is basically the same as step S21 and the steps of the loop processing described in FIG. 2( b ), the only difference being that the processed file is a file encrypted in the local memory.
[0113] A file encryption method disclosed in an embodiment of the present application is described below in conjunction with FIG. 2(d). FIG. 2(d) is a flow chart of a file encryption method disclosed in an embodiment of the present application. When executing the file encryption steps shown in FIG. 2(d), the size of the available memory space (available space) of the local memory is monitored in real time. The file encryption method shown in FIG. 2(d) includes:
[0114] Step S244: reading the first file segment data stream of the file to be processed from the file to be processed into the local memory.
[0115] Step S245: encrypt the first file segment data stream.
[0116] Step S246: Calculate the first hash value of the encrypted first file segment data stream in the local memory to complete the processing of the first file segment data stream, and temporarily cache the first hash value in the local memory.
[0117] It is worth noting that after the processing of the first file fragment data stream is completed, the first file fragment data stream and the encrypted first file fragment data stream are released from the local memory to avoid occupying the physical storage space of the local device.
[0118] Step S247: perform loop processing to sequentially read the mth file fragment data stream whose file size does not exceed the available memory space size of the local memory at the current moment from the files to be processed.
[0119] The process of the loop processing shown in step S247 is basically the same as the steps of the loop processing introduced in step S27.
[0120] Step S248: Read the mth file segment data stream into the local memory, and encrypt the mth file segment data stream.
[0121] Step S249: Based on the m-1th hash value of the encrypted m-1th file shard data stream, iteratively calculate the m-1th hash value and the encrypted mth file shard data stream to obtain the mth hash value, until the calculation of the Nth file shard data stream is completed, and the Nth hash value is obtained as the complete hash value of the file to be processed.
[0122] The value range of m is an integer of 2-N, and the encryption of the file to be processed is now completed.
[0123] It is worth noting that if the available memory space of the local memory monitored in real time is sufficient (meeting the space requirement for loading the file to be processed), the file to be processed is directly loaded into the local memory, and the encryption of the entire file to be processed is completed in the local memory.
[0124] In some embodiments of the present application, the encryption processing of the file to be processed may be performed by using a symmetric encryption algorithm.
[0125] In order to avoid incorrect calculations during the subsequent hash calculation of the processed file after encryption processing using a symmetric encryption algorithm, in some embodiments of the present application, the size of the 1st file shard data stream to the Nth file shard data stream needs to be set to an integer multiple of 16 bytes. For example, when the available memory space of the local memory of the local device is sufficient (such as greater than 2M), in order to speed up the encryption of the content of the file to be processed, the size of the file shard data stream read this time can be set to 1M. The available memory space of the local memory of the local device is small (such as less than 1M). In order to reduce the problem of data loading failure caused by insufficient local memory, the file size of the file shard data stream read this time can be set to 10K. Therefore, in the embodiments of the present application, the size of the sharded 1st file shard data stream to the Nth file shard data stream is dynamically adjusted according to the size of the available memory space of the local memory monitored in real time.
[0126] It is worth noting that other encryption algorithms may also be used for the encryption processing of the files to be processed, and the embodiments of the present application do not limit this.
[0127] Combine the following Figure 3 A method for processing a file disclosed in an embodiment of the present application is described. Figure 3 This is a flowchart of a method for file processing disclosed in an embodiment of the present application. Figure 3 The methods of file processing shown include:
[0128] Step S30: reading the first file segment data stream of the file to be processed from the file to be processed into the local memory.
[0129] Step S31: Calculate the first hash value of the first file segment data stream in the local memory to complete the processing of the first file segment data stream, and temporarily cache the first hash value in the local memory.
[0130] It is worth noting that after the processing of the first file fragment data stream is completed, the first file fragment data stream is released from the local memory to avoid occupying the local memory.
[0131] Step S32: perform loop processing, read the mth file shard data stream into the local memory in turn, and calculate the mth hash value based on the m-1th hash value and the mth file shard data stream, until the calculation for the Nth file shard data stream is completed, so as to obtain the Nth hash value as the complete hash value of the file to be processed, wherein the 1st file shard data stream to the Nth file shard data stream constitute the complete file of the file to be processed, N is an integer not less than 2, and m is an integer from 2 to N in turn.
[0132] It is worth noting that, in such a cyclic processing, the file to be processed is fragmented into N file fragment data streams according to the size of the available memory space in the local memory, and the sizes of the N file fragment data streams can be the same or different.
[0133] Step S33: Based on the complete hash value, complete the processing of the file to be processed.
[0134] For the file receiving end, the file receiving end receives the complete hash value uploaded by the local device and the uploaded file segment data streams corresponding to the file to be processed, then splices the file segment data streams to obtain the complete file to be processed, and uses the complete hash value to verify the complete file to be processed.
[0135] It is worth noting that the loop processing process shown in step S32 includes step S21 and the loop processing steps described in Figures 2(b) and S27.
[0136] Combine the following Figure 4 A file verification method based on hash verification disclosed in an embodiment of the present application is described. Figure 4 The following is a flowchart of a file verification method based on hash verification disclosed in an embodiment of the present application. Figure 4 The hash-based file verification method shown includes:
[0137] Step S40: receiving a complete hash value corresponding to the complete file to be processed.
[0138] Step S41: receiving N file fragment data streams formed by the to-be-processed file fragments, where N is an integer greater than 1.
[0139] Step S42: splicing the N file fragment data streams to obtain a complete file to be processed.
[0140] Step S43: Use the complete hash value to verify the complete file to be processed.
[0141] In some embodiments of the present application, the file receiving end is a server device for uploading files to be processed.
[0142] In some embodiments of the present application, the server device is a cloud storage server.
[0143] Figure 5 This is a schematic diagram of the structure of a file processing device disclosed in an embodiment of the present application, and the file processing device includes:
[0144] A reading module 50 is used to read the first file segment data stream of the file to be processed from the file to be processed into a local memory;
[0145] A calculation module 51, used for calculating a first hash value of a first file;
[0146] The loop processing module 52 performs loop processing, sequentially reads the mth file shard data stream into the local memory, and calculates the mth hash value based on the m-1th hash value and the mth file shard data stream, wherein m is an integer from 2 to N in sequence, until the calculation for the Nth file shard data stream is completed, so as to obtain the Nth hash value as the complete hash value of the to-be-processed file, wherein the 1st file shard data stream to the Nth file shard data stream constitute the complete file of the to-be-processed file, N is an integer not less than 2, and m is an integer from 2 to N in sequence;
[0147] Based on the complete hash value, the processing of the to-be-processed file is completed.
[0148] In some embodiments of the present application, the file processing device can be implemented as a device for uploading files, and the process of sending the file to be processed into the local memory is: the file to be processed is read into the local memory in segments, and then the hash value of each file segment data stream is iteratively calculated segment by segment. After obtaining the complete hash value of the file to be processed, the complete hash value of the file to be processed and the file to be processed are uploaded. The processing performed by the file uploading device for file upload processing according to this embodiment is the same as the file uploading method corresponding to Figure 2 (a) above.
[0149] In some embodiments of the present application, the file processing device can be implemented as a device for encrypting and uploading files, and the processing of sending the files to be processed into the local memory is: the files to be processed are read into the local memory in segments, and then each file segment data stream is encrypted in a cyclic manner, and the encrypted file segment data stream after encryption is iteratively calculated. The hash value of each encrypted file segment data stream. After obtaining the complete hash value of the complete encrypted file to be processed, the complete hash value of the complete encrypted file to be processed is uploaded, and then the file to be processed is read into the local memory in segments in a cyclic manner, and each file segment data stream is encrypted in turn, and the encrypted file segment data stream is uploaded in turn, realizing the process of encrypting and uploading at the same time. The processing performed by the file encryption upload device for file encryption upload processing according to this embodiment is the same as the file encryption upload method corresponding to Figure 2 (b) above.
[0150] In some embodiments of the present application, the file processing device can be implemented as a device for file encryption, and the processing of the file to be processed being sent to the local memory is: the file to be processed is read into the local memory in segments, and then each segment of the file segment data stream is encrypted in a cyclic manner segment by segment, and the hash value of each segment of the encrypted file segment data stream after the encryption is iteratively calculated to obtain the complete hash value of the complete encrypted file to be processed, thereby realizing the encryption of the file to be processed.
[0151] The process performed by the file encryption device for file encryption processing according to this embodiment is the same as the file encryption method corresponding to FIG. 2( c ).
[0152] Figure 6 This is a schematic diagram of the structure of a file verification device based on hash verification disclosed in an embodiment of the present application. The file verification device based on hash verification includes:
[0153] A first receiving module 60, configured to receive a complete hash value corresponding to a complete file to be processed;
[0154] The second receiving module 61 is used to receive N file fragment data streams formed by the file fragments to be processed, where N is an integer greater than 1;
[0155] A splicing module 62 is used to splice N file fragment data streams to obtain a complete file to be processed;
[0156] The verification module 63 is used to verify the complete file to be processed obtained by splicing using the complete hash value.
[0157] In some embodiments of the present application, an electronic device is provided, Figure 7 The electronic device in the embodiment of the present application is introduced. Figure 7A schematic diagram of the structure of an electronic device disclosed in an embodiment of the present application.
[0158] For at least one embodiment, the controller hub 704 communicates with the processor 701 via a multi-drop bus such as a front-side bus (FSB), a point-to-point interface such as a QuickPath Interconnect (QPI), or a similar connection. The processor 701 executes instructions that control general types of data processing operations. In one embodiment, the controller hub 704 includes, but is not limited to, a graphics memory controller hub (GMCH) (not shown) and an input / output hub (IOH) (which can be on a separate chip) (not shown), wherein the GMCH includes memory and a graphics controller and is coupled to the IOH.
[0159] The electronic device 700 may also include a coprocessor 706 and a memory 702 coupled to the controller hub 704. Alternatively, one or both of the memory 702 and the GMCH may be integrated within the processor 701 (as described in this application), with the memory 702 and the coprocessor 706 being directly coupled to the processor 701 and the controller hub 704, with the controller hub 704 being in a single chip with the IOH.
[0160] In one embodiment, the memory 702 may be, for example, a dynamic random access memory (DRAM), a phase change memory (PCM), or a combination of the two. The memory 702 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. The computer-readable storage medium stores instructions, and more specifically, stores temporary and permanent copies of the instructions.
[0161] In one embodiment, coprocessor 706 is a special purpose processor, such as, for example, a high throughput MIC processor, a network or communication processor, a compression engine, a graphics processor, a GPGPU, or an embedded processor, etc. The optional nature of coprocessor 706 is indicated by dashed lines in FIG. Figure 7 middle.
[0162] In one embodiment, the electronic device 700 may further include a network interface (NIC) 703. The network interface 703 may include a transceiver for providing a radio interface for the device 700 to communicate with any other suitable device (such as a front-end module, an antenna, etc.). In various embodiments, the network interface 703 may be integrated with other components of the electronic device 700. The network interface 703 may implement the functions of the communication unit in the above-mentioned embodiments.
[0163] In one embodiment, Figure 7As shown, the electronic device 700 may further include an input / output (I / O) device 705. The input / output (I / O) device 705 may include: a user interface designed to enable a user to interact with the electronic device 700; a peripheral component interface designed to enable peripheral components to interact with the electronic device 700; and / or a sensor designed to determine environmental conditions and / or location information related to the electronic device 700.
[0164] It is worth noting that Figure 7 This is for illustrative purposes only. Figure 7 It is shown that the electronic device 700 includes multiple devices such as a processor 701, a controller hub 704, a memory 702, etc. However, in actual applications, the devices using the methods of the present application may only include a part of the devices of the electronic device 700, for example, it may only include the processor 701 and the NIC 703. Figure 7 The properties of optional devices are shown with dashed lines.
[0165] In some embodiments of the present application, the electronic device 700 can implement the device of the present application, or be implemented as a server according to the present application, depending on the operations performed according to the instructions stored in the electronic device 700.
[0166] When the electronic device 700 is implemented as an embodiment of the device according to the present application, the computer-readable storage medium stores instructions which may include: when executed by at least one unit in the processor, the device implements the following Figures 1 to 3 When the instructions are executed on a computer, the computer executes the above-mentioned file processing method. Figures 1 to 3 The mentioned file processing methods.
[0167] In an embodiment where the electronic device 700 is implemented as a server according to the present application, the computer-readable storage medium may store instructions that, when executed by at least one unit in the processor, cause the server to implement Figure 4 The instructions of the file verification method based on hash verification mentioned above. When the instructions are executed on a computer, the computer executes the above-mentioned Figure 4 The mentioned file verification method based on hash verification.
[0168] Reference now Figure 8 , Figure 8 1 is a schematic diagram of a structure of a SOC disclosed in an embodiment of the present application, showing a block diagram of a SoC (System on Chip) 1000 according to an embodiment of the present application. Figure 8In the figure, similar components have the same reference numerals. In addition, the dashed box is an optional feature of a more advanced SoC. The SoC can be used in a device according to an embodiment of the present application, or in a server according to an embodiment of the present application. Depending on the device in which it is located and the instructions stored therein, the corresponding functions can be implemented.
[0169] exist Figure 8 In the embodiment, SoC 1000 includes: an interconnect unit 1002, which is coupled to processor 1001; a system agent unit 1006; a bus controller unit 1005; an integrated memory controller unit 1003; a group or one or more coprocessors 1007, which may include integrated graphics logic, image processors, audio processors, and video processors; a static random access memory (SRAM) unit 1008; and a direct memory access (DMA) unit 1004. In one embodiment, coprocessor 1007 includes a special-purpose processor, such as, for example, a network or communication processor, a compression engine, a GPGPU, a high-throughput MIC processor, or an embedded processor.
[0170] One or more computer-readable media for storing data and / or instructions may be included in the static random access memory (SRAM) unit 1008. The computer-readable storage medium may store instructions, and more specifically, temporary and permanent copies of the instructions.
[0171] When the SoC 1000 is applied to a device according to the present application, the computer-readable storage medium may store instructions that, when executed by at least one unit in the processor, cause the network routing device to implement the following Figure 1-Figure 3 When the instructions are executed on a computer, the computer executes the above-mentioned method of file processing. Figure 1-Figure 3 The method for handling the mentioned files.
[0172] When the SoC 1000 is applied to a server according to the present application, the instructions stored in the computer-readable storage medium may include: when executed by at least one unit in the processor, the server implements the following Figure 4 The instructions of the file verification method based on hash verification mentioned above. When the instructions are executed on a computer, the computer executes the above-mentioned Figure 4 The mentioned file verification method based on hash verification.
[0173] Fig. 9 A schematic diagram of the structure of a system disclosed in an embodiment of the present application is shown in FIG. Fig. 9 As shown, the system 9 includes the above-mentioned devices and servers.
[0174] Fig.10A schematic diagram of the workflow of a thread model of a system disclosed in an embodiment of the present application is shown in FIG. Fig.11 This is a schematic diagram of a calculation process of a complete hash value of a file to be processed disclosed in an embodiment of the present application. Fig.10 In this paper, we take the encryption process as a symmetric encryption algorithm, the server as a cloud server, and the file to be processed as a 5GB video file as an example. Fig.11 The complete hash value calculation process diagram is as follows: Fig.10 As shown in the figure, the workflow diagram of the thread model is as follows:
[0175] Step S100: monitor the available memory space size of the local memory of the local device, assuming it is 3 MB.
[0176] Step S101: Read the first video file segment data stream of the target value (not exceeding the available memory space size, such as 1 MB) from the 5GB video file according to the available memory space size of the local memory.
[0177] Step S102: performing encryption processing on the read first video file segment data stream using a symmetric encryption algorithm to obtain a ciphertext data stream Encrypted_Buffer1 after the first video file segment data stream is encrypted.
[0178] Step S103: Calculate the hash value of the encrypted data stream Encrypted_Buffer1 obtained by encrypting the first video file segment data stream using a hash algorithm.
[0179] like Fig.11 As shown, at this time, the first hash value of the first 1MB video file segment data stream after encryption of the 5GB video file is obtained, which is recorded as hash1. In order to finally obtain the complete hash value of the entire video file, continue to loop and read the remaining content of the video file.
[0180] Step S104: S100-S103 are executed in a loop until the entire 5 GB video file is read and the complete hash value is calculated iteratively.
[0181] like Fig.11 As shown, the iteration process of the complete hash value of the 5GB video file is as follows:
[0182] Calculate the hash1 of the encrypted 1MB first video file fragment data stream.
[0183] Then the second video file segment data stream of the 5GB video file is obtained in sequence (if the available free memory of the local memory is 4GB at this time, the size of the second video file segment data stream read can be 3GB), the second video file segment data stream is encrypted to obtain the ciphertext data stream Encrypted_Buffer2, and the hash iteration algorithm is used to iteratively calculate hash1 and Encrypted_Buffer2 to obtain a new ciphertext summary, recorded as hash2 (the total hash value of the first video file segment data stream and the second video file segment data stream); in this way, hash3 and hash4 can be iterated to obtain the complete hash value hashN of N video file segment data streams, and after the 5GB video file is read, the complete hash value hashN of the encrypted video file can be finally obtained.
[0184] Step S105: Upload the complete hash value to the cloud storage server for verification of the 5GB video file.
[0185] Next, we will perform the process of encrypting and uploading the 5GB video file. Using the following upload solution, we can effectively reduce the reliance on the local memory and physical storage space of the local device when uploading the ciphertext obtained by encrypting the 5GB file.
[0186] Step S106: monitor the available memory space size of the local memory of the local device.
[0187] Step S107: Read the first video file segment data stream of the target value (not exceeding the available memory space size, such as 1 MB) from the 5GB video file according to the available memory space size of the local memory.
[0188] Step S108: performing encryption processing on the read first video file segment data stream using a symmetric encryption algorithm to obtain a ciphertext data stream Encrypted_Buffer1 after the first video file segment data stream is encrypted.
[0189] Step S109: uploading the encrypted ciphertext data stream Encrypted_Buffer1 of the first video file segment data stream to the cloud storage server.
[0190] Step S110: Repeat steps S106 to S109 until the entire video file is read into the local storage in the form of sub-video files and encrypted, and the encrypted video file segment data streams are uploaded to the cloud storage server in sequence.
[0191] Step S111: the cloud storage server splices the received video file segment data streams to obtain a complete 5GB video file, and verifies the complete 5GB video file according to the received complete hash value.
[0192] The present invention discloses a file processing method, device, equipment, storage medium, and a file verification method and server based on hash verification, which have the following beneficial effects:
[0193] Read the 1st file shard data stream to the Nth file shard data stream of the file to be processed. Since the entire file to be processed is read into the local memory in sequence in the form of file shard data streams for processing, it does not rely on too large local memory space. The size of each file shard data stream is dynamically adjusted based on the available space size of the local memory, that is, the size of the file shard data stream does not exceed the available space size of the local memory. Therefore, the local memory can meet the memory requirements of each file shard data stream when performing hash calculation in the local memory, avoiding file loading and hash value calculation failure. In addition, when the local device encrypts the file to be processed, it reads the 1st file segment data stream to the Nth file segment data stream of the file to be processed in sequence, and reads each file segment data stream into the local memory in sequence for encryption and hash value calculation. After the encryption of a file segment data stream is completed, its hash value is first cached in the local memory, and the ciphertext data stream is released from the local memory and is not stored in the physical cache space of the local device until the calculation of the encrypted complete hash value of the entire file to be processed is completed in the local device and uploaded to the file receiving end, and then each file segment data stream is read into the local memory in sequence. After encrypting each file segment data stream in sequence, the ciphertext stream of the obtained file segment data stream is uploaded to the file receiving end while being encrypted, and does not rely on the physical storage space stored in the local device and the excessively large local memory, thereby avoiding the problem of occupying the physical storage space of the local device and clearing the cached data in the physical storage space, and avoiding the problem of over-reliance on local memory.
[0194] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for file processing, characterized in that: include: Reading a first file fragment data stream of the file to be processed from the file to be processed into a local memory, and calculating a first hash value of the first file fragment data stream, after completing the calculation of the first hash value of the first file fragment data stream, temporarily caching the first hash value into the local memory, and releasing the first file fragment data stream from the local memory; Perform loop processing, read the mth file shard data stream into the local memory in turn, and calculate the mth hash value based on the m-1th hash value and the mth file shard data stream, after completing the calculation of the mth hash value of the mth file shard data stream, temporarily cache the mth hash value into the local memory, and release the mth file shard data stream from the local memory, wherein m is an integer from 2 to N in turn, until the calculation of the hash value for the Nth file shard data stream is completed, so as to obtain the Nth hash value as the complete hash value of the file to be processed, wherein the 1st file shard data stream to the Nth file shard data stream constitute the complete file of the file to be processed, N is an integer not less than 2, the size of each file shard data stream is dynamically determined according to the available memory space size of the local memory monitored in real time, and the size of each file shard data stream does not exceed the available memory space size of the local memory; Based on the complete hash value, the processing of the to-be-processed file is completed.
2. The method for file processing according to claim 1, characterized in that: The file processing method is a method for uploading files, and the method for uploading files includes: Based on the complete hash value, the N file segment data streams are uploaded sequentially from the local memory to the file receiving end in the order of the files to be processed, or the complete files to be processed are uploaded from the local memory to the file receiving end.
3. The method for file processing according to claim 2, characterized in that: The first file segment data stream to the Nth file segment data stream used to calculate the hash value are files that have been encrypted respectively. The encryption process is completed after each of the file segment data streams is read into the local memory in sequence.
4. The method for file processing according to claim 1, characterized in that: The file processing method is a ciphertext data stream method, and the ciphertext data stream method includes: Based on the complete hash value of the file to be processed, the N file fragment data streams for the complete file to be processed are sequentially read into the local memory for encryption processing respectively, or the complete file to be processed is read into the local memory for encryption processing.
5. The method for file processing according to claim 1, characterized in that: The sizes of the N file fragment data streams are equal.
6. The method for file processing according to claim 3 or 4, characterized in that: The encryption process uses a symmetric encryption algorithm to perform encryption process.
7. The method for file processing according to claim 1, characterized in that: The sizes of the N file segment data streams are all integer multiples of 16 bytes.
8. A file verification method based on hash verification, applied to a file receiving end, characterized in that: include: Receive a complete hash value corresponding to a complete file to be processed, where the complete hash value is obtained by a local device corresponding to the file to be processed in the following manner: Reading a first file fragment data stream of the file to be processed from the file to be processed into a local memory, and calculating a first hash value of the first file fragment data stream, after completing the calculation of the first hash value of the first file fragment data stream, temporarily caching the first hash value into the local memory, and releasing the first file fragment data stream from the local memory; Perform loop processing, read the mth file shard data stream into the local memory in sequence, and calculate the mth hash value based on the m-1th hash value and the mth file shard data stream, after completing the calculation of the mth hash value of the mth file shard data stream, temporarily cache the mth hash value into the local memory, and release the mth file shard data stream from the local memory, wherein m is an integer from 2 to N in sequence, until the calculation of the hash value for the Nth file shard data stream is completed, so as to obtain the Nth hash value as the complete hash value of the to-be-processed file, wherein the 1st file shard data stream to the Nth file shard data stream constitute the complete file of the to-be-processed file, N is an integer not less than 2, the size of each file shard data stream is dynamically determined according to the available memory space size of the local memory monitored in real time, and the size of each file shard data stream does not exceed the available memory space size of the local memory; Receiving N file fragment data streams formed by the to-be-processed file fragments, wherein N is an integer greater than 1; splicing the N file fragment data streams to obtain the complete file to be processed; The complete hash value is used to verify the complete file to be processed obtained by splicing.
9. The file verification method based on hash verification as claimed in claim 8, characterized in that: The file receiving end is a server device for uploading the file to be processed.
10. The file verification method based on hash verification as claimed in claim 9, characterized in that: The server device is specifically a cloud storage server.
11. A file processing device, characterized in that: The file processing device comprises: A reading module, used for reading a first file fragment data stream of a file to be processed from a file to be processed into a local memory, and calculating a first hash value of the first file fragment data stream, and after completing the calculation of the first hash value of the first file fragment data stream, temporarily caching the first hash value into the local memory, and releasing the first file fragment data stream from the local memory; A loop processing module, used for performing loop processing, sequentially reading the mth file shard data stream into the local memory, and calculating the mth hash value based on the m-1th hash value and the mth file shard data stream, after completing the calculation of the mth hash value of the mth file shard data stream, temporarily caching the mth hash value into the local memory, and releasing the mth file shard data stream from the local memory, wherein m is an integer from 2 to N in sequence, until the calculation of the hash value for the Nth file shard data stream is completed, so as to obtain the Nth hash value as the complete hash value of the file to be processed; wherein the 1st file shard data stream to the Nth file shard data stream constitute the complete file of the file to be processed, N is an integer not less than 2, the size of each file shard data stream is dynamically determined according to the available memory space size of the local memory monitored in real time, and the size of each file shard data stream does not exceed the available memory space size of the local memory; Based on the complete hash value, the processing of the to-be-processed file is completed.
12. A file verification device based on hash verification, characterized in that: The file verification device based on hash verification includes: The first receiving module is configured to receive a complete hash value corresponding to a complete file to be processed, where the complete hash value is obtained by a local device corresponding to the file to be processed in the following manner: Reading a first file fragment data stream of the file to be processed from the file to be processed into a local memory, and calculating a first hash value of the first file fragment data stream, after completing the calculation of the first hash value of the first file fragment data stream, temporarily caching the first hash value into the local memory, and releasing the first file fragment data stream from the local memory; Perform loop processing, read the mth file shard data stream into the local memory in turn, and calculate the mth hash value based on the m-1th hash value and the mth file shard data stream, after completing the calculation of the mth hash value of the mth file shard data stream, temporarily cache the mth hash value into the local memory, and release the mth file shard data stream from the local memory, wherein m is an integer from 2 to N in turn, until the calculation of the hash value for the Nth file shard data stream is completed, so as to obtain the Nth hash value as the complete hash value of the to-be-processed file, wherein the 1st file shard data stream to the Nth file shard data stream constitute the complete file of the to-be-processed file, N is an integer not less than 2, the size of each file shard data stream is dynamically determined according to the available memory space size of the local memory monitored in real time, and the size of each file shard data stream does not exceed the available memory space size of the local memory; A second receiving module, configured to receive N file fragment data streams formed by the to-be-processed file fragments, wherein N is an integer greater than 1; A splicing module is used to splice the N file fragment data streams to obtain the complete file to be processed; a verification module is used to verify the complete file to be processed obtained by splicing using the complete hash value.
13. A device, characterized in that The device comprises: A memory for storing a processing program; A processor, wherein when executing the processing program, the processor implements the steps of the file processing method according to any one of claims 1 to 7.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a processing program, and when the processor executes the processing program, the steps of the file processing method according to any one of claims 1 to 7 are implemented.
15. A server, characterized in that: The server comprises: A memory, used for storing a verification program; A processor, wherein when executing the verification program, the processor implements the steps of the file verification method based on hash verification as described in any one of claims 8 to 10.
16. A system, characterized in that: Includes the device described in claim 13 and the server described in claim 15.
