CN111835808A - Data storage method and device, data reading method and device, and storage medium - Google Patents

Data storage method and device, data reading method and device, and storage medium Download PDF

Info

Publication number
CN111835808A
CN111835808A CN201910709205.XA CN201910709205A CN111835808A CN 111835808 A CN111835808 A CN 111835808A CN 201910709205 A CN201910709205 A CN 201910709205A CN 111835808 A CN111835808 A CN 111835808A
Authority
CN
China
Prior art keywords
data
identification code
stored
code
unique identification
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.)
Granted
Application number
CN201910709205.XA
Other languages
Chinese (zh)
Other versions
CN111835808B (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 Qisheng Technology Co Ltd
Original Assignee
Beijing Qisheng 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 Qisheng Technology Co Ltd filed Critical Beijing Qisheng Technology Co Ltd
Priority to CN201910709205.XA priority Critical patent/CN111835808B/en
Publication of CN111835808A publication Critical patent/CN111835808A/en
Application granted granted Critical
Publication of CN111835808B publication Critical patent/CN111835808B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a data storage method and device, a data reading method and device, an electronic device and a storage medium, which can perform double encryption and coding through hash codes and attribute information of data to be stored to generate a unique identification code of the data to be stored, and store the unique identification code in a block link point. Therefore, the reliability of data on the chain can be improved, the data storage of the storage database is used as a main data storage, and the data storage of the block chain is used as an auxiliary data storage, so that the master-slave backup of the data is better realized, the data backup quantity and the processing quantity can be reduced, the possibility that the data on the chain and the data of the database cannot be detected after being tampered is effectively reduced, the probability of data cheating is reduced, and the convenience, the reliability and the accuracy of data reading are improved.

Description

Data storage method and device, data reading method and device, and storage medium
Technical Field
The present application relates to the field of big data technologies, and in particular, to a data storage method and a data storage method apparatus corresponding thereto, a data reading method and a data reading apparatus corresponding thereto, and a computer-readable storage medium.
Background
At present, with the rapid development of the internet, a large amount of data is generated in various industries every day, such as finance, medical treatment, education and the like, and the data is exponentially increased. As a large amount of data is generated, the security of the data is vulnerable, and due to the large amount of data, the complexity, difficulty and the like of querying the data after storage are improved, so that the data is not easy to be perceived after being modified intentionally or unintentionally, and the security of the data is greatly influenced.
Disclosure of Invention
In view of the above, an object of the present application is to provide a data storage method and apparatus, a data reading method and apparatus, and a storage medium, which can generate a unique identifier of data to be stored after performing double encryption and encoding on hash codes and attribute information of the data to be stored, and store the unique identifier in a block link point, so that reliability of the unique identifier can be ensured by a block chain manner, and when a data reading request of a user is received, data reading can be performed on a storage database after passing verification of the unique identifier, thereby improving reliability of data storage of the database.
According to one aspect of the present application, an electronic device may include a storage medium and a processor in communication with the storage medium. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is operated, the processor is communicated with the storage medium through the bus, and when the processor executes the machine-readable instructions, one or more of the following operations can be executed:
acquiring data to be stored, which is stored in a storage database, and generating a hash code of the data to be stored;
generating a unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored;
and writing the unique identification code into the corresponding block chain node.
In some embodiments of the application, the processor, when executing the machine-readable instructions, may perform one or more of the following operations:
respectively generating an attribute code corresponding to each attribute information in at least one attribute information of the data to be stored;
determining a splicing position of each attribute code in the hash codes;
and inserting each attribute code into a corresponding splicing position in the hash code so as to splice the hash code and all the attribute codes to obtain the unique identification code of the data to be stored.
In some embodiments of the application, the processor, when executing the machine-readable instructions, may perform one or more of the following operations:
respectively acquiring the coding length and the coding attribute of each attribute code;
and determining the splicing position of each attribute code in the hash code based on the code length and the code attribute of each attribute code.
In the above embodiment, the attribute information includes at least one of the following information:
the data uploading method comprises the following steps of storing database name information of a database, data name information of data to be stored, data position information of the data to be stored in the database and data uploading party information of the data to be stored.
In some embodiments of the application, the processor, when executing the machine-readable instructions, may perform one or more of the following operations:
and storing the data to be stored and the unique identification code in a storage database in a way of using the unique identification code as a data main key of the data to be stored, or in a way of using the unique identification code as a query keyword of the data to be stored.
In some embodiments of the application, the processor, when executing the machine-readable instructions, may perform one or more of the following operations:
detecting whether the data to be stored is successfully written into a storage database and whether the unique identification code is successfully written into the corresponding block link point;
if the data to be stored fails to be written into the storage database and/or the unique identification code fails to be written into the corresponding block chain node, deleting the data written into the storage database and deleting the identification code written into the block chain node;
and re-executing the steps of acquiring the data to be stored for storing in the database and generating the hash code of the data to be stored.
In some embodiments of the application, the processor, when executing the machine-readable instructions, may perform one or more of the following operations:
in the process of writing the data to be stored into a storage database, if receiving the feedback information of the write error of the data to be stored, determining that the data to be stored is failed to be written into the storage database; or
After the data to be stored is written into the storage database, if the data to be stored cannot be inquired in the storage database or the inquired data is inconsistent with the data to be stored, determining that the data to be stored is not written into the storage database.
In some embodiments of the application, the processor, when executing the machine-readable instructions, may perform one or more of the following operations:
in the process of writing the unique identification code into the block chain node, if the write error feedback information of the unique identification code is received, determining that the unique identification code fails to be written into the block chain node; or
After the unique identification code is written into the blockchain node, if the unique identification code cannot be inquired in the blockchain node or the inquired code is inconsistent with the unique identification code, determining that the unique identification code is failed to be written into the blockchain node.
In some embodiments of the application, the processor, when executing the machine-readable instructions, may perform one or more of the following operations:
acquiring the unique identification code from the blockchain node;
performing data matching in the storage database through the unique identification code;
and if the matched data is inconsistent with the data to be stored or the data cannot be matched from the storage database, determining that the data to be stored in the storage database is tampered.
According to another aspect of the present application, another electronic device is provided that may include a storage medium and a processor in communication with the storage medium. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is operated, the processor is communicated with the storage medium through the bus, and when the processor executes the machine-readable instructions, one or more of the following operations can be executed:
determining a unique identification code of data to be read matched with a data reading request based on the received data information to be read carried in the data reading request of a user and at least one attribute information carried in each identification code stored in a block chain node;
detecting whether data indicated by at least one attribute information in the unique identification code is consistent with data indicated by hash coding in the unique identification code;
and if the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code, reading the data to be read, which is matched with the hash code, from the storage database indicated by the at least one attribute information in the unique identification code.
In some embodiments of the application, the processor, when executing the machine-readable instructions, may perform one or more of the following operations:
determining data information to be read from a received data reading request of a user;
extracting at least one attribute code in each identification code stored in the blockchain node based on the splicing position of each attribute code in the identification code;
determining at least one attribute information carried in each identification code stored in a blockchain node based on at least one attribute code extracted from each identification code;
and determining at least one identification code with the attribute information indicating data consistent with the data indicated by the to-be-read data information from the plurality of identification codes, and determining the identification code as a unique identification code matched with the data reading request.
According to an aspect of the present application, there is provided a data storage method, including:
acquiring data to be stored, which is stored in a storage database, and generating a hash code of the data to be stored;
generating a unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored;
and writing the unique identification code into the corresponding block chain node.
In some embodiments of the present application, the generating a unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored includes:
respectively generating an attribute code corresponding to each attribute information in at least one attribute information of the data to be stored;
determining a splicing position of each attribute code in the hash codes;
and inserting each attribute code into a corresponding splicing position in the hash code so as to splice the hash code and all the attribute codes to obtain the unique identification code of the data to be stored.
In some embodiments of the present application, the determining a splicing position of each attribute code in the hash code includes:
respectively acquiring the coding length and the coding attribute of each attribute code;
and determining the splicing position of each attribute code in the hash code based on the code length and the code attribute of each attribute code.
In the above embodiment, the attribute information includes at least one of the following information:
the data uploading method comprises the following steps of storing database name information of a database, data name information of data to be stored, data position information of the data to be stored in the database and data uploading party information of the data to be stored.
In some embodiments of the present application, after the generating of the unique identification code of the data to be stored based on the hash code and the at least one attribute information of the data to be stored, the data storage method includes:
and storing the data to be stored and the unique identification code in a storage database in a way of using the unique identification code as a data main key of the data to be stored, or in a way of using the unique identification code as a query keyword of the data to be stored.
In some embodiments of the present application, after the storing the association between the data to be stored and the unique identification code in the storage database, and after the writing the unique identification code in the corresponding blockchain node, the data storage method includes:
detecting whether the data to be stored is successfully written into a storage database and whether the unique identification code is successfully written into the corresponding block link point;
if the data to be stored fails to be written into the storage database and/or the unique identification code fails to be written into the corresponding block chain node, deleting the data written into the storage database and deleting the identification code written into the block chain node;
and re-executing the steps of acquiring the data to be stored for storing in the database and generating the hash code of the data to be stored.
In some embodiments of the present application, it is determined that the data to be stored fails to be written to the storage database by:
in the process of writing the data to be stored into a storage database, if receiving the feedback information of the write error of the data to be stored, determining that the data to be stored is failed to be written into the storage database; or
After the data to be stored is written into the storage database, if the data to be stored cannot be inquired in the storage database or the inquired data is inconsistent with the data to be stored, determining that the data to be stored is not written into the storage database.
In some embodiments of the present application, determining that the unique identification code failed to be written to the blockchain node comprises:
in the process of writing the unique identification code into the block chain node, if the write error feedback information of the unique identification code is received, determining that the unique identification code fails to be written into the block chain node; or
After the unique identification code is written into the blockchain node, if the unique identification code cannot be inquired in the blockchain node or the inquired code is inconsistent with the unique identification code, determining that the unique identification code is failed to be written into the blockchain node.
In some embodiments of the present application, after the storing the association between the data to be stored and the unique identification code in the storage database, and after the writing the unique identification code in the corresponding blockchain node, the data storage method includes:
acquiring the unique identification code from the blockchain node;
performing data matching in the storage database through the unique identification code;
and if the matched data is inconsistent with the data to be stored or the data cannot be matched from the storage database, determining that the data to be stored in the storage database is tampered.
According to another aspect of the present application, there is provided a data reading method including:
determining a unique identification code of data to be read matched with a data reading request based on the received data information to be read carried in the data reading request of a user and at least one attribute information carried in each identification code stored in a block chain node;
detecting whether data indicated by at least one attribute information in the unique identification code is consistent with data indicated by hash coding in the unique identification code;
and if the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code, reading the data to be read, which is matched with the hash code, from the storage database indicated by the at least one attribute information in the unique identification code.
In some embodiments of the present application, determining, based on data information to be read carried in a received data read request of a user and at least one attribute information carried in each identification code stored in a blockchain node, a unique identification code of data to be read that matches the data read request includes:
determining data information to be read from a received data reading request of a user;
extracting at least one attribute code in each identification code stored in the blockchain node based on the splicing position of each attribute code in the identification code;
determining at least one attribute information carried in each identification code stored in a blockchain node based on at least one attribute code extracted from each identification code;
and determining at least one identification code with the attribute information indicating data consistent with the data indicated by the to-be-read data information from the plurality of identification codes, and determining the identification code as a unique identification code matched with the data reading request.
According to an aspect of the present application, there is provided a data storage device including:
the hash coding module is used for acquiring data to be stored which is stored in a storage database and generating hash codes of the data to be stored;
the identification code encoding module is used for generating a unique identification code of the data to be stored based on the hash code generated by the hash encoding module and at least one attribute information of the data to be stored;
and the block chain storage module is used for writing the unique identification code generated by the identification code encoding module into a corresponding block chain node.
In some embodiments of the present application, the identification code encoding module is specifically configured to:
respectively generating an attribute code corresponding to each attribute information in at least one attribute information of the data to be stored;
determining a splicing position of each attribute code in the hash codes;
and inserting each attribute code into a corresponding splicing position in the hash code so as to splice the hash code and all the attribute codes to obtain the unique identification code of the data to be stored.
In some embodiments of the present application, the identification code encoding module is further configured to:
respectively acquiring the coding length and the coding attribute of each attribute code;
and determining the splicing position of each attribute code in the hash code based on the code length and the code attribute of each attribute code.
In the above embodiment, the attribute information includes at least one of the following information:
the data uploading method comprises the following steps of storing database name information of a database, data name information of data to be stored, data position information of the data to be stored in the database and data uploading party information of the data to be stored.
In some embodiments of the present application, the data storage device further comprises:
and the uplink data storage module is used for storing the data to be stored and the unique identification code into a storage database in an associated manner by adopting the unique identification code as the data primary key of the data to be stored or adopting the unique identification code as the query keyword of the data to be stored.
In some embodiments of the present application, the data storage device further comprises a write detection module, the write detection module being configured to:
detecting whether the data to be stored is successfully written into a storage database and whether the unique identification code is successfully written into the corresponding block link point;
if the data to be stored fails to be written into the storage database and/or the unique identification code fails to be written into the corresponding block chain node, deleting the data written into the storage database and deleting the identification code written into the block chain node;
and re-executing the steps of acquiring the data to be stored for storing in the database and generating the hash code of the data to be stored.
In some embodiments of the present application, it is determined that the data to be stored fails to be written to the storage database by:
in the process of writing the data to be stored into a storage database, if receiving the feedback information of the write error of the data to be stored, determining that the data to be stored is failed to be written into the storage database; or
After the data to be stored is written into the storage database, if the data to be stored cannot be inquired in the storage database or the inquired data is inconsistent with the data to be stored, determining that the data to be stored is not written into the storage database.
In some embodiments of the present application, determining that the unique identification code failed to be written to the blockchain node comprises:
in the process of writing the unique identification code into the block chain node, if the write error feedback information of the unique identification code is received, determining that the unique identification code fails to be written into the block chain node; or
After the unique identification code is written into the blockchain node, if the unique identification code cannot be inquired in the blockchain node or the inquired code is inconsistent with the unique identification code, determining that the unique identification code is failed to be written into the blockchain node.
In some embodiments of the present application, the data storage device further comprises a data verification module, the data verification module is configured to:
acquiring the unique identification code from the blockchain node;
performing data matching in the storage database through the unique identification code;
and if the matched data is inconsistent with the data to be stored or the data cannot be matched from the storage database, determining that the data to be stored in the storage database is tampered.
According to another aspect of the present application, there is provided a data reading apparatus including:
the identification code determining module is used for determining a unique identification code of the data to be read, which is matched with the data reading request, based on the data information to be read, which is carried in the received data reading request of the user, and at least one attribute information carried in each identification code stored in the block chain node;
the data detection module is used for detecting whether data indicated by at least one attribute information in the unique identification code determined by the identification code determination module is consistent with data indicated by hash codes in the unique identification code;
and the data reading module is used for reading the data to be read matched with the hash code from the storage database indicated by the at least one attribute information in the unique identification code if the data detection module detects that the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code.
In some embodiments of the present application, the identification code determination module is specifically configured to:
determining data information to be read from a received data reading request of a user;
extracting at least one attribute code in each identification code stored in the blockchain node based on the splicing position of each attribute code in the identification code;
determining at least one attribute information carried in each identification code stored in a blockchain node based on at least one attribute code extracted from each identification code;
and determining at least one identification code with the attribute information indicating data consistent with the data indicated by the to-be-read data information from the plurality of identification codes, and determining the identification code as a unique identification code matched with the data reading request.
According to an aspect of the present application, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the data storage method as described above.
According to another aspect of the present application, a computer-readable storage medium is provided, having stored thereon a computer program which, when executed by a processor, performs the steps of the data reading method as described above.
The data storage method and device, the data reading method and device, the electronic device and the storage medium provided by the embodiment of the application acquire data to be stored, which are stored in a storage database, and generate hash codes of the data to be stored; generating a unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored; and writing the unique identification code into the corresponding block chain node. Correspondingly, determining a unique identification code of the data to be read matched with the data reading request based on the data information to be read carried in the received data reading request of the user and at least one attribute information carried in each identification code stored in a block chain node; detecting whether data indicated by at least one attribute information in the unique identification code is consistent with data indicated by hash coding in the unique identification code; and if the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code, reading the data to be read, which is matched with the hash code, from the storage database indicated by the at least one attribute information in the unique identification code.
Compared with the prior art, the method and the device have the advantages that the unique identification code of the data to be stored is generated after double encryption and coding are carried out through the Hash code and the attribute information of the data to be stored, and the unique identification code is stored in the block chain node, so that when a data reading request of a user is received, the unique identification code can be matched through the data information to be read in the data reading request and the attribute information in the identification code stored in the block chain node, and data reading is carried out after the data indicated by the attribute information in the unique identification code and the Hash code are verified to be consistent. Therefore, the reliability of data on the chain can be improved, the data storage of the storage database is used as a main data storage, and the data storage of the block chain is used as an auxiliary data storage, so that the master-slave backup of the data is better realized, the data backup quantity and the processing quantity can be reduced, the possibility that the data on the chain and the data of the database cannot be detected after being tampered is effectively reduced, the probability of data cheating is reduced, the preparation for subsequent data reading is facilitated, and the convenience, the reliability and the accuracy of data reading are also facilitated to be improved.
Furthermore, the splicing position of the attribute codes in the hash codes can be set according to the code length and the code attribute corresponding to the attribute codes of different attribute information, so that the uploaded information of different data is more clear and concise, convenient and fast, and the method is helpful for acquiring different information more conveniently and pertinently in the subsequent data reading process, and is helpful for improving the comparison and reliability of data information.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 is a schematic architecture diagram of a data management system according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a data storage method according to an embodiment of the present application;
FIG. 3 is a schematic flow chart illustrating another data storage method according to an embodiment of the present application;
fig. 4 is a schematic flowchart of a data reading method according to an embodiment of the present application;
referring to fig. 5 to 6, fig. 5 is a diagram illustrating a structure of a data storage device according to an embodiment of the present disclosure;
FIG. 6 is a second block diagram of a data storage device according to an embodiment of the present invention;
fig. 7 is a structural diagram of a data storage device according to an embodiment of the present application.
Detailed Description
In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for illustrative and descriptive purposes only and are not used to limit the scope of protection of the present application. Additionally, it should be understood that the schematic drawings are not necessarily drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be performed out of order, and steps without logical context may be performed in reverse order or simultaneously. One skilled in the art, under the guidance of this application, may add one or more other operations to, or remove one or more operations from, the flowchart.
In addition, the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
In order to enable a person skilled in the art to use the present disclosure, the following embodiments are given in connection with a specific application scenario "storage and reading of data to be stored in a storage database and a blockchain node, respectively". It will be apparent to those skilled in the art that the general principles defined herein may be applied to other embodiments and applications without departing from the spirit and scope of the application. Although the present application primarily describes how to perform storage of blockchain nodes and data reading in a database to be stored for storing to a storage database, it should be understood that this is only one exemplary embodiment.
It should be noted that in the embodiments of the present application, the term "comprising" is used to indicate the presence of the features stated hereinafter, but does not exclude the addition of further features.
One aspect of the present application relates to a data management system. The system can generate the unique identification code of the data to be stored after double encryption and coding are carried out on the Hash code and the attribute information of the data to be stored, and the unique identification code is stored in the block chain node, so that when a data reading request of a user is received, the unique identification code can be matched through the data information to be read in the data reading request and the attribute information in the identification code stored in the block chain node, and data reading is carried out after the data indicated by the attribute information in the unique identification code and the Hash code are verified to be consistent.
It is worth noting that before the application is filed, a large amount of data is generated every day in all industries, the data grows exponentially, and as a large amount of data is generated, the security of the data is vulnerable, and due to the large amount of data, the complexity, difficulty and the like of querying the data after storage are improved, the data is not easy to be perceived after being modified intentionally or unintentionally, and the security of the data is greatly influenced.
However, the data management system provided by the application can improve the reliability of data on the chain, better realize the master-slave backup of the data by using the data storage of the storage database as the master and the data storage of the block chain as the auxiliary, reduce the data backup quantity and the processing quantity, effectively reduce the possibility that the data on the chain and the database data cannot be detected after being tampered, reduce the probability of data cheating, be beneficial to preparing for subsequent data reading, and be beneficial to improving the convenience, reliability and accuracy of data reading.
Fig. 1 is a schematic architecture diagram of a data management system according to an embodiment of the present application. For example, the data management system may be used in industries such as travel (e.g., public travel, rental travel, etc.), finance, education, and so on. The data management system may include one or more of a network 110, an electronic device 120, an electronic device 130, a storage database 140 for traditional data storage, and a blockchain node 150 for blockchain data storage.
Among them, one of the electronic device 120 and the electronic device 130 is a providing-side terminal for providing a service, and the other is a service requester terminal for requesting and receiving a service.
In some embodiments, a processor may be included in both electronic device 120 and electronic device 130. The processor may process information and/or data related to the service request to perform one or more of the functions described herein. In addition, either the electronic device 120 or the electronic device 130 may include a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor communicating with the storage medium via the bus when the electronic device is running, the processor executing the machine-readable instructions to perform the steps of the methods described in the present application, such as the data storage method and the data reading method described below.
In some embodiments, a processor may include one or more processing cores (e.g., a single-core processor (S) or a multi-core processor (S)). Merely by way of example, a Processor may include a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), an Application Specific Instruction Set Processor (ASIP), a Graphics Processing Unit (GPU), a Physical Processing Unit (PPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), a Programmable Logic Device (PLD), a controller, a microcontroller Unit, a Reduced Instruction Set computer (Reduced Instruction Set computer), a microprocessor, or the like, or any combination thereof.
In some embodiments, the device types corresponding to the electronic devices 120 and 130 may be mobile devices, such as smart home devices, wearable devices, smart mobile devices, virtual reality devices, augmented reality devices, or the like, and may also be tablet computers, laptop computers, or built-in devices in motor vehicles, or the like.
In some embodiments, storage database 140 and/or block link point 150 may be connected to network 110 to communicate with one or more components in a data management system (e.g., electronic device 120, electronic device 130, etc.). One or more components in the data management system may access data or instructions stored in storage database 140 and/or block chain node 150 via network 110. In some embodiments, storage database 140 and/or blockchain node 150 may be directly connected to one or more components in the data management system.
The data storage method and the data reading method provided by the embodiment of the present application are respectively described in detail below with reference to the content described in the data management system shown in fig. 1.
Referring to fig. 2, fig. 2 is a schematic flowchart of a data storage method according to an embodiment of the present disclosure, where the data storage method may be executed by one or more processors built in the electronic device 120 or the electronic device 130 in the data management system, and as shown in fig. 2, the specific execution process includes:
s201: the method comprises the steps of obtaining data to be stored, wherein the data are stored in a storage database, and generating hash codes of the data to be stored.
The data to be stored may be generated in the data management system, the electronic device 120 and/or the electronic device 130, business data for storing into a conventional storage database for backup, storage, and the like.
The Hash code is obtained by calculating the data to be stored through a Hash algorithm and corresponds to the data to be stored.
The storage database may be a distributed database having a distributed data architecture, or may be a traditional centralized traditional database, for example, a database in which all data are stored in one storage location in a centralized manner.
For example, in the public trip field, the data to be stored may be usage data of vehicles where users use shared bicycles, shared electric vehicles, and the like, such as order data, riding data, and the like, and may be used to store and perform traceability data.
S202: and generating a unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored.
In this step, after the data to be stored is acquired and the hash code is generated, the acquired data to be stored may be analyzed, and information extraction may be performed according to an analysis result to determine at least one attribute information of the data to be stored, and then, the hash code and the at least one attribute information are used to generate the unique identification code of the data to be stored.
Wherein the attribute information includes at least one of the following information:
the data uploading method comprises the following steps of storing database name information of a database, data name information of data to be stored, data position information of the data to be stored in the database and data uploading party information of the data to be stored.
In addition, the attribute information may further include information such as data uploading time, data storage party information, and data storage time.
Specifically, based on the hash code and at least one attribute information of the data to be stored, a unique identification code of the data to be stored is generated, after at least one attribute information of the data to be stored is analyzed and extracted, a preset coding mode or a similar coding mode meeting the requirements is used, encoding the at least one attribute information to respectively generate an attribute code corresponding to each attribute information in the at least one attribute information of the data to be stored, then determining the splicing position of each attribute code in the hash code according to the coding characteristic or the attribute characteristic and the like of each attribute code, then, each attribute code can be inserted into the corresponding splicing position in the hash code, and splicing the hash code and all attribute codes to obtain the unique identification code of the data to be stored.
In view of keeping reasonable length of the codes and occupation of data, the code length of the attribute codes can be controlled, and attribute information with different attributes can be spliced to different positions in the hash codes, so that the unique attribute of the unique identification code is improved, and the difficulty of cracking is increased.
Therefore, further, the splicing position of each attribute code in the hash code is determined, and different attribute information may use the same or different coding modes, so that each attribute code obtained after coding may be identified, the coding length and the coding attribute of each attribute code are respectively obtained, and then the splicing position of each attribute code in the hash code is determined based on the coding length and the coding attribute of each attribute code.
Therefore, after the hash code is obtained, the hash code is processed again, the unique identification code of the data to be stored is obtained by splicing the attribute codes corresponding to the attribute information degrees, the confidentiality of the data to be stored and the identification capability after tampering can be improved, the information of different uploading parties of the data to be stored is more clear, when the data on a subsequent chain is used, for example, when the data is not used for commercial use, the data generating party can be better identified, the responsibility can be better defined, and the information tracing is facilitated.
Furthermore, according to the coding length and the coding attribute corresponding to the attribute codes of different attribute information, the splicing position of the attribute codes in the hash codes is set, so that the uploaded information of different data is more clear and concise, convenient and fast, and the method is helpful for acquiring different information more conveniently and pertinently in the subsequent data reading process, and is helpful for improving the comparison and reliability of data information.
S203: and writing the unique identification code into the corresponding block chain node.
In this step, after the unique identifier code is generated, the unique identifier code may be used as uplink data, and the unique identifier code is written into a corresponding blockchain node for storage.
The unique identification code may be written into one block chain node or may be written into a plurality of block chain nodes.
The data storage method provided by the embodiment of the application acquires data to be stored, which are stored in a storage database, and generates the hash code of the data to be stored; generating a unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored; and writing the unique identification code into the corresponding block chain node.
Compared with the prior art, the method and the device have the advantages that the unique identification code of the data to be stored is generated after double encryption and coding are carried out through the Hash code and the attribute information of the data to be stored, and the unique identification code is stored in the block chain node. Therefore, the reliability of data on the chain can be improved, the data storage of the storage database is used as a main data storage, and the data storage of the block chain is used as an auxiliary data storage, so that the master-slave backup of the data is better realized, the data backup quantity and the processing quantity can be reduced, the possibility that the data on the chain and the data of the database cannot be detected after being tampered is effectively reduced, and the probability of data cheating is reduced.
Referring to fig. 3, fig. 3 is a schematic flowchart of another data storage method according to an embodiment of the present application, where the data storage method may be executed by one or more processors built in the electronic device 120 or the electronic device 130 in the data management system, and as shown in fig. 3, the specific execution process includes:
s301: the method comprises the steps of obtaining data to be stored, wherein the data are stored in a storage database, and generating hash codes of the data to be stored.
S302: and generating a unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored.
S303: and writing the unique identification code into the corresponding block chain node.
The descriptions of step S301 to step S303 may refer to the descriptions of step S201 to step S203, and the same technical effects may be achieved, which are not described herein again.
S304: and storing the data to be stored and the unique identification code in a storage database in a way of using the unique identification code as a data main key of the data to be stored, or in a way of using the unique identification code as a query keyword of the data to be stored.
In this step, after the unique identification code is generated, the data to be stored may be stored in a storage database, and specifically, for the reasons of facilitating subsequent data query and data reading, reducing processing time, improving convenience of data use, and the like, the unique identification code may be used as a data primary key of the data to be stored, that is, the unique identification code is used as a data primary key of the data to be stored, or the unique identification code is used as an inquiry keyword of the data to be stored, that is, the unique identification code is used as an inquiry keyword of the data to be stored, so as to associate the data to be stored with the unique identification code, for example, the data to be stored and the unique identification code are bound and stored in the storage database.
Therefore, the unique identification code and the data to be stored are stored in an associated mode, data query and data reading can be facilitated, the data tampering difficulty can be increased, and the risk of data tampering is reduced.
In this embodiment, step S304 is performed after step S303, that is, the corresponding data is written into the block chain node first, and then the corresponding data is written into the storage database, but the present embodiment is not limited thereto, and this embodiment is only an example, and in other embodiments, step S304 may be performed before step S303, that is, the corresponding data is written into the storage database first, and then the corresponding data is written into the block chain node, or step S303 and step S304 may be performed simultaneously, that is, the corresponding data is written into the block chain node and the corresponding data is written into the storage database simultaneously, when the data is written into the storage database and the block chain node, only two operations need to be performed asynchronously, that is, the two operations need not to be performed, for example, the writing speed, the writing pace, and the like need not to be kept consistent, therefore, the requirement of data writing can be reduced, the convenience of data writing is improved, and the writing sequence of the two is not limited at all.
In some embodiments of the present application, after writing the corresponding data to the storage database and writing the corresponding data to the blockchain node, i.e., after S303 and S304, the data storage method includes:
detecting whether the data to be stored is successfully written into a storage database and whether the unique identification code is successfully written into the corresponding block link point; if the data to be stored fails to be written into the storage database and/or the unique identification code fails to be written into the corresponding block chain node, deleting the data written into the storage database and deleting the identification code written into the block chain node; and re-executing the steps of acquiring the data to be stored for storing in the database and generating the hash code of the data to be stored.
In this step, after data writing is completed, the block chain nodes and the storage databases may be respectively detected to detect whether the data to be stored is successfully written into the storage databases and whether the unique identification codes are successfully written into the corresponding block link points, if it is detected that the data to be stored is unsuccessfully written into the storage databases and/or the unique identification codes are unsuccessfully written into the corresponding block link points, a regression operation may be performed on the data writing, that is, data already written into the storage databases is deleted, for example, all or part of the data to be stored that has been written into the storage databases and all or part of the unique identification codes that have been written into the storage databases and are associated with the data to be stored may be executed again to acquire the data to be stored for storage into the databases, and generating the hash code of the data to be stored, and performing subsequent steps to respectively perform data writing in the storage database and data writing in the block chain node again.
Therefore, a data rollback mechanism is arranged, data writing failure caused by interference in the data writing process and the like can be effectively avoided, and the integrity of data writing is ensured.
Further, for detecting whether the data to be stored is successfully written into the storage database, it may be determined that the data to be stored is failed to be written into the storage database in the following manner:
in the process of writing the data to be stored into a storage database, if receiving the feedback information of the write error of the data to be stored, determining that the data to be stored is failed to be written into the storage database; or after the data to be stored is written into the storage database, if the data to be stored cannot be inquired in the storage database or the inquired data is inconsistent with the data to be stored, determining that the data to be stored is not written into the storage database.
Further, for detecting whether the unique identification code is successfully written into the corresponding block link point, it may be determined that the unique identification code fails to be written into the block link node by:
in the process of writing the unique identification code into the block chain node, if the write error feedback information of the unique identification code is received, determining that the unique identification code fails to be written into the block chain node; or after the unique identification code is written into the blockchain node, if the unique identification code cannot be inquired in the blockchain node or the inquired code is inconsistent with the unique identification code, determining that the unique identification code is failed to be written into the blockchain node.
In this embodiment, although the above-mentioned data writing of the storage database and the block link point is described as receiving the writing error feedback information during the data writing process, the writing error feedback information may be displayed in real time and notified to the user, or may be received during the data writing process and displayed after the data writing process and notified to the user.
For example, whether the data is written into the storage database or the data is written into the block chain node, a check mechanism may be set, for example, a feedback mechanism may be set in the process of uploading the data, and in the process of writing the data, the feedback of the storage database and the block chain node may be received periodically or in real time, for example, periodically, the storage database and the block chain node may feed back write success feedback information that the data is written successfully or write error feedback information that the data is written incorrectly, and if the write error feedback information of the storage database and/or the block chain node is received, it may be known that the data to be stored is written into the storage database unsuccessfully.
Or after the data is uploaded, inquiring the data written into the storage database and the block chain node, and if the data cannot be found or the inquired data is inconsistent, knowing that the data to be stored is written into the storage database unsuccessfully.
In some embodiments of the present application, after writing the corresponding data to the storage database and writing the corresponding data to the blockchain node, i.e., after S303 and S304, the data storage method includes:
acquiring the unique identification code from the blockchain node; performing data matching in the storage database through the unique identification code; and if the matched data is inconsistent with the data to be stored or the data cannot be matched from the storage database, determining that the data to be stored in the storage database is tampered.
In this step, in order to ensure that it can be known in time whether the data to be stored in the storage database is tampered, a periodic data check may be performed, specifically, the unique identification code stored in the blockchain node may be periodically acquired, then, data matching is performed in the storage database using the unique identification code, if the data matched from the storage database is inconsistent with the data to be stored, or the data cannot be matched from the storage database, it is determined that the data to be stored in the storage database is tampered, and then, a notification message that the data is tampered may be sent to a manager.
The data storage method provided by the embodiment of the application acquires data to be stored, which are stored in a storage database, and generates the hash code of the data to be stored; generating a unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored; writing the unique identification code into a corresponding block chain node; and storing the data to be stored and the unique identification code in a storage database in a way of using the unique identification code as a data main key of the data to be stored, or in a way of using the unique identification code as a query keyword of the data to be stored.
Compared with the prior art, the method and the device have the advantages that the unique identification code of the data to be stored is generated after double encryption and coding are carried out through the hash code and the attribute information of the data to be stored, the unique identification code is stored in the block link point, and the data to be stored and the unique identification code are stored in the storage database in an associated mode. Therefore, the reliability of data uplink and data storage can be improved, the data storage of the storage database is used as a main data storage and the data storage of the block chain is used as an auxiliary data storage, the main backup and the auxiliary backup of the data are better realized, the data backup quantity and the data processing quantity can be reduced, the possibility that the data on the chain and the data of the database cannot be detected after being tampered is effectively reduced, and the probability of data cheating is reduced.
Correspondingly, referring to fig. 4, fig. 4 is a schematic flowchart of a data reading method provided in an embodiment of the present application, where the data reading method may be executed by one or more processors built in the electronic device 120 or the electronic device 130 in the data management system, and as described in fig. 4, the specific execution process is as follows:
s401: the method comprises the steps of determining a unique identification code of data to be read matched with a data reading request based on the received data information to be read carried in the data reading request of a user and at least one attribute information carried in each identification code stored in a block chain node.
In this step, after a data reading request input by a user is received, the data reading request may be analyzed to determine information of data to be read carried in the data reading request, and a plurality of stored identification codes may be acquired from the blockchain node, and at least one attribute information of uplink data carried in each identification code is determined, and then the information of the data to be read is used to match with the plurality of at least one attribute information to determine one of the at least one attribute information matching the data reading request, and a unique identification code of the data to be read to which the at least one attribute information belongs is determined, that is, the unique identification code of the data to be read matching the data reading request may be determined.
The at least one attribute information carried in each identification code may be obtained by analyzing at least one attribute code in each identification code, and determining the attribute information corresponding to each attribute code in a reverse decoding manner and the like, so as to obtain the at least one attribute information in each identification code.
Specifically, after a data reading request of a user is received, data information to be read is determined from the received data reading request of the user, a preset coding rule is then acquired, a splicing position of each attribute code indicated by the coding rule in an identification code is determined, based on the splicing position of each attribute code in the identification code, extraction of partial codes is performed on each identification code stored in a block chain node, so that at least one attribute code in each identification code stored in the block chain node is extracted, then, based on the at least one attribute code extracted from each identification code, at least one attribute information carried in each identification code stored in the block chain node is determined through decoding and the like, and finally, at least one attribute information corresponding to each identification code is matched with the data reading request, and determining at least one identification code with the attribute information consistent with the data indicated by the data to be read from the plurality of identification codes, and determining the identification code as a unique identification code matched with the data reading request.
Therefore, the first verification of the data to be read can be achieved by analyzing the attribute information obtained by the identification code after double coding, so that the unique identification code corresponding to the data required to be read by the user and stored in the block chain node can be accurately determined, compared with the traditional comparison and matching of single information, the accuracy of information matching can be ensured, the efficiency of information matching is improved, and the interference information can be effectively and directly filtered.
S402: and detecting whether the data indicated by the at least one attribute information in the unique identification code is consistent with the data indicated by the hash code in the unique identification code.
In this step, after the unique identification code is determined, information extraction may be performed on the unique identification code through disassembly and the like to obtain a hash code and at least one attribute information carried in the unique identification code, and then data indicated by the hash code carried in the unique identification code is compared with data indicated by the at least one attribute information carried in the unique identification code, so as to detect whether the data indicated by the extracted hash code is consistent with the data indicated by the at least one attribute information.
Therefore, the consistency between at least one attribute information in the unique identification code and the Hash code is detected, the second verification of the data to be read can be realized, and the accuracy of the subsequent data reading is favorably ensured.
S403: and if the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code, reading the data to be read, which is matched with the hash code, from the storage database indicated by the at least one attribute information in the unique identification code.
In this step, if it is detected through comparison detection that the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code, it may be considered that the determined unique identification code is accurate and has not been tampered, and then the data may be read using the unique identification code.
Specifically, in view of the data stored in the storage database, at the time of data storage, the data and the corresponding unique identification code are stored in the storage database in an associated manner, so that, at the time of data reading, the data can be preliminarily screened through matching between the hash code in the unique identification code corresponding to the stored data and the hash code in the determined unique identification code, and if the data are consistent, secondary determination can be further performed through matching between at least one attribute code in the unique identification code corresponding to the stored data and at least one attribute code in the determined unique identification code, so that the data to be read can be accurately read.
The data reading method provided by the embodiment of the application determines a unique identification code of data to be read, which is matched with a data reading request, based on the information of the data to be read, which is carried in the received data reading request of a user, and at least one attribute information carried in each identification code stored in a block chain node; detecting whether data indicated by at least one attribute information in the unique identification code is consistent with data indicated by hash coding in the unique identification code; and if the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code, reading the data to be read, which is matched with the hash code, from the storage database indicated by the at least one attribute information in the unique identification code.
Compared with the prior art, when a data reading request of a user is received, the unique identification code can be matched through the data information to be read in the data reading request and the attribute information in the identification code stored in the block chain node, and data reading is carried out only after the data indicated by the attribute information in the unique identification code and the data indicated by the Hash code are verified to be consistent. Therefore, through multiple times of information verification, under the condition that the reliability of uplink data is high, the tampered conditions of the uplink data and the database data can be effectively identified, the probability of data cheating is reduced, and convenience, reliability and accuracy of data reading are improved.
Based on the same inventive concept, the embodiment of the present application further provides a data storage device corresponding to the data storage method, and as the principle of solving the problem of the data storage device in the embodiment of the present application is similar to the data storage method in the embodiment of the present application, the implementation of the device may refer to the implementation of the method, and repeated details are not repeated.
Referring to fig. 5 to 6, fig. 5 is a first structural diagram of a data storage device according to an embodiment of the present disclosure, and fig. 6 is a second structural diagram of a data storage device according to an embodiment of the present disclosure. As shown in fig. 5, the data storage device 500 includes:
the hash coding module 510 is configured to obtain data to be stored, which is used for being stored in a storage database, and generate a hash code of the data to be stored.
An identification code encoding module 520, configured to generate a unique identification code of the data to be stored based on the hash code generated by the hash encoding module 510 and at least one attribute information of the data to be stored.
A blockchain storage module 530, configured to write the unique identification code generated by the identification code encoding module 520 into a corresponding blockchain node.
In some embodiments of the present application, the identification code encoding module 520 is specifically configured to:
respectively generating an attribute code corresponding to each attribute information in at least one attribute information of the data to be stored;
determining a splicing position of each attribute code in the hash codes;
and inserting each attribute code into a corresponding splicing position in the hash code so as to splice the hash code and all the attribute codes to obtain the unique identification code of the data to be stored.
In some embodiments of the present application, the identification code encoding module 520 is further configured to:
respectively acquiring the coding length and the coding attribute of each attribute code;
and determining the splicing position of each attribute code in the hash code based on the code length and the code attribute of each attribute code.
In the above embodiment, the attribute information includes at least one of the following information:
the data uploading method comprises the following steps of storing database name information of a database, data name information of data to be stored, data position information of the data to be stored in the database and data uploading party information of the data to be stored.
In some embodiments of the present application, as shown in fig. 6, the data storage device 500 further comprises:
and the uplink data storage module 540 is configured to store the data to be stored and the unique identification code in a storage database in an associated manner in a manner that the unique identification code is used as a data primary key of the data to be stored, or in a manner that the unique identification code is used as a query keyword of the data to be stored.
In some embodiments of the present application, as shown in fig. 6, the data storage device 500 further comprises a write detection module 550, the write detection module 550 being configured to:
detecting whether the data to be stored is successfully written into a storage database and whether the unique identification code is successfully written into the corresponding block link point;
if the data to be stored fails to be written into the storage database and/or the unique identification code fails to be written into the corresponding block chain node, deleting the data written into the storage database and deleting the identification code written into the block chain node;
and re-executing the steps of acquiring the data to be stored for storing in the database and generating the hash code of the data to be stored.
In some embodiments of the present application, it is determined that the data to be stored fails to be written to the storage database by:
in the process of writing the data to be stored into a storage database, if receiving the feedback information of the write error of the data to be stored, determining that the data to be stored is failed to be written into the storage database; or
After the data to be stored is written into the storage database, if the data to be stored cannot be inquired in the storage database or the inquired data is inconsistent with the data to be stored, determining that the data to be stored is not written into the storage database.
In some embodiments of the present application, determining that the unique identification code failed to be written to the blockchain node comprises:
in the process of writing the unique identification code into the block chain node, if the write error feedback information of the unique identification code is received, determining that the unique identification code fails to be written into the block chain node; or
After the unique identification code is written into the blockchain node, if the unique identification code cannot be inquired in the blockchain node or the inquired code is inconsistent with the unique identification code, determining that the unique identification code is failed to be written into the blockchain node.
In some embodiments of the present application, as shown in fig. 6, the data storage device further comprises a data verification module 560, the data verification module 560 is configured to:
acquiring the unique identification code from the blockchain node;
performing data matching in the storage database through the unique identification code;
and if the matched data is inconsistent with the data to be stored or the data cannot be matched from the storage database, determining that the data to be stored in the storage database is tampered.
The data storage device provided by the embodiment of the application acquires data to be stored, which are stored in a storage database, and generates a hash code of the data to be stored; generating a unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored; and writing the unique identification code into the corresponding block chain node.
Compared with the prior art, the method and the device have the advantages that the unique identification code of the data to be stored is generated after double encryption and coding are carried out through the Hash code and the attribute information of the data to be stored, and the unique identification code is stored in the block chain node. Therefore, the reliability of data on the chain can be improved, the data storage of the storage database is used as a main data storage, and the data storage of the block chain is used as an auxiliary data storage, so that the master-slave backup of the data is better realized, the data backup quantity and the processing quantity can be reduced, the possibility that the data on the chain and the data of the database cannot be detected after being tampered is effectively reduced, and the probability of data cheating is reduced.
Based on the same inventive concept, a data reading device corresponding to the data reading method is also provided in the embodiments of the present application, and because the principle of solving the problem of the data reading device in the embodiments of the present application is similar to the data reading method in the embodiments of the present application, the implementation of the device can refer to the implementation of the method, and repeated details are not repeated.
Referring to fig. 7, fig. 7 is a structural diagram of a data storage device according to an embodiment of the present application. As shown in fig. 7, the data reading apparatus 700 includes:
an identification code determining module 710, configured to determine, based on data information to be read that is carried in a received data read request of a user and at least one attribute information that is carried in each identification code stored in a block chain node, a unique identification code of data to be read that matches the data read request;
a data detection module 720, configured to detect whether data indicated by at least one attribute information in the unique identification code determined by the identification code determination module 710 is consistent with data indicated by a hash code in the unique identification code;
the data reading module 730 is configured to, if the data detection module 720 detects that the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code, read the data to be read, which is matched with the hash code, from the storage database indicated by the at least one attribute information in the unique identification code.
In some embodiments of the present application, the identification code determining module 710 is specifically configured to:
determining data information to be read from a received data reading request of a user;
extracting at least one attribute code in each identification code stored in the blockchain node based on the splicing position of each attribute code in the identification code;
determining at least one attribute information carried in each identification code stored in a blockchain node based on at least one attribute code extracted from each identification code;
and determining at least one identification code with the attribute information indicating data consistent with the data indicated by the to-be-read data information from the plurality of identification codes, and determining the identification code as a unique identification code matched with the data reading request.
The data reading device provided by the embodiment of the application determines the unique identification code of the data to be read, which is matched with the data reading request, based on the information of the data to be read, which is carried in the received data reading request of the user, and at least one attribute information carried in each identification code stored in a block chain node; detecting whether data indicated by at least one attribute information in the unique identification code is consistent with data indicated by hash coding in the unique identification code; and if the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code, reading the data to be read, which is matched with the hash code, from the storage database indicated by the at least one attribute information in the unique identification code.
Compared with the prior art, when a data reading request of a user is received, the unique identification code can be matched through the data information to be read in the data reading request and the attribute information in the identification code stored in the block chain node, and data reading is carried out only after the data indicated by the attribute information in the unique identification code and the data indicated by the Hash code are verified to be consistent. Therefore, through multiple times of information verification, under the condition that the reliability of uplink data is high, the tampered conditions of the uplink data and the database data can be effectively identified, the probability of data cheating is reduced, and convenience, reliability and accuracy of data reading are improved.
According to an aspect of the present application, there is also provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the data storage method as described above.
According to another aspect of the present application, there is also provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the data reading method as described above.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to corresponding processes in the method embodiments, and are not described in detail in this application. In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical division, and there may be other divisions in actual implementation, and for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or modules through some communication interfaces, and may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (12)

