CN108196975B - Data verification method and device based on multiple checksums and storage medium - Google Patents

Data verification method and device based on multiple checksums and storage medium Download PDF

Info

Publication number
CN108196975B
CN108196975B CN201711171385.8A CN201711171385A CN108196975B CN 108196975 B CN108196975 B CN 108196975B CN 201711171385 A CN201711171385 A CN 201711171385A CN 108196975 B CN108196975 B CN 108196975B
Authority
CN
China
Prior art keywords
data
checksum
memory
verified
memory checksum
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
CN201711171385.8A
Other languages
Chinese (zh)
Other versions
CN108196975A (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.)
Sangfor Technologies Co Ltd
Original Assignee
Sangfor Technologies 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 Sangfor Technologies Co Ltd filed Critical Sangfor Technologies Co Ltd
Priority to CN201711171385.8A priority Critical patent/CN108196975B/en
Publication of CN108196975A publication Critical patent/CN108196975A/en
Application granted granted Critical
Publication of CN108196975B publication Critical patent/CN108196975B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1008Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices
    • G06F11/1012Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices using codes or arrangements adapted for a specific type of error
    • GPHYSICS
    • G06COMPUTING; CALCULATING; 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

Abstract

The invention discloses a data verification method, a device and a storage medium based on multiple checksums, wherein the method comprises the following steps: reading data to be verified and an original memory checksum from a preset type storage unit by acquiring a data reading instruction, wherein the original memory checksum is generated by the data to be verified; generating a current memory checksum according to the data to be verified; and comparing the original memory checksum with the current memory checksum, and verifying the integrity of the data to be verified according to a comparison result. Since the data integrity verification is performed on the data read from the various types of storage units, whether the data is in error or not can be found in time.

Description

