CN111737534B - File processing method, device and equipment - Google Patents

File processing method, device and equipment Download PDF

Info

Publication number
CN111737534B
CN111737534B CN202010566471.4A CN202010566471A CN111737534B CN 111737534 B CN111737534 B CN 111737534B CN 202010566471 A CN202010566471 A CN 202010566471A CN 111737534 B CN111737534 B CN 111737534B
Authority
CN
China
Prior art keywords
file
characters
hash
preset
hash value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010566471.4A
Other languages
Chinese (zh)
Other versions
CN111737534A (en
Inventor
代瑞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202010566471.4A priority Critical patent/CN111737534B/en
Publication of CN111737534A publication Critical patent/CN111737534A/en
Application granted granted Critical
Publication of CN111737534B publication Critical patent/CN111737534B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9014Indexing; Data structures therefor; Storage structures hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a file processing method, device and equipment, and relates to the technical fields of file processing, file verification and file security. The specific implementation scheme is as follows: the file generating device inserts k characters into the first file to generate a second file, so that a hash value corresponding to the second file meets preset hash characteristics. Therefore, when the file verification device verifies the file, the file verification device can determine whether the file is modified only by judging whether the hash value of the file meets the preset hash characteristic. In the process, the file verification equipment can realize verification by only utilizing the existing file, management and maintenance of the initial file or the hash value of the initial file are not needed, the maintenance difficulty is reduced, and the verification efficiency of the file is improved.

Description

File processing method, device and equipment
Technical Field
The embodiment of the application relates to the field of data processing, in particular to a file processing method, device and equipment, which can be used in the technical field of file processing.
Background
In some application scenarios, a verification of a file is required to determine whether the file has been modified after its self-generation.
In the prior art, it is common practice to either keep the original file, or to keep the hash value of the original file. When the current file needs to be checked, comparing the current file with the initial file, or comparing the hash value of the current file with the hash value of the initial file, and if the hash value of the current file is inconsistent with the hash value of the initial file, determining that the current file is modified.
However, the above manner needs to store and manage the initial files or hash values of the initial files, and when the number of the files is large, more initial files or hash values need to be maintained, so that the maintenance difficulty is large, and the file verification efficiency is low.
Disclosure of Invention
The application provides a file processing method, device and equipment, which are used for improving file verification efficiency.
In a first aspect, the present application provides a file processing method, including:
acquiring a first file to be processed;
inserting k characters into the first file to generate a second file, wherein a hash value corresponding to the second file meets preset hash characteristics; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value, and k is a natural number which is greater than or equal to 1.
In a second aspect, the present application provides a document processing method, including:
Acquiring a third file to be checked, and acquiring a hash value corresponding to the third file;
determining whether the third file is modified according to whether the hash value meets a preset hash characteristic; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value.
In a third aspect, the present application provides a document processing apparatus, including:
the acquisition module is used for acquiring a first file to be processed;
the generating module is used for inserting k characters into the first file to generate a second file, and the hash value corresponding to the second file meets the preset hash characteristic; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value, and k is a natural number which is greater than or equal to 1.
In a fourth aspect, the present application provides a document processing apparatus, including:
the acquisition module is used for acquiring a third file to be checked and acquiring a hash value corresponding to the third file;
the determining module is used for determining whether the third file is modified according to whether the hash value meets a preset hash characteristic or not; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value.
In a fifth aspect, the present application provides an electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of the first aspects and/or to perform the method of any one of the second aspects.
In a sixth aspect, the present application provides a non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of the first aspect and/or to perform the method of any one of the second aspect.
In a seventh aspect, the present application provides a computer program product comprising: computer program stored in a readable storage medium, from which the computer program can be read by at least one processor of an electronic device, the at least one processor executing the computer program causing the electronic device to perform the method of any one of the first aspects and/or to perform the method of any one of the second aspects.
The application provides a file processing method, a device and equipment, wherein the method comprises the following steps: the file generation device inserts k characters into the first file to generate a second file, so that a hash value corresponding to the second file meets a preset hash characteristic, wherein the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value. Therefore, when the file verification device verifies the file, the file verification device can determine whether the file is modified only by judging whether the hash value of the file meets the preset hash characteristic. In the process, the file generation device implicitly and automatically contains the verification information in the generated file, so that the file verification device can realize verification by only utilizing the existing file, management and maintenance of the initial file or the hash value of the initial file are not needed, the maintenance difficulty is reduced, and the verification efficiency of the file is improved.
It should be understood that the description of this section is not intended to identify key or critical features of the embodiments of the application or to delineate the scope of the application. Other features of the present application will become apparent from the description that follows.
Drawings
The drawings are for better understanding of the present solution and do not constitute a limitation of the present application. Wherein:
FIG. 1 is a schematic diagram of one possible system architecture to which embodiments of the present application are applicable;
fig. 2 is a schematic diagram of a possible application scenario applicable to the embodiment of the present application;
FIG. 3 is a flow chart illustrating a method for processing a file according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a first file and a second file according to an embodiment of the present disclosure;
FIG. 5 is a flowchart illustrating a method for processing a file according to another embodiment of the present disclosure;
FIG. 6 is a flowchart illustrating a method for processing a file according to another embodiment of the present disclosure;
fig. 7A and fig. 7B are a set of schematic diagrams of hash values of a third file according to an embodiment of the present application;
fig. 8A and fig. 8B are another set of schematic diagrams of hash values of a third file according to an embodiment of the present application;
FIG. 9 is a schematic diagram of a document processing apparatus according to an embodiment of the present disclosure;
FIG. 10 is a schematic diagram of a document processing apparatus according to another embodiment of the present disclosure;
fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present application are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present application to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The application provides a file processing method which is applied to the technical fields of file processing, file verification, file security and the like in the field of data processing so as to achieve the purpose of improving file verification efficiency.
Possible system architectures and application scenarios of embodiments of the present application are first described in connection with fig. 1 and 2.
Fig. 1 is a schematic diagram of one possible system architecture to which the embodiments of the present application are applicable. As shown in fig. 1, the file system includes a file generation device, a file use device, and a file verification device. The file generating device is used for generating the file and providing the file to the file using device. By way of example, the file generating device may provide the file to the file using device via network transmission, media copying, and the like in a variety of ways. The file use device may use the file. The file-using device may modify the file during use of the file. The file verification device is used for verifying the file to determine whether the file is modified after self-generation.
In the actual application scenario, any two or all of the file generating device, the file using device and the file checking device may correspond to the same electronic device entity, or may correspond to different electronic device entities. For example, the file use device may also act as a file verification device. Alternatively, the file generating apparatus may also be used as the file using apparatus at the same time. Alternatively, the file generating apparatus may serve as both the file using apparatus and the file verifying apparatus. The embodiments of the present application are not limited in this regard.
The system architecture shown in fig. 1 is applicable to a variety of scenarios in which verification of a file is required. For example, the method can be applied to a version management scene for checking the version file; the method can also be applied to a contract management scene for checking the contract file; of course, the method can also be applied to other similar application scenarios, which are not listed here. The version management scenario is described below in connection with fig. 2 as an example.
Fig. 2 is a schematic diagram of a possible application scenario applicable to the embodiment of the present application. As shown in fig. 2, the application scenario includes: version file generation device and version file use device. Wherein the version file generating device may also be referred to as version file issuing device. The version file generation device is used for generating a version file and providing the version file to the version file use device. Version control software is also typically provided in the version file generating device and may be used to manage the generated version file. In this embodiment, the version file generated by the version file generating device may be in various formats such as a text file and a binary file, which is not limited in this embodiment.
The version file use device may also be referred to as a version file running device. The version file generated by the version file generating device may be deployed in the version file using device, i.e., the version file using device may load, run, etc. the version file. In some application scenarios, the version file using device may also debug, test, etc. the version file. It can be appreciated that during the above-described version file running, debugging, testing, etc., the version file may be modified by the version file use device, or the version file may be manually modified by a debugger.
Since the version file may be modified during use, after the version file using device is operated for a period of time, the version file used by the version file using device may not be the version file originally generated. That is, in fig. 2, the content of version file 2 may be different from that of version file 1. Thus, in some scenarios, it is necessary to check the version file currently used by the version file use device (i.e., version file 2) to determine whether the version file has been modified since the initial generation (i.e., whether the content of the version file 1 was the same as that of the initial release).
It should be noted that, in fig. 2, the case where the version file use device has a version file verification function, that is, the case where the version file use device and the version file verification device correspond to the same electronic device entity is illustrated. Of course, in practical application, the version file use device and the version file verification device may also respectively correspond to different electronic device entities.
In verifying a version file, it is a common practice to keep an initial version file (i.e., version file 1) in a version file use device. The existing version file is compared with the original version file when it is necessary to determine whether or not a certain existing version file (i.e., version file 2) is modified. If the file version file and the file version file are the same, determining that the existing version file is not modified; if the two files are different, the existing version file is determined to be modified.
However, the above-described manner has at least the following problems: version file use devices need to manage and maintain the original version file and need to ensure that the original version file that they maintain is unmodified so that it will be compared as a baseline to the existing version file. When the number of version files used in the version file using device is large, or when different versions of the same version file need to be managed, the version file using device needs to maintain a large number of initial version files, so that on one hand, the maintenance difficulty is increased, and on the other hand, the verification efficiency of the version files is reduced.
Another conventional approach is to maintain a hash value of the original version file in the version file use device. When the verification is needed to be carried out on the existing version file, only the hash value of the existing version file is needed to be calculated, and then the hash value of the original version file maintained by the existing version file is compared with the hash value of the original version file. If the file version file and the file version file are the same, determining that the existing version file is not modified; if the two files are different, the existing version file is determined to be modified. Thus, although the management and maintenance of a large number of initial version files are avoided, the management and maintenance of a large number of hash values are still needed, and the problems of high maintenance difficulty and low verification efficiency of the version files still exist.
In order to solve at least one of the above technical problems, an embodiment of the present application provides a file processing method, where when a version file is generated by a version file generating device, a hash value of the generated version file satisfies a preset hash feature by inserting characters into the version file. Therefore, when the version file using device verifies the existing version file, the verification of the existing version file can be realized only by judging whether the hash value of the existing version file meets the preset hash characteristic. In the process, the generated version file implicitly contains the verification information, so that verification can be realized by only utilizing the existing version file, management and maintenance of the initial version file or the hash value of the initial version file are not needed, the maintenance difficulty is reduced, and the verification efficiency of the version file is improved.
The following describes the technical solutions of the present application and how the technical solutions of the present application solve the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 3 is a flow chart of a file processing method according to an embodiment of the present application. The method of the present embodiment may be performed by a file generating apparatus. As shown in fig. 3, the method of the present embodiment includes:
s301: and acquiring a first file to be processed.
S302: inserting k characters into the first file to generate a second file, wherein a hash value corresponding to the second file meets preset hash characteristics; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value, and k is a natural number which is greater than or equal to 1.
In this embodiment, the first file refers to a file generated by the file generating apparatus according to an existing file generating manner. The second file refers to a file obtained by the file generating apparatus by performing character insertion processing on the first file. The second file is a file for publishing.
The present embodiment is different from the prior art in that the first file is directly released, that is, provided to the file use device, after the first file is generated by the file generation device in the prior art. In the embodiment, after the first file is generated by the file generating device, the first file is not directly issued, but the first file is subjected to character insertion processing to generate a second file, and the second file is provided to the file using device.
When the embodiment is applied to different application scenarios, the first file may be a file of a different type. For example, when applied to a version management scenario as shown in fig. 2, the first file may be a version file. When applied to the contract management scenario, the first file may be a contract file.
Alternatively, the first file may be a text file.
Alternatively, the first file may be a binary file.
In this embodiment, k characters are inserted into the first file to generate a second file, so that a hash value corresponding to the second file meets a preset hash characteristic. For convenience of description, the original characters in the first file may be referred to as "valid characters", and the inserted k characters may be referred to as "pad characters", or "padding characters". Thus, the generated second file includes both valid characters and filler characters.
In one example, fig. 4 is a schematic diagram of a first file and a second file provided in an embodiment of the present application. Fig. 4 (a) illustrates a first file, and fig. 4 (b) illustrates a second file. The characters in the dashed box of the second file are k characters inserted in the embodiment.
In practical application, k characters may be inserted at any position of the first file, which is not limited in this embodiment. In fig. 4, k characters are inserted at the end of the first file.
It should be understood that there are various ways to insert k characters in the first file, and various insertion strategies may be used to perform the insertion attempt until the hash value corresponding to the generated second file meets the preset hash feature.
In this embodiment, the preset hash feature refers to a feature that is satisfied by the hash value of the second file. The file generating device ensures that the hash value of the generated and released second file meets the preset hash characteristic. In this way, the file verification device may determine whether the file to be verified is modified by determining whether the hash value of the file to be verified satisfies the preset hash characteristic. It should be understood that the preset hash feature may be agreed upon by the file generating apparatus and the file verifying apparatus, or may be specified by one of them and then notified to the other.
Specifically, the preset hash characteristic indicates a value characteristic of at least part of characters in the hash value of the second file.
For example, assuming that the hash value corresponding to the second file includes m characters, the preset hash feature may indicate a value of n characters among the m characters. n is less than or equal to m.
It should be appreciated that the n characters may be any n characters in the hash value. For example, the first n characters of the hash value may be the first n characters of the hash value, the last n characters of the hash value, or the middle n characters. Of course, the n characters may also be discontinuous, for example, assuming n=5, the n characters may be the 1 st, 3 rd, 5 th, 7 th, 9 th, and 2 nd, 4 th, 6 th, 8 th, 10 th characters in the hash value.
It should be understood that the preset hash feature may be any feature that is pre-agreed or specified, which is not limited in this embodiment. Several possible embodiments are illustrated below.
In a possible implementation manner, the preset hash feature is specifically used for indicating that at least part of characters in the hash value are consistent with preset characters. For example, the preset hash feature may indicate that the first 5 characters in the hash value are "00000". For another example, the preset hash feature may indicate that the first 5 characters in the hash value are "12a0A".
In another possible implementation manner, the preset hash feature is specifically used to indicate that at least part of characters in the hash value are consistent with characters in a preset position in the second file. For example: in connection with the example shown in fig. 4, the second file includes a "Version" field, which has a value of "1.2.3.4". The preset hash feature may indicate that the first n characters in the hash value are consistent with the value corresponding to the "Version" field in the second file. In one example, the preset hash feature may indicate that the first 4 characters in the hash value are "1234"; in another example, the preset hash feature may indicate that the first 7 characters in the hash value are "1.2.3.4".
In yet another possible embodiment, the two possible embodiments described above may also be used in combination. The preset hash feature is specifically used for indicating that a first part of characters in the hash value are consistent with preset characters, and a second part of characters are consistent with characters at preset positions in the second file. For example: the preset hash feature may indicate that the 1 st character in the hash value is "a", and the 2 nd to 5 th characters are consistent with the value corresponding to the "Version" field in the second file, that is, the 2 nd to 5 th characters are "1234".
In this embodiment, when the preset hash feature is agreed or specified, the value of n may be considered as follows. On the one hand, the collision probability refers to the probability that two different hash values meet the preset hash feature. If the value of n is too small, namely the number of the appointed matched characters is too small, the collision probability is increased. In this way, the file verification device may in some cases be considered unmodified when performing the verification, so that the accuracy of the verification result is reduced. On the other hand, if the value of n is too large, that is, the number of specified matching characters is too large, difficulty in finding a character insertion scheme increases, so that the processing efficiency of the file generating apparatus decreases. In the two aspects, n can be 5 or 6, so that the processing efficiency of the file generating equipment and the accuracy of the verification result of the file verification equipment can be considered, and most application requirements can be met.
According to the file processing method provided by the embodiment, the file generating device inserts k characters into the first file to generate the second file, so that the hash value corresponding to the second file meets the preset hash characteristic, wherein the preset hash characteristic is used for indicating the value characteristic of at least part of the characters in the hash value. Therefore, when the file verification device verifies the file, the file verification device can determine whether the file is modified only by judging whether the hash value of the file meets the preset hash characteristic. In the process, the file generation device implicitly and automatically contains the verification information in the generated file, so that the file verification device can realize verification by only utilizing the existing file, management and maintenance of the initial file or the hash value of the initial file are not needed, the maintenance difficulty is reduced, and the verification efficiency of the file is improved.
Fig. 5 is a flowchart of a file processing method according to another embodiment of the present application. This embodiment refines the embodiment shown in fig. 3. As shown in fig. 5, the method of the present embodiment includes:
s501: and acquiring a first file to be processed.
S502: and determining k inserted character positions in the first file, and determining k candidate characters.
For example, a random strategy may be employed to determine the k insert character positions in the first file.
Optionally, the k insert character positions are consecutive. When the k insert character positions are consecutive, only the start position of the k insert character positions in the first file needs to be determined. For example, the start position of the k inserted character positions in the first file is the 1 st character, or the 10 th character, or the position after the last 1 character, or the like.
The positions of the k continuous inserted characters are determined in the first file, so that the positions of the k filled characters in the second file after filling are continuous, the continuity of the effective characters in the second file is not greatly influenced, and the readability of the effective characters in the second file is ensured.
Further, after determining the k insert character positions, k candidate characters are further determined. For example, a random strategy may be employed to randomly determine k candidate characters among all fillable characters. For example, taking a text file as an example, all fillable characters include, but are not limited to: 26 lower case letters, 26 upper case letters, 10 numbers, symbols, etc. may display characters. K candidate characters are randomly determined from all the fillable characters.
Optionally, in order to facilitate distinguishing the pad character from the valid character in the second file, the first preset number of characters in the k candidate characters and/or the last preset number of characters may be set as a fixed character. For example, in connection with the example shown in fig. 4, the first few characters of the k candidate characters are set to "/Paddings/".
In a possible implementation manner, before S502, the method may further include: and obtaining the type of the first file, and determining the value of k according to the type of the first file. Wherein the file structures corresponding to the different types of files are different.
In this embodiment, the value of the number of characters k filled in may be different for different types of first files. By way of example, certain types of files may have stringent requirements on the structure, for example, requiring a preset number of byte alignments, or having other formatting requirements. In this case, the value of k can be determined according to the requirement of the type of file on the structure, so as to ensure the validity of the generated second file.
Note that, in this embodiment, specific values of k corresponding to different types of files are not limited.
S503: and filling the k candidate characters to the k inserted character positions to obtain a second file.
S504: and obtaining the hash value of the second file.
After k characters are filled in the first file to generate a second file, a hash value of the second file is calculated. It should be understood that the hash value of the second file may be calculated by using a plurality of hash algorithms, which is not limited in this embodiment.
For example, a hash value of the second file may be calculated using a message digest algorithm (Message Digest Algorithm, MD 5).
S505: and judging whether the hash value of the second file meets a preset hash characteristic or not.
If yes, ending, namely determining the second file as the file to be distributed. If not, execution continues with S506.
S506: altering the k insert character positions and/or altering the k candidate characters.
And then, returning to S503 to S505 until the obtained hash value corresponding to the second file meets the preset hash characteristic.
In this embodiment, the file generating apparatus implements the generation of the second file whose hash value satisfies the preset hash characteristic according to the first file through the above-described filling process. Therefore, when the file verification device verifies the file, the file verification device can determine whether the file is modified only by judging whether the hash value of the file meets the preset hash characteristic. In the process, the file generation device implicitly and automatically contains the verification information in the generated file, so that the file verification device can realize verification by only utilizing the existing file, management and maintenance of the initial file or the hash value of the initial file are not needed, the maintenance difficulty is reduced, and the verification efficiency of the file is improved.
Fig. 6 is a flowchart of a file processing method according to another embodiment of the present application. The method of the present embodiment may be performed by a file verification device. As shown in fig. 6, the method of the present embodiment includes:
s601: and obtaining a third file to be checked, and obtaining a hash value corresponding to the third file.
The third file is any file to be verified. And calculating by adopting a hash algorithm to obtain a hash value corresponding to the third file. It should be appreciated that the hash algorithm employed herein is consistent with the hash algorithm employed in the embodiment of fig. 5 when obtaining the hash value of the second file.
S602: determining whether the third file is modified according to whether the hash value meets a preset hash characteristic; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value.
It should be understood that the preset hash feature in this embodiment is consistent with the preset hash feature in the embodiment shown in fig. 3 and 5, and will not be described here. In the implementation process, the preset hash feature may be agreed in advance by the file generating device and the file verifying device, or may be specified by one of the parties and then notified to the other party.
In a possible implementation manner, the preset hash feature is specifically used for indicating that at least part of characters in the hash value are consistent with preset characters.
In another possible implementation manner, the preset hash feature is specifically configured to indicate that at least part of characters in the hash value are consistent with characters in a preset position in the third file.
In yet another possible implementation manner, the preset hash feature is specifically configured to indicate that a first part of characters in the hash value are consistent with preset characters, and a second part of characters are consistent with characters in a preset position in the third file.
Specifically, S602 may specifically include: if the hash value meets the preset hash characteristic, determining that the third file is not modified; and if the hash value does not meet the preset hash characteristic, determining that the third file is modified.
The following is an example with reference to fig. 7A, 7B and fig. 8A, 8B.
Fig. 7A and fig. 7B are a set of schematic diagrams of hash values of a third file according to an embodiment of the present application. In one example, assume that the preset hash feature indicates that the first 5 characters in the hash value corresponding to the third file are "00000". In this case, if the hash value corresponding to the actually calculated third file is as shown in fig. 7A, it is indicated that the third file is unmodified. If the hash value corresponding to the actually calculated third file is as shown in fig. 7B, it is indicated that the third file is modified.
Fig. 8A and fig. 8B are another set of schematic diagrams of hash values of the third file according to the embodiments of the present application. In one example, assume that the preset hash feature indicates that the 1 st character in the hash value corresponding to the third file is "a", and the 2 nd-5 th characters are consistent with the value "1.2.3.4" corresponding to the "Version" field in the third file, that is, the 2 nd-5 th characters are "1234". In this case, if the hash value corresponding to the actually calculated third file is as shown in fig. 8A, it is indicated that the third file is unmodified. If the hash value corresponding to the actually calculated third file is as shown in fig. 8B, it is indicated that the third file is modified.
According to the file processing method provided by the embodiment, when the file verification equipment verifies the file, whether the file is modified can be determined only by judging whether the hash value of the file meets the preset hash characteristic. In the process, the file verification equipment can realize verification by only utilizing the existing file, management and maintenance of the initial file or the hash value of the initial file are not needed, the maintenance difficulty is reduced, and the verification efficiency of the file is improved.
Fig. 9 is a schematic structural diagram of a document processing device according to an embodiment of the present application. The apparatus may be in the form of software and/or hardware. The apparatus may be integrated in a file generating device. As shown in fig. 9, the file processing device 10 provided in this embodiment includes: an acquisition module 11 and a generation module 12.
The acquiring module 11 is configured to acquire a first file to be processed;
the generating module 12 is configured to insert k characters into the first file, generate a second file, where a hash value corresponding to the second file meets a preset hash feature; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value, and k is a natural number which is greater than or equal to 1.
In a possible implementation manner, the generating module 12 is specifically configured to:
determining k insert character positions in the first file, and determining k candidate characters;
and (3) performing a filling process: filling the k candidate characters to the k inserted character positions to obtain a second file;
and acquiring a hash value corresponding to the second file, and if the hash value does not meet the preset hash characteristic, changing the k insert character positions and/or changing the k candidate characters, and returning to execute the filling process until the acquired hash value corresponding to the second file meets the preset hash characteristic.
In one possible implementation, the k insert character positions are consecutive.
In a possible implementation manner, the preset hash feature is specifically configured to indicate that at least part of characters in the hash value are consistent with preset characters; or,
The preset hash feature is specifically configured to indicate that at least part of characters in the hash value are consistent with characters in a preset position in the second file.
In a possible implementation manner, the generating module 12 is further configured to:
acquiring the type of the first file, wherein the file structures corresponding to the files of different types are different;
and determining the value of k according to the type of the first file.
The file processing device provided in this embodiment may be used to execute the file processing method in the embodiment shown in fig. 3 or fig. 5, and its implementation principle and technical effects are similar, and will not be described herein.
Fig. 10 is a schematic structural diagram of a document processing device according to another embodiment of the present application. The apparatus may be in the form of software and/or hardware. The apparatus may be integrated in a file verification device. As shown in fig. 10, the file processing device 20 provided in this embodiment includes: an acquisition module 21 and a determination module 22.
The obtaining module 21 is configured to obtain a third file to be verified, and obtain a hash value corresponding to the third file;
a determining module 22, configured to determine whether the third file is modified according to whether the hash value meets a preset hash characteristic; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value.
In a possible implementation manner, the determining module 22 is specifically configured to:
if the hash value meets the preset hash characteristic, determining that the third file is not modified;
and if the hash value does not meet the preset hash characteristic, determining that the third file is modified.
In a possible implementation manner, the preset hash feature is specifically configured to indicate that at least part of characters in the hash value are consistent with preset characters; or,
the preset hash feature is specifically configured to indicate that at least part of characters in the hash value are consistent with characters in a preset position in the third file.
The file processing device provided in this embodiment may be used to execute the file processing method in the embodiment shown in fig. 6, and its implementation principle and technical effects are similar, and will not be described herein.
According to embodiments of the present application, an electronic device and a readable storage medium are also provided.
According to an embodiment of the present application, there is also provided a computer program product comprising: a computer program stored in a readable storage medium, from which at least one processor of an electronic device can read, the at least one processor executing the computer program causing the electronic device to perform the solution provided by any one of the embodiments described above.
The electronic device provided by the application can be used as a file generation device or a file verification device. The electronic device provided by the application can also serve as file generation equipment and file verification equipment at the same time.
As shown in fig. 11, a block diagram of an electronic device according to a file processing method according to an embodiment of the present application is shown. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the application described and/or claimed herein.
As shown in fig. 11, the electronic device includes: one or more processors 1101, memory 1102, and interfaces for connecting the various components, including a high speed interface and a low speed interface. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the electronic device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In other embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories. Also, multiple electronic devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). In fig. 11, a processor 1101 is taken as an example.
Memory 1102 is a non-transitory computer-readable storage medium provided herein. The memory stores instructions executable by at least one processor to cause the at least one processor to perform the file processing method of the embodiment shown in fig. 3 or fig. 5 and/or to perform the file processing method of the embodiment shown in fig. 6 and provided herein. The non-transitory computer readable storage medium of the present application stores computer instructions for causing a computer to perform the file processing method of the embodiment shown in fig. 3 or fig. 5 provided herein and/or to perform the file processing method of the embodiment shown in fig. 6 provided herein.
The memory 1102 is used as a non-transitory computer readable storage medium, and may be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as program instructions/modules (e.g., the acquisition module 11 and the generation module 12 shown in fig. 9, and/or the acquisition module 21 and the determination module 22 shown in fig. 10) corresponding to the file processing method in the embodiments of the present application. The processor 1101 executes various functional applications of the server and data processing by executing non-transitory software programs, instructions, and modules stored in the memory 1102, that is, implements the file processing method in the method embodiment shown in fig. 3 or fig. 5 and/or implements the file processing method in the method embodiment shown in fig. 6.
Memory 1102 may include a storage program area that may store an operating system, at least one application program required for functionality, and a storage data area; the storage data area may store data created according to the use of the electronic device, etc. In addition, memory 1102 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 1102 may optionally include memory located remotely from the processor 1101, which may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device of the file processing method may further include: an input device 1103 and an output device 1104. The processor 1101, memory 1102, input device 1103 and output device 1104 may be connected by a bus or other means, for example in fig. 11.
The input device 1103 may receive input digital or character information and generate key signal inputs related to user settings and function control of the electronic device, such as a touch screen, keypad, mouse, trackpad, touchpad, pointer stick, one or more mouse buttons, trackball, joystick, and like input devices. The output device 1104 may include a display device, auxiliary lighting (e.g., LEDs), and haptic feedback (e.g., a vibration motor), among others. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device may be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASIC (application specific integrated circuit), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
These computer programs (also known as programs, software applications, or code) include machine instructions for a programmable processor, and can be implemented in a high-level procedural and/or object-oriented programming language, and/or in assembly/machine language. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present application may be performed in parallel, sequentially, or in a different order, provided that the desired results of the technical solutions disclosed in the present application can be achieved, and are not limited herein.
The above embodiments do not limit the scope of the application. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application are intended to be included within the scope of the present application.