1. A data storage method, characterized in that the data storage method comprises:
acquiring data to be stored, which is stored in a storage database, and generating a hash code of the data to be stored;
generating a unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored;
and writing the unique identification code into the corresponding block chain node.
2. The data storage method of claim 1, wherein the generating the unique identification code of the data to be stored based on the hash code and at least one attribute information of the data to be stored comprises:
respectively generating an attribute code corresponding to each attribute information in at least one attribute information of the data to be stored;
determining a splicing position of each attribute code in the hash codes;
and inserting each attribute code into a corresponding splicing position in the hash code so as to splice the hash code and all the attribute codes to obtain the unique identification code of the data to be stored.
3. The data storage method of claim 2, wherein the determining the splicing position of each attribute code in the hash code comprises:
respectively acquiring the coding length and the coding attribute of each attribute code;
and determining the splicing position of each attribute code in the hash code based on the code length and the code attribute of each attribute code.
4. The data storage method of any of claims 1 to 3, wherein the attribute information comprises at least one of the following information:
the data uploading method comprises the following steps of storing database name information of a database, data name information of data to be stored, data position information of the data to be stored in the database and data uploading party information of the data to be stored.
5. The data storage method according to claim 1, wherein after the generating of the unique identification code of the data to be stored based on the hash code and the at least one attribute information of the data to be stored, the data storage method comprises:
and storing the data to be stored and the unique identification code in a storage database in a way of using the unique identification code as a data main key of the data to be stored, or in a way of using the unique identification code as a query keyword of the data to be stored.
6. The data storage method according to claim 5, wherein after the storing of the association between the data to be stored and the unique identification code in a storage database and after the writing of the unique identification code in the corresponding blockchain node, the data storage method comprises:
detecting whether the data to be stored is successfully written into a storage database and whether the unique identification code is successfully written into the corresponding block link point;
if the data to be stored fails to be written into the storage database and/or the unique identification code fails to be written into the corresponding block chain node, deleting the data written into the storage database and deleting the identification code written into the block chain node;
and re-executing the steps of acquiring the data to be stored for storing in the database and generating the hash code of the data to be stored.
7. A data reading method, characterized in that the data reading method comprises:
determining a unique identification code of data to be read matched with a data reading request based on the received data information to be read carried in the data reading request of a user and at least one attribute information carried in each identification code stored in a block chain node;
detecting whether data indicated by at least one attribute information in the unique identification code is consistent with data indicated by hash coding in the unique identification code;
and if the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code, reading the data to be read, which is matched with the hash code, from the storage database indicated by the at least one attribute information in the unique identification code.
8. The data reading method according to claim 7, wherein the determining, based on the information of the data to be read carried in the received data reading request of the user and at least one attribute information carried in each identification code stored in a blockchain node, a unique identification code of the data to be read that matches the data reading request includes:
determining data information to be read from a received data reading request of a user;
extracting at least one attribute code in each identification code stored in the blockchain node based on the splicing position of each attribute code in the identification code;
determining at least one attribute information carried in each identification code stored in a blockchain node based on at least one attribute code extracted from each identification code;
and determining at least one identification code with the attribute information indicating data consistent with the data indicated by the to-be-read data information from the plurality of identification codes, and determining the identification code as a unique identification code matched with the data reading request.
9. A data storage device, characterized in that the data storage device comprises:
the hash coding module is used for acquiring data to be stored which is stored in a storage database and generating hash codes of the data to be stored;
the identification code encoding module is used for generating a unique identification code of the data to be stored based on the hash code generated by the hash encoding module and at least one attribute information of the data to be stored;
and the block chain storage module is used for writing the unique identification code generated by the identification code encoding module into a corresponding block chain node.
10. A data reading apparatus, characterized in that the data reading apparatus comprises:
the identification code determining module is used for determining a unique identification code of the data to be read, which is matched with the data reading request, based on the data information to be read, which is carried in the received data reading request of the user, and at least one attribute information carried in each identification code stored in the block chain node;
the data detection module is used for detecting whether data indicated by at least one attribute information in the unique identification code determined by the identification code determination module is consistent with data indicated by hash codes in the unique identification code;
and the data reading module is used for reading the data to be read matched with the hash code from the storage database indicated by the at least one attribute information in the unique identification code if the data detection module detects that the data information indicated by the at least one attribute information in the unique identification code is consistent with the data information indicated by the hash code in the unique identification code.
11. An electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the data storage method of any one of claims 1 to 6 or to perform the steps of the data reading method of any one of claims 7 to 8.
12. A computer-readable storage medium, characterized in that a computer program is stored thereon, which, when being executed by a processor, performs the steps of the data storage method according to any one of claims 1 to 6 or performs the steps of the data reading method according to any one of claims 7 to 8.
CN201910709205.XA 2019-08-01 2019-08-01 Data storage method and device, data reading method and device, and storage medium Active CN111835808B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910709205.XA CN111835808B (en) 2019-08-01 2019-08-01 Data storage method and device, data reading method and device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910709205.XA CN111835808B (en) 2019-08-01 2019-08-01 Data storage method and device, data reading method and device, and storage medium