Data verification method and device based on multiple checksums and storage medium
Technical Field
The invention relates to the technical field of data verification, in particular to a data verification method and device based on multiple checksums and a storage medium.
Background
Data integrity refers to the state in which all values stored in a database are correct, is a maintenance and guarantee of accuracy and consistency of the data throughout its life, and is critical to the design, implementation, and use of any system that stores, processes, or retrieves data. Therefore, maintaining data integrity is the most important responsibility of modern storage systems, and a variety of techniques have been developed and applied to improve data integrity protection. The most common and popular of which is the checksum method.
The checksum is a small block reference derived from the data block for detecting errors that may be introduced during its transmission or storage. The traditional checksum method aiming at the storage system is generally end-to-end verification, and the checksum protection is used when an application program transmits data to a back-end system interface; and then verified using a checksum until the data is read. Such a checksum method has drawbacks, such as slow error detection, failure to perform checksum verification if data is not returned, and failure to detect data errors in time.
Disclosure of Invention
The invention mainly aims to provide a data verification method, a device and a storage medium based on multiple checksums, and aims to solve the technical problem that data errors cannot be found in time in the prior art.
In order to achieve the above object, the present invention provides a data verification method based on multiple checksums, which comprises the following steps:
acquiring a data reading instruction, and reading data to be verified and an original memory checksum from a preset type storage unit, wherein the original memory checksum is generated by the data to be verified;
generating a current memory checksum according to the data to be verified;
and comparing the original memory checksum with the current memory checksum, and verifying the integrity of the data to be verified according to a comparison result.
Preferably, the preset type storage unit is a memory;
correspondingly, the reading of the data to be verified and the original memory checksum from the preset type storage unit specifically includes:
reading first data and a first memory checksum from the memory, taking the first data as the data to be verified, and taking the first memory checksum as the original memory checksum.
Preferably, before the reading the first data and the first memory checksum from the memory, the multi-checksum-based data verification method further includes:
acquiring first data, receiving a first write-in instruction, generating a first memory checksum according to the first data, and writing the first data and the first memory checksum into the memory.
Preferably, the preset type storage unit is an external memory;
correspondingly, the reading of the data to be verified and the original memory checksum from the preset type storage unit specifically includes:
and reading second data and a second memory checksum from the external memory, taking the second data as the data to be verified, and taking the second memory checksum as the original memory checksum.
Preferably, the reading the second data and the second memory checksum from the external memory specifically includes:
reading second data, a second memory checksum and a first external memory checksum from the external memory;
correspondingly, after the reading of the second data and the second memory checksum from the external memory, taking the second data as the data to be verified and taking the second memory checksum as the original memory checksum, the data verification method based on multiple checksums further includes:
generating a current external memory checksum according to the data to be verified, and comparing the first external memory checksum with the current external memory checksum;
when the first external memory checksum is consistent with the current external memory checksum, determining that the data to be verified is complete;
and when the first external memory checksum is inconsistent with the current external memory checksum, executing the step of generating the current internal memory checksum according to the data to be verified.
Preferably, before the reading of the second data, the second memory checksum, and the first external memory checksum from the external memory, the multi-checksum-based data verification method further includes:
acquiring second data, receiving a second write-in instruction, and generating a second memory checksum and a first external memory checksum according to the second data;
and writing the second data, the second memory checksum and the first external memory checksum into the external memory.
Preferably, after verifying the integrity of the data to be verified according to the comparison result, the data verification method based on multiple checksums further includes:
and when the verification result is that the data to be verified is complete, writing the data to be verified and the original memory checksum into a read cache.
Preferably, before the obtaining of the data reading instruction, the multi-checksum-based data verification method further includes:
receiving an issuing request, and judging whether the issuing request contains the original memory checksum or not;
when the original memory checksum is included, extracting the data to be verified and the original memory checksum from the issued request, and writing the data to be verified and the original memory checksum into the preset type storage unit;
and when the original memory checksum is not included, extracting the data to be verified from the issued request, generating the original memory checksum according to the data to be verified, and writing the data to be verified and the original memory checksum into the preset type storage unit.
In addition, in order to achieve the above object, the present invention further provides a data verification apparatus based on multiple checksums, the apparatus including: a memory, a processor, and a multi-checksum based data validation program stored on the memory and executable on the processor, the multi-checksum based data validation program configured to implement the steps of the multi-checksum based data validation method as described above.
Furthermore, to achieve the above object, the present invention further proposes a storage medium having stored thereon a multi-checksum-based data verification program, which when executed by a processor implements the steps of the multi-checksum-based data verification method as described above.
The data verification method based on the multiple checksums provided by the invention comprises the steps of reading data to be verified and an original memory checksum from a preset type storage unit by acquiring a data reading instruction, wherein the original memory checksum is generated by the data to be verified; generating a current memory checksum according to the data to be verified; and comparing the original memory checksum with the current memory checksum, and verifying the integrity of the data to be verified according to a comparison result. Since the data integrity verification is performed on the data read from the various types of storage units, whether the data is in error or not can be found in time.
Drawings
FIG. 1 is a schematic structural diagram of a data verification device based on multiple checksums in a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a data verification method based on multiple checksums according to a first embodiment of the present invention;
FIG. 3 is a flow chart illustrating a data verification method based on multiple checksums according to a second embodiment of the present invention;
FIG. 4 is a flow chart illustrating a data verification method based on multiple checksums according to a third embodiment of the present invention;
fig. 5 is a schematic flow chart of a data verification method based on multiple checksums according to a fourth embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a data verification apparatus based on multiple checksums in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the multi-checksum-based data verification apparatus may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the apparatus shown in FIG. 1 does not constitute a limitation of multi-checksum-based data verification apparatus and may include more or fewer components than shown, or some components in combination, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a storage medium, may include therein an operating system, a network communication module, a user interface module, and a data verification program based on a multi-checksum.
In the data verification apparatus based on multiple checksums shown in fig. 1, the network interface 1004 is mainly used for connecting an external device and performing data communication with the external device; the user interface 1003 is mainly used for connecting a user terminal and performing data communication with the user terminal; the processor 1001 and the memory 1005 of the multi-checksum-based data verification apparatus of the present invention may be provided in the multi-checksum-based data verification apparatus, which calls the multi-checksum-based data verification program stored in the memory 1005 through the processor 1001 and performs the following operations:
acquiring a data reading instruction, and reading data to be verified and an original memory checksum from a preset type storage unit, wherein the original memory checksum is generated by the data to be verified;
generating a current memory checksum according to the data to be verified;
and comparing the original memory checksum with the current memory checksum, and verifying the integrity of the data to be verified according to a comparison result.
Further, the processor 1001 may call the multi-checksum-based data verification program stored in the memory 1005, and also perform the following operations:
reading first data and a first memory checksum from the memory, taking the first data as the data to be verified, and taking the first memory checksum as the original memory checksum.
Further, the processor 1001 may call the multi-checksum-based data verification program stored in the memory 1005, and also perform the following operations:
acquiring first data, receiving a first write-in instruction, generating a first memory checksum according to the first data, and writing the first data and the first memory checksum into the memory.
Further, the processor 1001 may call the multi-checksum-based data verification program stored in the memory 1005, and also perform the following operations:
and reading second data and a second memory checksum from the external memory, taking the second data as the data to be verified, and taking the second memory checksum as the original memory checksum.
Further, the processor 1001 may call the multi-checksum-based data verification program stored in the memory 1005, and also perform the following operations:
generating a current external memory checksum according to the data to be verified, and comparing the first external memory checksum with the current external memory checksum;
when the first external memory checksum is consistent with the current external memory checksum, determining that the data to be verified is complete;
and when the first external memory checksum is inconsistent with the current external memory checksum, executing the step of generating the current internal memory checksum according to the data to be verified.
Further, the processor 1001 may call the multi-checksum-based data verification program stored in the memory 1005, and also perform the following operations:
acquiring second data, receiving a second write-in instruction, and generating a second memory checksum and a first external memory checksum according to the second data;
and writing the second data, the second memory checksum and the first external memory checksum into the external memory.
Further, the processor 1001 may call the multi-checksum-based data verification program stored in the memory 1005, and also perform the following operations:
and when the verification result is that the data to be verified is complete, writing the data to be verified and the original memory checksum into a read cache.
Further, the processor 1001 may call the multi-checksum-based data verification program stored in the memory 1005, and also perform the following operations:
receiving an issuing request, and judging whether the issuing request contains the original memory checksum or not;
when the original memory checksum is included, extracting the data to be verified and the original memory checksum from the issued request, and writing the data to be verified and the original memory checksum into the preset type storage unit;
and when the original memory checksum is not included, extracting the data to be verified from the issued request, generating the original memory checksum according to the data to be verified, and writing the data to be verified and the original memory checksum into the preset type storage unit.
In the embodiment, data to be verified and an original memory checksum are read from a preset type storage unit by acquiring a data reading instruction, wherein the original memory checksum is generated by the data to be verified; generating a current memory checksum according to the data to be verified; and comparing the original memory checksum with the current memory checksum, and verifying the integrity of the data to be verified according to a comparison result. Since the data integrity verification is performed on the data read from the various types of storage units, whether the data is in error or not can be found in time.
Based on the hardware structure, the embodiment of the data verification method based on multiple checksums is provided.
Referring to fig. 2, fig. 2 is a schematic flow chart of a data verification method based on multiple checksums according to a first embodiment of the present invention.
In a first embodiment, the multi-checksum-based data verification method comprises the following steps:
step S10: acquiring a data reading instruction, and reading data to be verified and an original memory checksum from a preset type storage unit, wherein the original memory checksum is generated by the data to be verified;
it should be noted that the data integrity refers to a state that all values of the data stored in the database are correct, and the checksum is a small block reference derived from the data block and used for detecting the integrity of the data, that is, detecting whether the data is in error during transmission or storage. Generally, data is repeatedly written, stored and read in each storage system, and when a user performs integrity protection on the data, integrity verification is performed on the read data to confirm the integrity of the data. Before the integrity verification is performed on the data, a user reads the data to be verified from a preset type storage unit, where the preset type storage unit includes, but is not limited to, an internal memory, an external memory (magnetic disk, optical disk, etc.), a cache, and the like.
It should be understood that the original memory checksum is generated by calculating the data to be verified through a memory-level checksum algorithm, where the memory-level checksum algorithm refers to a checksum algorithm with high performance, low storage requirement, and low error detection capability, such as CRC-8, Fletcher-16, CRC-16, and the like, and is suitable for calculating a memory checksum on the data in the memory, and calculating a checksum of the data in the memory using the memory-level checksum algorithm, and the method has high adaptability and can meet the data integrity protection requirement and performance requirement of the memory data. And after the original memory checksum is generated, writing the original memory checksum and the data to be verified into the preset type storage unit so as to be used for subsequently reading the data to be verified and the original memory checksum from the preset type storage unit.
Of course, the memory checksum may also perform data integrity verification on the data in the external memory.
Step S20: generating a current memory checksum according to the data to be verified;
it should be noted that, the original memory checksum is generated before the data to be verified is written into the preset type storage unit, and in order to verify the integrity of the data to be verified through the memory checksum, the memory checksum of the data to be verified at the time of writing and reading needs to be obtained, so as to verify whether an error occurs in the time period from writing to reading of the data to be verified. On the premise of obtaining an original memory checksum, generating a current memory checksum according to the read data to be verified, and comparing the original memory checksum with the current memory checksum to verify whether the data to be verified has errors in a period from writing to reading.
Step S30: and comparing the original memory checksum with the current memory checksum, and verifying the integrity of the data to be verified according to a comparison result.
It should be understood that, after the current memory checksum is generated, the original memory checksum and the current memory checksum are compared, where the original memory checksum and the current memory checksum are two memory checksums of data to be verified during writing and during reading, and if the original memory checksum and the current memory checksum are consistent, it indicates that no error occurs in the time period from writing to reading of the data to be verified, and data integrity is maintained, that is, the verification result is that the data to be verified is complete; and if the original memory checksum is inconsistent with the current memory checksum, the data to be verified is wrong in the time period from writing to reading, and the data integrity is damaged, namely the verification result is that the data to be verified is incomplete.
In the embodiment, data to be verified and an original memory checksum are read from a preset type storage unit by acquiring a data reading instruction, wherein the original memory checksum is generated by the data to be verified; generating a current memory checksum according to the data to be verified; and comparing the original memory checksum with the current memory checksum, and verifying the integrity of the data to be verified according to a comparison result. Since the data integrity verification is performed on the data read from the various types of storage units, whether the data is in error or not can be found in time.
Referring to fig. 3, fig. 3 is a schematic flowchart of a second embodiment of the data verification method based on multiple checksums of the present invention, and the second embodiment of the data verification method based on multiple checksums of the present invention is proposed based on the embodiment described in fig. 2.
In this embodiment, the preset type storage unit is a memory;
correspondingly, the step S10 specifically includes:
step S102: reading first data and a first memory checksum from the memory, taking the first data as the data to be verified, and taking the first memory checksum as the original memory checksum.
It should be noted that the Memory includes, but is not limited to, a Random Access Memory (RAM), a Read-Only Memory (ROM), a CACHE Memory (CACHE), and the like, data may pass through different levels of the storage system in the whole life cycle of the Memory, for example, repeatedly write and Read in the storage system such as the Memory, the external Memory, and the CACHE, and for data to be verified stored in different storage units, different verification methods are used for verification, for example, for data in the external Memory, two checksums are used for verification, including an external Memory checksum and a Memory checksum, and for data in the Memory, one checksum is used for verification, including a Memory checksum, to achieve higher verification accuracy.
In this embodiment, data integrity verification is performed on data in the memory.
It will be appreciated that for data read from memory, verification will be performed using the memory checksum, i.e. the memory checksum when the data to be verified is written to memory and when it is read from memory. In this embodiment, data in the memory is referred to as first data, a first memory checksum is generated by the first data before the first data is written into the memory, the first data and the first memory checksum are read after the first data is written into the memory, the first data is used as the data to be verified, and the first memory checksum is used as the original memory checksum, so that the subsequent verification using the memory checksum is facilitated.
Further, before the step S102, the method for verifying data based on multiple checksums further includes:
step S101: acquiring first data, receiving a first write-in instruction, generating a first memory checksum according to the first data, and writing the first data and the first memory checksum into the memory.
It should be understood that the first data is data to be written into the memory, and the first write command refers to writing the first data into the memory, and the first data is necessarily written into the memory before the first data is read from the memory. For data in the memory, verification needs to be performed through a memory checksum, so that before the first data is written into the memory, a first memory checksum is generated through a memory-level checksum algorithm, and then the first memory checksum and the first data are written into the memory.
For example, in acquiring the first data d1Then, receiving a first write-in instruction, and generating a first memory checksum c according to a memory-level checksum algorithm1The first data d is processed1And writing the first memory checksum into the memory. After a period of time, receiving a data reading instruction input by a user, and reading first data d from the memory1And a first memory checksum c1The first data d1As the data to be verified, the first memory checksum c1As the original memory checksum. Data d to be verified according to the memory-level checksum algorithm1Calculating to generate current memory check sum c1', check the original memory by c1Check sum with current memory c1' A comparison was made. When c is going to1=c1When the first data is read out, the integrity of the data is maintained, and no error occurs. When c is going to1≠c1When the data is read, the first data is read, the integrity of the data is damaged, and an error occurs.
In this embodiment, when the preset type storage unit is a memory, first data is acquired, a first write instruction is received, the first memory checksum is generated according to the first data, and the first data and the first memory checksum are written into the memory; reading first data and a first memory checksum from the memory, taking the first data as the data to be verified, and taking the first memory checksum as the original memory checksum. And generating a current memory checksum according to the data to be verified, and verifying the integrity of the data to be verified by comparing the original memory checksum with the current memory checksum. Because the data integrity verification is carried out on the data in the memory, whether the data have errors or not can be found in time.
Referring to fig. 4, fig. 4 is a schematic flowchart of a data verification method based on multiple checksums according to a third embodiment of the present invention, and the third embodiment of the data verification method based on multiple checksums according to the embodiment described in fig. 2 is provided.
In this embodiment, the preset type storage unit is an external memory;
correspondingly, the step S10 specifically includes:
step S104: and reading second data and a second memory checksum from the external memory, taking the second data as the data to be verified, and taking the second memory checksum as the original memory checksum.
In this embodiment, data integrity verification is performed on the data in the external memory.
It is understood that the external memory can be a hard disk, an optical disk, a magnetic tape or other external data verification device based on multiple checksums, and the data read from the external memory can be verified by using the memory checksums, i.e. by using the memory checksums when the data to be verified is written into the memory and when the data is read from the memory. In this embodiment, data in the external memory is referred to as second data, a second memory checksum is generated by the second data before the second data is written into the memory, the second data and the second memory checksum are read after the second data is written into the memory, the second data is used as the data to be verified, and the second memory checksum is used as the original memory checksum, so that the external memory checksum is conveniently used for verification in the subsequent process.
Further, the reading the second data and the second memory checksum from the external memory specifically includes:
reading second data, a second memory checksum and a first external memory checksum from the external memory;
it can be understood that, for data read from the external memory, the verification effect is better to perform verification by using the memory checksum and the external memory checksum, and the second data, the second memory checksum, and the first external memory checksum in the external memory are obtained in advance, so as to perform integrity verification on the second data by using the second memory checksum and the first external memory checksum.
Correspondingly, after the step S104, the multi-checksum-based data verification method further includes:
step S105: generating a current external memory checksum according to the data to be verified, and comparing the first external memory checksum with the current external memory checksum;
step S106: when the first external memory checksum is consistent with the current external memory checksum, determining that the data to be verified is complete;
and when the first external memory checksum is inconsistent with the current external memory checksum, executing the step of generating the current internal memory checksum according to the data to be verified.
It can be understood that when the data to be verified is read from the memory, the data integrity verification is performed only through the memory checksum, and when the data to be verified is read from the external memory, the data integrity verification is performed through two checksums, namely, the external memory checksum algorithm and the memory checksum, wherein the external memory level checksum algorithm refers to a checksum algorithm with low performance, high storage requirement and high error detection capability, such as Adler-32, CRC-32, MD5, SHA-1, and the like, and is suitable for the data in the external memory, and the checksum algorithm used for calculating the checksum of the data in the external memory is high in adaptability and can meet the data integrity protection requirement and performance requirement of the external memory data. And the current external memory checksum is generated by calculating the data through an external memory level checksum algorithm when the data is read.
It is to be understood that the first external memory checksum and the current external memory checksum are two external memory checksums of the second data when being written into the external memory and when being read from the external memory, and when the first external memory checksum and the current external memory checksum are consistent, it indicates that no error occurs in the second data during the period from being written into the external memory to being read from the external memory, and data integrity is maintained, i.e., the data to be verified (the second data) is verified to be complete. When the first external memory checksum is inconsistent with the current external memory checksum, two situations exist, the first situation is that the data to be verified has errors, the second situation is that the first external memory checksum has errors in the writing or storing process, and when the first external memory checksum is inconsistent with the current external memory checksum, the step of generating the current memory checksum according to the data to be verified is executed, that is, whether the data to be verified has errors is verified through the memory checksum. And if the original memory checksum is consistent with the current memory checksum, verifying that the data to be verified is complete.
Further, before the step S104, the method for verifying data based on multiple checksums further includes:
step S103: acquiring second data, receiving a second write-in instruction, and generating a second memory checksum and a first external memory checksum according to the second data;
and writing the second data, the second memory checksum and the first external memory checksum into the external memory.
It is understood that the second data is data to be written into the external memory, and the second write command refers to writing the second data into the external memory, and the second data is necessarily written into the external memory before the second data is read from the external memory. For data in the external memory, the data needs to be verified through external memory checksum verification and internal memory checksum, so that before the second data is written into the external memory, a second internal memory checksum is generated through an internal memory-level checksum algorithm, a first external memory checksum is generated through an external memory-level checksum algorithm, and then the second data, the second internal memory checksum and the first external memory checksum are written into the external memory.
For example, in acquiring the second data d2Then, receiving a second write command, and generating a second memory checksum c according to the memory-level checksum algorithm2And a first external memory checksum c3The second data d is added2The second memory checksum c2And a first external memory checksum c3And writing into an external memory. After a period of time, receiving a data reading instruction input by a user, and reading the second data d from the external memory2The second memory checksum c2And a first external memory checksum c3Second data d2As the data to be verified, the second memory checksum c2As the original memory checksum. Data d to be verified according to the external memory level checksum algorithm2Calculating to generate current external memory check sum c3', the first external memory checksum c3Check sum c with current external memory3' A comparison was made. When c is going to3=c3When the second data is read, the integrity of the second data is maintained, and no error occurs. When c is going to3≠c3In the case of 'time', it is stated that the written second data is different from the read data to be verified, or the first external memory checksum c3An error occurs during writing or storing. When c is going to3≠c3' in time, treat the data d to be verified according to the memory level checksum algorithm2Calculating to generate current memory check sum c1', check the original memory by c1Check sum with current memory c1' A comparison was made. When c is going to1=c1When the second data is read, the integrity of the second data is maintained, and no error occurs. When c is going to1≠c1When the data is verified, the written second data is different from the read data to be verified, the integrity of the data is damaged, and the data is sentAn error is generated.
It should be noted that the memory is generally a random access memory, and data will disappear after power is off, so that after the data is used up, the data will be written into the disk for permanent storage. When the first data read from the internal memory is verified to be complete, the first data can be written into the external memory, so that when the first data is read from the external memory, the first data can be verified by using the external memory checksum. When the verification of the first data read from the memory is incomplete, which indicates that the first data has an error, other measures, such as data recovery, should be taken, but the first data cannot be directly written into the external memory for storage and use.
In this embodiment, when the preset type storage unit is an external memory, second data is acquired, a second write instruction is received, the second memory checksum and the first external memory checksum are generated according to the second data, and the second data, the second memory checksum and the first external memory checksum are written into the external memory; after receiving a data reading instruction, reading second data, the second memory checksum and the first external memory checksum from the memory, taking the second data as the data to be verified, and taking the second memory checksum as the original memory checksum; and generating a current internal memory checksum and a current external memory checksum according to the data to be verified, and verifying the integrity of the data to be verified by comparing the first external memory checksum with the current external memory checksum, and comparing the original internal memory checksum with the current internal memory checksum. Because the two checksums are used for data integrity verification of the external and internal data at the same time, whether the data are wrong or not can be found in time, whether the external memory checksum is wrong or not can be detected, and the probability of wrong judgment caused by the wrong checksum is reduced.
Referring to fig. 5, fig. 5 is a schematic flowchart of a fourth embodiment of the data verification method based on multiple checksums of the present invention, and the fourth embodiment of the data verification method based on multiple checksums of the present invention is proposed based on the embodiment described in fig. 2.
In this embodiment, after step S30, the method for verifying data based on multiple checksums further includes:
step S40: and when the verification result is that the data to be verified is complete, writing the data to be verified and the original memory checksum into a read cache.
It can be understood that, when the verification result is that the data to be verified is complete, the data to be verified and the original memory checksum may be stored in the cache, so that when the next verification requires the same data to be verified and original memory checksum, it is not necessary to read the data from the external memory or the internal memory again, and it is also not necessary to calculate the data again, thereby reducing the calculation overhead and increasing the speed.
Further, before the step S10, the method for verifying data based on multiple checksums further includes:
receiving an issuing request, and judging whether the issuing request contains the original memory checksum or not;
when the original memory checksum is included, extracting the data to be verified and the original memory checksum from the issued request, and writing the data to be verified and the original memory checksum into the preset type storage unit;
and when the original memory checksum is not included, extracting the data to be verified from the issued request, generating the original memory checksum according to the data to be verified, and writing the data to be verified and the original memory checksum into the preset type storage unit.
It should be noted that, due to the read-write experience of the data to be verified in the storage system before, the data to be verified and the original memory checksum of the data to be verified may already be stored, and when the original memory checksum is not stored, the original memory checksum needs to be generated according to the data to be verified; when the original memory checksum is stored, the checksum calculation of the data to be verified is not performed any more, but the original memory checksum in the issued request is directly extracted, so that the calculation process can be reduced.
It can be understood that the issued request necessarily includes data to be verified, and may include an original memory checksum, and to achieve the purpose of reducing the calculation process, it is determined whether the issued request includes the original memory checksum. When the issued request comprises an original memory checksum, directly extracting data to be verified and the original memory checksum from the issued request, and writing the data to be verified and the original memory checksum into the preset type storage unit for subsequent reading and verification of the data to be verified and the original memory checksum. When the issuing request does not contain the original memory checksum, the data to be verified are extracted from the issuing request, the original memory checksum is generated according to the data to be verified, and the data to be verified and the original memory checksum are written into the preset type storage unit for subsequent reading and verification of the data to be verified and the original memory checksum.
In the embodiment, when the verification result is that the data to be verified is complete, the data to be verified and the original memory checksum are written into the cache, and the original memory checksum is not calculated any more in the next data integrity verification, so that the verification process can be simplified; when data is written in, whether the original memory checksum is contained in the issued request is judged, and when the original memory checksum is contained, the original memory checksum does not need to be calculated again, so that the calculation cost is reduced.
In addition, an embodiment of the present invention further provides a storage medium, where a data verification program based on multiple checksums is stored on the storage medium, and when executed by a processor, the data verification program based on multiple checksums implements the following operations:
acquiring a data reading instruction, and reading data to be verified and an original memory checksum from a preset type storage unit, wherein the original memory checksum is generated by the data to be verified;
generating a current memory checksum according to the data to be verified;
and comparing the original memory checksum with the current memory checksum, and verifying the integrity of the data to be verified according to a comparison result.
Further, the multi-checksum based data verification program when executed by the processor further performs the following operations:
reading first data and a first memory checksum from the memory, taking the first data as the data to be verified, and taking the first memory checksum as the original memory checksum.
Further, the multi-checksum based data verification program when executed by the processor further performs the following operations:
acquiring first data, receiving a first write-in instruction, generating a first memory checksum according to the first data, and writing the first data and the first memory checksum into the memory.
Further, the multi-checksum based data verification program when executed by the processor further performs the following operations:
and reading second data and a second memory checksum from the external memory, taking the second data as the data to be verified, and taking the second memory checksum as the original memory checksum.
Further, the multi-checksum based data verification program when executed by the processor further performs the following operations:
generating a current external memory checksum according to the data to be verified, and comparing the first external memory checksum with the current external memory checksum;
when the first external memory checksum is consistent with the current external memory checksum, determining that the data to be verified is complete;
and when the first external memory checksum is inconsistent with the current external memory checksum, executing the step of generating the current internal memory checksum according to the data to be verified.
Further, the multi-checksum based data verification program when executed by the processor further performs the following operations:
acquiring second data, receiving a second write-in instruction, and generating a second memory checksum and a first external memory checksum according to the second data;
and writing the second data, the second memory checksum and the first external memory checksum into the external memory.
Further, the multi-checksum based data verification program when executed by the processor further performs the following operations:
and when the verification result is that the data to be verified is complete, writing the data to be verified and the original memory checksum into a read cache.
Further, the multi-checksum based data verification program when executed by the processor further performs the following operations:
receiving an issuing request, and judging whether the issuing request contains the original memory checksum or not;
when the original memory checksum is included, extracting the data to be verified and the original memory checksum from the issued request, and writing the data to be verified and the original memory checksum into the preset type storage unit;
and when the original memory checksum is not included, extracting the data to be verified from the issued request, generating the original memory checksum according to the data to be verified, and writing the data to be verified and the original memory checksum into the preset type storage unit.
In the data verification method based on multiple checksums provided by this embodiment, data to be verified and an original memory checksum are read from a preset type storage unit by obtaining a data reading instruction, where the original memory checksum is generated from the data to be verified; generating a current memory checksum according to the data to be verified; and comparing the original memory checksum with the current memory checksum, and verifying the integrity of the data to be verified according to a comparison result. Since the data integrity verification is performed on the data read from the various types of storage units, whether the data is in error or not can be found in time.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
The use of the words first, second, etc. do not denote any order, and these words may be interpreted as names.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (8)