Claims (15)

1. A document processing method, comprising:
acquiring a first file to be processed;
inserting k characters into the first file to generate a second file, wherein a hash value corresponding to the second file meets preset hash characteristics; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value, and k is a natural number which is greater than or equal to 1;
The preset hash feature is specifically used for indicating that at least part of characters in the hash value are consistent with preset characters; or, the preset hash feature is specifically configured to indicate that at least part of characters in the hash value are consistent with characters in a preset position in the second file.
2. The method of claim 1, wherein inserting k characters in the first file, generating a second file, comprises:
determining k insert character positions in the first file, and determining k candidate characters;
and (3) performing a filling process: filling the k candidate characters to the k inserted character positions to obtain a second file;
and acquiring a hash value corresponding to the second file, and if the hash value does not meet the preset hash characteristic, changing the k insert character positions and/or changing the k candidate characters, and returning to execute the filling process until the acquired hash value corresponding to the second file meets the preset hash characteristic.
3. The method of claim 2, wherein the k insert character positions are consecutive.
4. A method according to any one of claims 1 to 3, wherein k characters are inserted in the first file, and before generating a second file, further comprising:
Acquiring the type of the first file, wherein the file structures corresponding to the files of different types are different;
and determining the value of k according to the type of the first file.
5. A document processing method, comprising:
obtaining a third file to be verified, and obtaining a hash value corresponding to the third file, wherein the third file is generated by generating a second file in any one of the modes of claims 1-4;
determining whether the third file is modified according to whether the hash value meets a preset hash characteristic; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value;
the preset hash feature is specifically used for indicating that at least part of characters in the hash value are consistent with preset characters; or, the preset hash feature is specifically configured to indicate that at least part of characters in the hash value are consistent with characters in a preset position in the second file.
6. The method of claim 5, wherein determining whether the third file has been modified based on whether the hash value satisfies a preset hash characteristic comprises:
if the hash value meets the preset hash characteristic, determining that the third file is not modified;
And if the hash value does not meet the preset hash characteristic, determining that the third file is modified.
7. A document processing apparatus comprising:
the acquisition module is used for acquiring a first file to be processed;
the generating module is used for inserting k characters into the first file to generate a second file, and the hash value corresponding to the second file meets the preset hash characteristic; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value, and k is a natural number which is greater than or equal to 1;
the preset hash feature is specifically used for indicating that at least part of characters in the hash value are consistent with preset characters; or, the preset hash feature is specifically configured to indicate that at least part of characters in the hash value are consistent with characters in a preset position in the second file.
8. The apparatus of claim 7, wherein the generating module is specifically configured to:
determining k insert character positions in the first file, and determining k candidate characters;
and (3) performing a filling process: filling the k candidate characters to the k inserted character positions to obtain a second file;
and acquiring a hash value corresponding to the second file, and if the hash value does not meet the preset hash characteristic, changing the k insert character positions and/or changing the k candidate characters, and returning to execute the filling process until the acquired hash value corresponding to the second file meets the preset hash characteristic.
9. The apparatus of claim 8, wherein the k insert character positions are consecutive.
10. The apparatus of any of claims 7 to 9, wherein the generating module is further to:
acquiring the type of the first file, wherein the file structures corresponding to the files of different types are different;
and determining the value of k according to the type of the first file.
11. A document processing apparatus comprising:
the acquisition module is used for acquiring a third file to be verified and acquiring a hash value corresponding to the third file, wherein the third file is generated in a mode that the generation module in any one of claims 7-10 generates a second file;
the determining module is used for determining whether the third file is modified according to whether the hash value meets a preset hash characteristic or not; the preset hash characteristic is used for indicating the value characteristic of at least part of characters in the hash value;
the preset hash feature is specifically used for indicating that at least part of characters in the hash value are consistent with preset characters; or, the preset hash feature is specifically configured to indicate that at least part of characters in the hash value are consistent with characters in a preset position in the second file.
12. The apparatus of claim 11, wherein the determining module is specifically configured to:
if the hash value meets the preset hash characteristic, determining that the third file is not modified;
and if the hash value does not meet the preset hash characteristic, determining that the third file is modified.
13. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 4 and/or to perform the method of any one of claims 5 to 6.
14. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1 to 4 and/or to perform the method of any one of claims 5 to 6.
15. A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1 to 4 and/or performs the method of any one of claims 5 to 6.
CN202010566471.4A 2020-06-19 2020-06-19 File processing method, device and equipment Active CN111737534B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010566471.4A CN111737534B (en) 2020-06-19 2020-06-19 File processing method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010566471.4A CN111737534B (en) 2020-06-19 2020-06-19 File processing method, device and equipment