Publications (2)

Publication Number Publication Date
CN111835808A true CN111835808A (en) 2020-10-27
CN111835808B CN111835808B (en) 2023-11-14

Family

ID=72912000

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910709205.XA Active CN111835808B (en) 2019-08-01 2019-08-01 Data storage method and device, data reading method and device, and storage medium

Country Status (1)

Country Link
CN (1) CN111835808B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113225407A (en) * 2021-04-29 2021-08-06 全球能源互联网研究院有限公司 Equipment identification information management method and device, electronic equipment and storage medium
CN115344848A (en) * 2022-07-20 2022-11-15 北京数牍科技有限公司 Identification obtaining method, device, equipment and computer readable storage medium
CN115345646A (en) * 2022-07-20 2022-11-15 北京数牍科技有限公司 Information sending method, device, equipment and computer readable storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107172112A (en) * 2016-03-07 2017-09-15 阿里巴巴集团控股有限公司 A kind of computer documents transmission method and device
CN107196973A (en) * 2017-07-25 2017-09-22 广东虹勤通讯技术有限公司 A kind of data encryption, decryption method and device
CN107480475A (en) * 2017-07-21 2017-12-15 广州智慧城市发展研究院 A kind of resource share method and system based on block chain network
CN108197505A (en) * 2017-12-29 2018-06-22 泰康保险集团股份有限公司 Block chain business data processing method, device and electronic equipment
CN109067541A (en) * 2018-06-29 2018-12-21 阿里巴巴集团控股有限公司 Data verification method and device, electronic equipment based on block chain
CN109191197A (en) * 2018-08-24 2019-01-11 陕西优米数据技术有限公司 Video passenger flow statistical analysis based on block chain technology
CN109582644A (en) * 2018-12-21 2019-04-05 深圳前海微众银行股份有限公司 File memory method, device, equipment and computer readable storage medium
CN109634932A (en) * 2018-11-30 2019-04-16 北京瑞卓喜投科技发展有限公司 A kind of intelligence contract storage method and storage system
WO2019075773A1 (en) * 2017-10-16 2019-04-25 平安科技(深圳)有限公司 Data processing method and apparatus, computer device and storage medium
CN109905351A (en) * 2017-12-08 2019-06-18 北京京东尚科信息技术有限公司 Method and apparatus for storing data

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107172112A (en) * 2016-03-07 2017-09-15 阿里巴巴集团控股有限公司 A kind of computer documents transmission method and device
CN107480475A (en) * 2017-07-21 2017-12-15 广州智慧城市发展研究院 A kind of resource share method and system based on block chain network
CN107196973A (en) * 2017-07-25 2017-09-22 广东虹勤通讯技术有限公司 A kind of data encryption, decryption method and device
WO2019075773A1 (en) * 2017-10-16 2019-04-25 平安科技(深圳)有限公司 Data processing method and apparatus, computer device and storage medium
CN109905351A (en) * 2017-12-08 2019-06-18 北京京东尚科信息技术有限公司 Method and apparatus for storing data
CN108197505A (en) * 2017-12-29 2018-06-22 泰康保险集团股份有限公司 Block chain business data processing method, device and electronic equipment
CN109067541A (en) * 2018-06-29 2018-12-21 阿里巴巴集团控股有限公司 Data verification method and device, electronic equipment based on block chain
CN109191197A (en) * 2018-08-24 2019-01-11 陕西优米数据技术有限公司 Video passenger flow statistical analysis based on block chain technology
CN109634932A (en) * 2018-11-30 2019-04-16 北京瑞卓喜投科技发展有限公司 A kind of intelligence contract storage method and storage system
CN109582644A (en) * 2018-12-21 2019-04-05 深圳前海微众银行股份有限公司 File memory method, device, equipment and computer readable storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113225407A (en) * 2021-04-29 2021-08-06 全球能源互联网研究院有限公司 Equipment identification information management method and device, electronic equipment and storage medium
CN113225407B (en) * 2021-04-29 2022-07-26 全球能源互联网研究院有限公司 Equipment identification information management method and device, electronic equipment and storage medium
CN115344848A (en) * 2022-07-20 2022-11-15 北京数牍科技有限公司 Identification obtaining method, device, equipment and computer readable storage medium
CN115345646A (en) * 2022-07-20 2022-11-15 北京数牍科技有限公司 Information sending method, device, equipment and computer readable storage medium
CN115345646B (en) * 2022-07-20 2023-05-02 北京数牍科技有限公司 Information transmission method, device, equipment and computer readable storage medium