1. A data verification method based on multiple checksums is characterized in that the data verification method based on multiple checksums comprises the following steps:
acquiring a data reading instruction, and reading data to be verified and an original memory checksum from a preset type storage unit, wherein the original memory checksum is generated by the data to be verified;
generating a current memory checksum according to the data to be verified;
comparing the original memory checksum with the current memory checksum, and verifying the integrity of the data to be verified according to a comparison result;
the preset type storage unit comprises an external memory;
correspondingly, the reading of the data to be verified and the original memory checksum from the preset type storage unit specifically includes:
reading second data, a second memory checksum and a first external memory checksum from the external memory, taking the second data as the data to be verified, and taking the second memory checksum as the original memory checksum;
generating a current external memory checksum according to the data to be verified, and comparing the first external memory checksum with the current external memory checksum;
when the first external memory checksum is consistent with the current external memory checksum, determining that the data to be verified is complete;
and when the first external memory checksum is inconsistent with the current external memory checksum, executing the step of generating the current internal memory checksum according to the data to be verified.
2. The multi-checksum-based data verification method of claim 1, wherein the predetermined type of storage unit is a memory;
correspondingly, the reading of the data to be verified and the original memory checksum from the preset type storage unit specifically includes:
reading first data and a first memory checksum from the memory, taking the first data as the data to be verified, and taking the first memory checksum as the original memory checksum.
3. The multi-checksum-based data verification method of claim 2, wherein before reading the first data and the first memory checksum from the memory, the multi-checksum-based data verification method further comprises:
acquiring first data, receiving a first write-in instruction, generating a first memory checksum according to the first data, and writing the first data and the first memory checksum into the memory.
4. The multi-checksum-based data verification method of claim 1, wherein before reading the second data, the second memory checksum, and the first external memory checksum from the external memory, the multi-checksum-based data verification method further comprises:
acquiring second data, receiving a second write-in instruction, and generating a second memory checksum and a first external memory checksum according to the second data;
and writing the second data, the second memory checksum and the first external memory checksum into the external memory.
5. The multi-checksum-based data verification method of any of claims 1-4, wherein after verifying the integrity of the data to be verified according to the comparison result, the multi-checksum-based data verification method further comprises:
and when the verification result is that the data to be verified is complete, writing the data to be verified and the original memory checksum into a read cache.
6. The multi-checksum-based data verification method of claim 5, wherein prior to obtaining the data read instruction, the multi-checksum-based data verification method further comprises:
receiving an issuing request, and judging whether the issuing request contains the original memory checksum or not;
when the original memory checksum is included, extracting the data to be verified and the original memory checksum from the issued request, and writing the data to be verified and the original memory checksum into the preset type storage unit;
and when the original memory checksum is not included, extracting the data to be verified from the issued request, generating the original memory checksum according to the data to be verified, and writing the data to be verified and the original memory checksum into the preset type storage unit.
7. A multi-checksum-based data verification apparatus, the apparatus comprising: a memory, a processor, and a multi-checksum based data validation program stored on the memory and executable on the processor, the multi-checksum based data validation program configured to implement the steps of the multi-checksum based data validation method of any of claims 1-6.
8. A storage medium having stored thereon a multi-checksum-based data verification program, which when executed by a processor implements the steps of the multi-checksum-based data verification method of any of claims 1 to 6.
CN201711171385.8A 2017-11-21 2017-11-21 Data verification method and device based on multiple checksums and storage medium Active CN108196975B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711171385.8A CN108196975B (en) 2017-11-21 2017-11-21 Data verification method and device based on multiple checksums and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711171385.8A CN108196975B (en) 2017-11-21 2017-11-21 Data verification method and device based on multiple checksums and storage medium