Publications (2)

Publication Number Publication Date
CN111737534A CN111737534A (en) 2020-10-02
CN111737534B true CN111737534B (en) 2024-04-09

Family

ID=72650399

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010566471.4A Active CN111737534B (en) 2020-06-19 2020-06-19 File processing method, device and equipment

Country Status (1)

Country Link
CN (1) CN111737534B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114084168B (en) * 2021-10-27 2024-06-25 北京百度网讯科技有限公司 Automatic driving system control method, device, electronic equipment and readable storage medium
CN114428765A (en) * 2021-12-31 2022-05-03 北京云宽志业网络技术有限公司 Random file creating method and device, computer equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001134491A (en) * 1999-11-02 2001-05-18 Mitsubishi Electric Corp System for supporting selection of password
CN106612172A (en) * 2016-07-15 2017-05-03 四川用联信息技术有限公司 Data change recovery algorithm capable of restoring data authenticity in cloud storage
CN109145080A (en) * 2018-07-26 2019-01-04 新华三信息安全技术有限公司 A kind of text fingerprints preparation method and device
CN110503434A (en) * 2019-07-15 2019-11-26 平安普惠企业管理有限公司 Data verification method, device, equipment and storage medium based on hash algorithm
CN110555293A (en) * 2019-09-10 2019-12-10 百度在线网络技术(北京)有限公司 Method, apparatus, electronic device and computer readable medium for protecting data
CN110650018A (en) * 2019-09-06 2020-01-03 南京南瑞继保工程技术有限公司 Message tamper-proof method and device
CN111177107A (en) * 2019-12-31 2020-05-19 百度在线网络技术(北京)有限公司 File processing method, device, equipment and storage medium based on block chain

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4810915B2 (en) * 2005-07-28 2011-11-09 日本電気株式会社 Data search apparatus and method, and computer program
US9304944B2 (en) * 2012-03-29 2016-04-05 Broadcom Corporation Secure memory access controller
EP3234792B1 (en) * 2014-12-15 2023-06-07 Royal Bank Of Canada Verification of data processes in a network of computing resources

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001134491A (en) * 1999-11-02 2001-05-18 Mitsubishi Electric Corp System for supporting selection of password
CN106612172A (en) * 2016-07-15 2017-05-03 四川用联信息技术有限公司 Data change recovery algorithm capable of restoring data authenticity in cloud storage
CN109145080A (en) * 2018-07-26 2019-01-04 新华三信息安全技术有限公司 A kind of text fingerprints preparation method and device
CN110503434A (en) * 2019-07-15 2019-11-26 平安普惠企业管理有限公司 Data verification method, device, equipment and storage medium based on hash algorithm
CN110650018A (en) * 2019-09-06 2020-01-03 南京南瑞继保工程技术有限公司 Message tamper-proof method and device
CN110555293A (en) * 2019-09-10 2019-12-10 百度在线网络技术(北京)有限公司 Method, apparatus, electronic device and computer readable medium for protecting data
CN111177107A (en) * 2019-12-31 2020-05-19 百度在线网络技术(北京)有限公司 File processing method, device, equipment and storage medium based on block chain

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Achieving the Capability of a Dictionary Based Data Compression Technique OLZW and its Variants;Utpa Nandi ET AL;《International Journal of Electronics Communication and Computer Engineering》;20141231;第5卷(第4期);全文 *
MD5算法及其在电视节目技术质量控制中的应用;刘元春;;中国有线电视;20101015(10);全文 *
文件同步系统的研究和实现;刘;叶勇;石竹;;信息安全与通信保密;20140210(02);全文 *