Also Published As

Publication number Publication date
CN111835808B (en) 2023-11-14

Similar Documents

Publication Publication Date Title
CN111880740B (en) Data processing method, device, computer system and readable storage medium
CN111835808B (en) Data storage method and device, data reading method and device, and storage medium
CN110543516A (en) Intelligent contract processing method and device, computer equipment and storage medium
CN112070608B (en) Information processing method, device, medium and electronic equipment
CN115328759A (en) Form verification method and device
CN110895548B (en) Method and apparatus for processing information
CN112765280B (en) Block data storage method and device, computer readable medium and electronic equipment
CN110727691A (en) Data analysis and verification method and device
CN115879164A (en) Data verification method, device, equipment and storage medium
CN112583805A (en) Data processing method and device based on block chain, electronic equipment and storage medium
CN115086047B (en) Interface authentication method and device, electronic equipment and storage medium
CN114942905A (en) Migration data verification method, device, equipment and storage medium
CN114625751A (en) Data tracing query method and device based on block chain
CN112686759A (en) Account checking monitoring method, device, equipment and medium
CN116107801A (en) Transaction processing method and related product
CN112559578A (en) Data processing method and device, electronic equipment and storage medium
CN116700628B (en) Block chain data processing method, device, computer equipment and storage medium
CN113627938B (en) Data deleting method, device and equipment of block chain and storage medium
CN116383544B (en) Webpage report generation method, device, equipment and medium
CN110781188B (en) Form information processing method and device, electronic equipment and storage medium
CN112926091B (en) Block chain-based data ownership recording and data transaction verification method and device
CN111752796B (en) Method and device for determining model corresponding to log information
CN115629958A (en) Universal field level automatic checking method and device for different service interfaces
CN117687685A (en) Incremental code line determining method and device, computer equipment and storage medium
CN114238270A (en) Database operation method and device, computer equipment and readable storage 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