Publications (2)

Publication Number Publication Date
CN108196975A CN108196975A (en) 2018-06-22
CN108196975B true CN108196975B (en) 2021-09-17

Family

ID=62573184

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711171385.8A Active CN108196975B (en) 2017-11-21 2017-11-21 Data verification method and device based on multiple checksums and storage medium

Country Status (1)

Country Link
CN (1) CN108196975B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109800104A (en) * 2018-12-18 2019-05-24 盛科网络(苏州)有限公司 Detection method, device, storage medium and the electronic device of data storage
CN109816525A (en) * 2018-12-27 2019-05-28 石更箭数据科技(上海)有限公司 A kind of data processing method and its device, medium, terminal

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1397950A (en) * 2002-08-30 2003-02-19 交大铭泰(北京)软件有限公司 Method for strong holographic data on magnetic disc and method for restoring its lost data
CN1758268A (en) * 2004-10-08 2006-04-12 富士通株式会社 Biometric authentication method and biometric authentication apparatus
CN101561795A (en) * 2009-05-20 2009-10-21 中兴通讯股份有限公司 Method and device for synchronizing data in distribution-type system
CN102081577A (en) * 2011-01-12 2011-06-01 厦门雅迅网络股份有限公司 Data storage structure of Flash memory and data manipulation mode thereof
CN104216791A (en) * 2013-05-30 2014-12-17 上海斐讯数据通信技术有限公司 Flash stored data verifying method
CN105183579A (en) * 2015-09-24 2015-12-23 联想(北京)有限公司 Data check method and device and electronic equipment
CN105262589A (en) * 2014-07-16 2016-01-20 阿里巴巴集团控股有限公司 Data security check method and apparatus and check device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9501350B2 (en) * 2014-09-22 2016-11-22 Empire Technology Development Llc Detecting unidirectional resistance drift errors in a multilevel cell of a phase change memory
CN106484503B (en) * 2015-08-27 2019-10-18 深圳市中兴微电子技术有限公司 A kind of calculation method and network processing unit verifying sum
US10108489B2 (en) * 2015-10-28 2018-10-23 Avago Technologies General Ip (Singapore) Pte. Ltd. Systems and methods for efficient soft data based flash memory data recovery
CN107194250A (en) * 2017-03-31 2017-09-22 武汉斗鱼网络科技有限公司 The integrity checking method and device of internal storage code
CN107220141B (en) * 2017-05-26 2021-06-22 海信视像科技股份有限公司 Data file checking method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1397950A (en) * 2002-08-30 2003-02-19 交大铭泰(北京)软件有限公司 Method for strong holographic data on magnetic disc and method for restoring its lost data
CN1758268A (en) * 2004-10-08 2006-04-12 富士通株式会社 Biometric authentication method and biometric authentication apparatus
CN101561795A (en) * 2009-05-20 2009-10-21 中兴通讯股份有限公司 Method and device for synchronizing data in distribution-type system
CN102081577A (en) * 2011-01-12 2011-06-01 厦门雅迅网络股份有限公司 Data storage structure of Flash memory and data manipulation mode thereof
CN104216791A (en) * 2013-05-30 2014-12-17 上海斐讯数据通信技术有限公司 Flash stored data verifying method
CN105262589A (en) * 2014-07-16 2016-01-20 阿里巴巴集团控股有限公司 Data security check method and apparatus and check device
CN105183579A (en) * 2015-09-24 2015-12-23 联想(北京)有限公司 Data check method and device and electronic equipment

Also Published As

Publication number Publication date
CN108196975A (en) 2018-06-22

Similar Documents

Publication Publication Date Title
US9804933B2 (en) System differential upgrade method, apparatus, and mobile terminal
CN102262574B (en) Boot protecting method and device of operating system
CN104461641B (en) A kind of data programming method, system, burn writing equipment and target device
CN107315616B (en) Firmware loading method and device and electronic equipment
CN110058873B (en) Application page updating method, device, equipment and storage medium
CN108196975B (en) Data verification method and device based on multiple checksums and storage medium
CN106776105B (en) System startup file checking and compiling method
CN109814524B (en) Vehicle diagnosis method, device and system
CN105302924A (en) File management method and device
WO2020233044A1 (en) Plug-in verification method and device, and server and computer-readable storage medium
CN104850427B (en) A kind of code upgrade method and device
CN106201640A (en) A kind of method and device of BootLoader program of upgrading
CN105550071A (en) System file upgrading and detecting method and communication device
CN108647119A (en) The startup method, apparatus and equipment of linux system
CN109815697B (en) Method and device for processing false alarm behavior
CN109033818B (en) Terminal, authentication method, and computer-readable storage medium
CN106326310B (en) Resource encryption updating method for mobile phone client software
CN111158948A (en) Data storage and verification method and device based on duplicate removal and storage medium
CN106843947B (en) Method and device for processing code defects
CN108200060B (en) Single sign-on verification method based on web subsystem, server and storage medium
CN111061699A (en) Method and device for updating database version of electric energy meter
CN105590065B (en) Method and device for protecting preset file
US11397662B2 (en) Method for debugging computer program, device employing method, and storage medium
CN106445737A (en) Multi-backup starting method
CN110032505B (en) Software quality determination apparatus and method, and non-transitory computer readable medium

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