Also Published As

Publication number Publication date
CN111737534A (en) 2020-10-02

Similar Documents

Publication Publication Date Title
CN111460429B (en) Task processing method, device, equipment and medium based on trusted execution environment
CN111177107B (en) File processing method, device, equipment and storage medium based on block chain
CN111582375B (en) Data enhancement policy searching method, device, equipment and storage medium
CN107729227B (en) Application program test range determining method, system, server and storage medium
CN111737534B (en) File processing method, device and equipment
CN111523001B (en) Method, device, equipment and storage medium for storing data
CN111782669B (en) Method and device for realizing distributed lock and electronic equipment
EP3862951A2 (en) Method and apparatus of processing deposit, device and storage medium
CN110493009A (en) The generation method and verification method of signature, device, equipment and medium
EP3799449B1 (en) Method, apparatus, and medium for verifying vehicle information
CN111475164B (en) Component dependency relationship detection method and device and electronic equipment
JP7506266B2 (en) Blockchain-based data processing method and device
EP3869377B1 (en) Method and apparatus for data processing based on smart contract, device and storage medium
CN112511505A (en) Authentication system, method, device, equipment and medium
CN112543103B (en) Account address generation method, account address verification method, account address generation device, account address verification device and account address verification medium
US20180268021A1 (en) Identifying corrupted text segments
CN111897782B (en) File control method, device, equipment and storage medium
CN112052347B (en) Image storage method and device and electronic equipment
CN111475572B (en) Block generation method, device, equipment and medium
CN113379421B (en) Information processing and block chain network composition method and device based on block chain
CN111639655B (en) Image local information generation method, device, electronic equipment and storage medium
CN112559497B (en) Data processing method, information transmission method, device and electronic equipment
CN111371557B (en) Block chain data processing method and device, electronic equipment and medium
CN112559547A (en) Method and device for determining consistency among multiple storage object copies
CN111444548A (en) Method, apparatus and computer storage medium for data integrity attestation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant