CN109905351B - Method, device, server and computer readable storage medium for storing data - Google Patents

Method, device, server and computer readable storage medium for storing data Download PDF

Info

Publication number
CN109905351B
CN109905351B CN201711296463.7A CN201711296463A CN109905351B CN 109905351 B CN109905351 B CN 109905351B CN 201711296463 A CN201711296463 A CN 201711296463A CN 109905351 B CN109905351 B CN 109905351B
Authority
CN
China
Prior art keywords
information
code
piece
encrypted
item
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201711296463.7A
Other languages
Chinese (zh)
Other versions
CN109905351A (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 Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information 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 Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201711296463.7A priority Critical patent/CN109905351B/en
Publication of CN109905351A publication Critical patent/CN109905351A/en
Application granted granted Critical
Publication of CN109905351B publication Critical patent/CN109905351B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

Methods and apparatus for storing data are disclosed. One embodiment of the method comprises: acquiring at least one piece of original information from a data source server; for each article code in at least one piece of original information, converting the article code into a hash code according to a preset hash table; encrypting the at least one hash code obtained by conversion according to a preset secret key to obtain at least one encrypted hash code; encrypting each item information in at least one piece of original information according to the secret key to obtain at least one piece of encrypted item information; storing the at least one encrypted hash code and the at least one piece of encrypted article information into a first node of a preset block chain, and recording the corresponding relation between the at least one encrypted hash code and each piece of encrypted article information in the at least one piece of encrypted article information and the storage position of each piece of encrypted article information. The implementation mode realizes the encrypted storage of the data and ensures the data security.

Description

Method, device, server and computer readable storage medium for storing data
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to the technical field of internet, and particularly relates to a method and a device for storing data.
Background
With the rapid development of the internet, the data security problem is continuously generated, and the commodity quality security problem is concerned. At present, a Chinese article coding center (data provider) puts article tracing data on its own tracing official network, and a user needs to input a website address to log in the official network of the Chinese article coding center and input an article bar code and a batch number to check the article tracing information.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. Essentially a decentralized database, and as a bottom layer technology of bitcoin, a blockchain is a series of data blocks which are generated by using a cryptographic method to be associated, and each data block contains information of one network transaction, so as to verify the validity (anti-counterfeiting) of the information and generate the next block. The block chain morphology is mainly divided into three main categories: public chain (bitcoin), private chain, alliance chain.
Disclosure of Invention
The embodiment of the application provides a method and a device for storing data.
In a first aspect, an embodiment of the present application provides a method for storing data, including: acquiring at least one piece of original information from a data source server, wherein each piece of original information in the at least one piece of original information comprises an article code and article information; for each article code in at least one piece of original information, converting the article code into a hash code according to a preset hash table; encrypting the at least one hash code obtained by conversion according to a preset secret key to obtain at least one encrypted hash code; encrypting each item information in at least one piece of original information according to the secret key to obtain at least one piece of encrypted item information; storing at least one encrypted hash code and at least one piece of encrypted article information into a first node of a preset block chain, and recording the corresponding relation between the at least one encrypted hash code and each piece of encrypted article information in the at least one piece of encrypted article information and the storage position of each piece of encrypted article information, wherein the first node is positioned in a target server.
In some embodiments, the method further comprises: in response to receiving a query request which comprises a target article code and is sent by a terminal, converting the target article code into a target hash code according to a hash table; encrypting the target hash code according to the secret key to obtain an encrypted target hash code; determining the storage position of the encrypted article information corresponding to the target article code according to the encrypted target hash code; acquiring the information of the encrypted target object from the determined storage position and decrypting the information according to the key; and sending the decrypted target article information to the terminal.
In some embodiments, the method further comprises: synchronizing at least one encrypted hash code and at least one piece of encrypted article information stored in a first node of a block chain into a second node of the block chain, wherein the second node is located in a data source server; and sending the hash table and the key to the data source server so that the data source server can verify at least one piece of original information through the second node based on the hash table and the key.
In some embodiments, obtaining at least one piece of raw information from a data source server comprises: at least one piece of original information is acquired from a data source server in an electronic data exchange manner.
In a second aspect, an embodiment of the present application provides a method for storing data, including: sending at least one piece of original information to a target server, wherein each piece of original information in the at least one piece of original information comprises an article code and article information; synchronizing at least one encrypted hash code and at least one piece of encrypted article information stored in a first node of a preset block chain into a second node of the block chain, wherein the first node is located in a target server, the second node is located in a data source server, the at least one encrypted hash code is obtained by converting an article code into the hash code by the target server based on a preset hash table and encrypting the converted hash code according to a preset key, and the at least one piece of encrypted article information is obtained by encrypting the at least one piece of article information by the target server.
In some embodiments, the method further comprises: receiving a hash table and a secret key sent by a target server; decrypting at least one encrypted hash code in a second node of the block chain according to the key to obtain at least one decrypted hash code; converting the at least one decrypted hash code into at least one decrypted item code according to the hash table; and for each decrypted item code in the at least one decrypted item code, determining whether an item code consistent with the decrypted item code exists in the at least one piece of original information, and if the item code consistent with the decrypted item code does not exist, outputting first information.
In some embodiments, the method further comprises: if the object code consistent with the decrypted object code exists, decrypting the encrypted object information corresponding to the decrypted object code according to the secret key to obtain decrypted object information; and for the decrypted article information, determining whether article information consistent with the decrypted article information exists in at least one piece of original information, and if the article information consistent with the decrypted article information does not exist, outputting second information.
In a third aspect, an embodiment of the present application provides an apparatus for storing data, including: the system comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is configured to acquire at least one piece of original information from a data source server, and each piece of original information in the at least one piece of original information comprises an article code and article information; the conversion unit is configured to convert each item code in at least one piece of original information into a hash code according to a preset hash table; the first encryption unit is configured to encrypt the at least one hash code obtained by conversion according to a preset secret key to obtain at least one encrypted hash code; the second encryption unit is configured to encrypt each item information in the at least one piece of original information according to the secret key to obtain at least one piece of encrypted item information; and the storage unit is configured to store the at least one encrypted hash code and the at least one piece of encrypted item information into a first node of a predetermined block chain, and record the corresponding relation between the at least one encrypted hash code and each piece of encrypted item information in the at least one piece of encrypted item information and the storage position of each piece of encrypted item information, wherein the first node is located in the target server.
In some embodiments, the apparatus further comprises a querying element configured to: in response to receiving a query request which comprises a target article code and is sent by a terminal, converting the target article code into a target hash code according to a hash table; encrypting the target hash code according to the secret key to obtain an encrypted target hash code; determining the storage position of the encrypted article information corresponding to the target article code according to the encrypted target hash code; acquiring the information of the encrypted target object from the determined storage position and decrypting the information according to the key; and sending the decrypted target article information to the terminal.
In some embodiments, the apparatus further comprises a first synchronization unit configured to: synchronizing at least one encrypted hash code and at least one piece of encrypted article information stored in a first node of a block chain into a second node of the block chain, wherein the second node is located in a data source server; and sending the hash table and the key to the data source server so that the data source server can verify at least one piece of original information through the second node based on the hash table and the key.
In some embodiments, the obtaining unit is further configured to: at least one piece of original information is acquired from a data source server in an electronic data exchange manner.
In a fourth aspect, an embodiment of the present application provides an apparatus for storing data, including: the system comprises a sending unit, a receiving unit and a processing unit, wherein the sending unit is configured to send at least one piece of original information to a target server, and each piece of original information in the at least one piece of original information comprises an article code and article information; the second synchronization unit is configured to synchronize at least one encrypted hash code and at least one piece of encrypted item information stored in a first node of a preset block chain into a second node of the block chain, wherein the first node is located in a target server, the second node is located in a data source server, the at least one encrypted hash code is obtained by converting an item code into a hash code by the target server based on a preset hash table and encrypting the hash code obtained by conversion according to a preset key, and the at least one piece of encrypted item information is obtained by encrypting the at least one piece of item information by the target server.
In some embodiments, the apparatus further comprises a verification unit: receiving a hash table and a secret key sent by a target server; decrypting at least one encrypted hash code in a second node of the block chain according to the key to obtain at least one decrypted hash code; converting the at least one decrypted hash code into at least one decrypted item code according to the hash table; and for each decrypted item code in the at least one decrypted item code, determining whether an item code consistent with the decrypted item code exists in the at least one piece of original information, and if the item code consistent with the decrypted item code does not exist, outputting first information.
In some embodiments, the verification unit is further configured to: if the object code consistent with the decrypted object code exists, decrypting the encrypted object information corresponding to the decrypted object code according to the secret key to obtain decrypted object information; and for the decrypted article information, determining whether article information consistent with the decrypted article information exists in at least one piece of original information, and if the article information consistent with the decrypted article information does not exist, outputting second information.
In a fifth aspect, an embodiment of the present application provides a server, including: one or more processors; storage means for storing one or more programs which, when executed by one or more processors, cause the one or more processors to carry out a method according to any one of the first or second aspects.
In a sixth aspect, embodiments of the present application provide a computer-readable storage medium on which a computer program is stored, wherein the program, when executed by a processor, implements the method according to any one of the first or second aspects.
According to the method and the device for storing data, the commodity code in the original information acquired from the data source server is subjected to hash transformation and then encrypted, the commodity information is encrypted, then the encrypted hash code and the encrypted commodity information are stored in the first node of the preset block chain, and the storage position is recorded. Thereby ensuring the security of the stored data and facilitating the query.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a method for storing data according to the present application;
FIG. 3 is a schematic diagram of an application scenario of a method for storing data according to the present application;
FIG. 4 is a flow diagram of yet another embodiment of a method for storing data according to the present application;
FIG. 5 is a schematic block diagram illustrating one embodiment of an apparatus for storing data according to the present application;
FIG. 6 is a schematic block diagram of yet another embodiment of an apparatus for storing data according to the present application;
FIG. 7 is a block diagram of a computer system suitable for use in implementing a server according to embodiments of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 shows an exemplary system architecture 100 to which embodiments of the method for storing data or the apparatus for storing data of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include a target server 101, proxy servers 102, 103, a data source server 104, and a terminal device 105. The proxy servers 102 and 103 can establish a private line connection by adopting a public network direct communication network. Communication between the target server 101, the data source server 104, and the terminal device 105 via the communication network. The communication network may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The data source server 104 may store raw information including item codes and item information.
The target server 101 may be a server that provides various services, such as a background query server that provides support for querying the item information by the user. The background query server may obtain the original information from the data source server 104, encrypt and store the original information, analyze and process data such as a query request including an article code sent by the terminal device 105, and feed back a processing result (e.g., article information) to the terminal device 105.
It should be noted that the method for storing data provided by the embodiment of the present application is generally performed by the target server 101 and the data source server 104, and accordingly, the apparatus for storing data is generally disposed in the target server 101 and the data source server 104.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of target servers, proxy servers, data source servers, and terminal devices, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for storing data in accordance with the present application is shown. The method for storing data comprises the following steps:
step 201, at least one piece of original information is obtained from a data source server.
In the present embodiment, an electronic device (e.g., a destination server (data acquirer) shown in fig. 1) on which the method for storing data operates may acquire at least one piece of original information from a data source server (data provider) that provides the original information by a wired connection manner or a wireless connection manner. The electronic device may also be a server separate from the target server. Wherein each piece of original information in the at least one piece of original information comprises an item code and item information. The item code may be a bar code identification specified by the international association for item codes for codes representing retail goods, non-retail goods, logistics units, participant positions, and the like. The article information may be traceability data of the article, such as information of the production place and production date of the article. Different nodes belonging to the same regional chain may be deployed on the target server and on the data source server, respectively. For a deployment node, a corresponding environment needs to be prepared, and specific environment requirements may be: physical server configuration: configuring a server according to actual requirements; operating the system: ubuntu; the network scheme comprises the following steps: a public network direct communication network; IP address and port: providing an internet IP address and a required port which need to remotely access three opposite end nodes so as to generate an access strategy; an endorsement strategy is as follows: the endorsement policy is used to indicate rules for block-level point transaction validation. 3 opposite end nodes are deployed to form a group, and when new data is written, endorsements of any node in the group are needed.
In some optional implementations of the present embodiment, the at least one piece of raw information is obtained from the data source server in an electronic data exchange. EDI (Electronic Data Interchange) is an international standard introduced by the international organization for standardization, and refers to a method for Electronic transmission from a computer to a computer, which forms a structured transaction or message format for business or administrative transactions according to a recognized standard, and is also a business language recognizable to the computer. For example, data such as purchase orders, packing lists, and bills of lading in international trade are exchanged. Data standard docking can be carried out according to an EPCIS (EPCIS is an EPCglobal network service, through which service business partners can exchange Internet of things product electronic code related data through a network) interface standard and an AS2 (availability status 2) protocol, data provided by a data provider is completely synchronized to an EDI data processing system of a data acquirer, newly added, modified and deleted data are pushed to the EDI data processing system of the data acquirer by the data provider in batches every day, and then the EDI data processing system analyzes an EPCIS message and pushes the EPCIS message to a tracing system.
Step 202, for each item code in at least one piece of original information, converting the item code into a hash code according to a preset hash table.
In the present embodiment, the hash table is a table that maps a group of keywords onto a limited address interval according to a set hash function and a collision processing method, and takes the "image" of the keyword in the address interval as a storage location recorded in the table, such table is called a hash table or hash, and the resulting storage location is called a hash address or hash address. As a linear data structure, the hash table is undoubtedly a faster one than tables, queues, and the like.
And 203, encrypting the at least one hash code obtained by conversion according to a preset secret key to obtain at least one encrypted hash code.
In this embodiment, each hash code is encrypted to obtain an encrypted hash code. The key may be the blockchain account number of the data source server. The blockchain account number can be used for digital signature to ensure the integrity of information transmission, the identity authentication of a sender and prevent repudiation in transactions. The receiver can decrypt the encrypted digest information only by using the public key of the sender, and then generates a digest information for the received original text by using the hash function, and compares the digest information with the decrypted digest information. If the two information are the same, the received information is complete and is not modified in the transmission process, otherwise, the information is modified, and therefore the digital signature can verify the integrity of the information.
And 204, encrypting each item information in the at least one piece of original information according to the secret key to obtain at least one piece of encrypted item information.
In this embodiment, each piece of item information is encrypted to obtain encrypted item information. The key used for encrypting the article information is the same as the key used for encrypting the hash code.
Step 205, storing the at least one encrypted hash code and the at least one piece of encrypted item information into a first node of a predetermined block chain, and recording a corresponding relationship between the at least one encrypted hash code and each piece of encrypted item information in the at least one piece of encrypted item information and a storage location of each piece of encrypted item information.
In this embodiment, the blockchain includes a first node and a second node, the first node of the blockchain is a node of the blockchain deployed at the target server, and the second node of the blockchain is a node of the blockchain deployed at the data source server. After the at least one encrypted hash code and the at least one piece of encrypted article information are stored in the blockchain, the blockchain returns a main key identifier (for example, an article code) of the transaction, stores the main key identifier of the transaction and associates the main key identifier with original data, and records the corresponding relation between the at least one encrypted hash code and each piece of encrypted article information in the at least one piece of encrypted article information and the storage position of each piece of encrypted article information.
In some optional implementations of this embodiment, the method further includes: in response to receiving a query request which comprises a target article code and is sent by a terminal, converting the target article code into a target hash code according to a hash table; encrypting the target hash code according to the secret key to obtain an encrypted target hash code; determining the storage position of the encrypted article information corresponding to the target article code according to the encrypted target hash code; acquiring the information of the encrypted target object from the determined storage position and decrypting the information according to the key; and sending the decrypted target article information to the terminal. The target item code is an item code to be queried, such as an item barcode on the packaging of the item. When the terminal queries the article information corresponding to the article code, the terminal does not need to directly access the official website server, and only needs to query through the target server. When the terminal sends the query request, the scanned commodity bar code can be sent to the target server in a code scanning mode. And the target server performs hash processing and encryption processing on the commodity bar code to obtain a target encrypted hash code. According to the corresponding relation and the storage position between the encrypted hash code and the encrypted article information which are stored before, the encrypted target article information corresponding to the target encrypted hash code can be found. And decrypting the encrypted target object information and then sending the decrypted target object information to the terminal. And the terminal can display the article information corresponding to the target article code. For example, a user scans a bar code on a milk box by using a terminal, the bar code is sent to a target server, and the target server performs a series of conversion on the bar code and then finds the information of articles such as production date, milk source origin, milk cow variety and the like corresponding to the bar code.
In some optional implementations of this embodiment, the method further includes: synchronizing at least one encrypted hash code and at least one piece of encrypted article information stored in a first node of a block chain into a second node of the block chain, wherein the second node is located in a data source server; and sending the hash table and the key to the data source server so that the data source server can verify at least one piece of original information through the second node based on the hash table and the key. And the blockchain node synchronizes the blockchain data to other nodes of the alliance chain through a data synchronization function so as to endorse each other. In addition to synchronizing the data, the hash table and key are also disclosed so that the data source server can verify that the original data has been tampered with.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method for storing data according to the present embodiment. In the application scenario of fig. 3, first, the blockchain trace back system 303 opens a trace back system account and a blockchain account for the data provider 301, and maps and binds the trace back system account and the blockchain account. Secondly, original data including article codes and article information of the data provider 301 are subjected to data transmission through an AS2 protocol, the original data are stored in a database of the block chain tracing system 303, then the block chain tracing system 303 performs hash processing on each piece of original data, then a block chain account (secret key) is used for signing the data, then the signed data are stored in a block chain link point (first node) of a data acquirer 304 in the block chain, the block chain returns a main key identifier of the transaction to the block chain tracing system 303, the block chain tracing system 303 stores and associates the original data, and a hash table and the block chain account are disclosed. And the block chain node synchronizes the block chain data to other nodes of the alliance chain through a data synchronization function.
According to the method provided by the embodiment of the application, the data is stored in the block chain, so that the encrypted storage of the data is realized, and the data security is ensured.
With further reference to FIG. 4, a flow 400 of yet another embodiment of a method for storing data is shown. The process 400 of the method for storing data includes the steps of:
step 401, at least one piece of original information is sent to a target server.
In this embodiment, the electronic device (e.g., the data source server shown in fig. 1) on which the method for storing data operates may send at least one piece of original information to the target server through a wired connection or a wireless connection. Wherein each piece of original information in the at least one piece of original information comprises an item code and item information. This step corresponds to step 201, where the data source server sends at least one piece of original information to the target server, and the target server executes step 201 and step 205 after receiving the at least one piece of original information.
Step 402, synchronizing at least one encrypted hash code and at least one piece of encrypted article information stored in a first node of a preset block chain into a second node of the block chain.
In this embodiment, the first node is located at the destination server, the second node is located at the data source server, the at least one encrypted hash code is obtained by converting an item code into a hash code by the destination server based on a preset hash table and encrypting the converted hash code according to a preset key, and the at least one piece of encrypted item information is obtained by encrypting the at least one piece of item information by the destination server. The target server stores the at least one encrypted hash code and the at least one encrypted item information to a first node of the regional chain deployed on the target server, via step 201 and 205. The data origin server then synchronizes the at least one cryptographic hash code and the at least one cryptographic commodity information stored in the first node to a second node of the blockchain deployed on the data origin server.
In some optional implementations of this embodiment, the method further includes: receiving a hash table and a secret key sent by a target server; decrypting at least one encrypted hash code in a second node of the block chain according to the key to obtain at least one decrypted hash code; converting the at least one decrypted hash code into at least one decrypted item code according to the hash table; and for each decrypted item code in the at least one decrypted item code, determining whether an item code consistent with the decrypted item code exists in the at least one piece of original information, and if the item code consistent with the decrypted item code does not exist, outputting first information. The hash table and key are used by the destination server for hash processing and encryption. The data source server can decrypt the encrypted hash code by using the same hash table and key and then convert the encrypted hash code into the commodity code. And then verifying whether the data obtained by the data source server and synchronized in the target server is consistent with the original data stored in the data source server. If the article codes do not match, first information, for example, information indicating that the article codes are tampered, is output.
In some optional implementations of this embodiment, the method further includes: if the object code consistent with the decrypted object code exists, decrypting the encrypted object information corresponding to the decrypted object code according to the secret key to obtain decrypted object information; and for the decrypted article information, determining whether article information consistent with the decrypted article information exists in at least one piece of original information, and if the article information consistent with the decrypted article information does not exist, outputting second information. And if the article code is not tampered, further verifying whether the article information corresponding to the article code is tampered. After decryption processing, the decrypted article information is compared with the original article information, and if the decrypted article information is not consistent with the original article information, second information is output, for example, information for prompting that the article information is tampered.
As can be seen from fig. 4, compared with the corresponding embodiment of fig. 2, the flow 400 of the method for storing data in the present embodiment highlights a step in which the data source server verifies whether the data stored in the target server is tampered. Therefore, the scheme described in the embodiment can prevent the data from being tampered, and the data security is improved.
With further reference to fig. 5, as an implementation of the methods shown in the above-mentioned figures, the present application provides an embodiment of an apparatus for storing data, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable to various electronic devices.
As shown in fig. 5, the apparatus 500 for storing data of the present embodiment includes: an acquisition unit 501, a conversion unit 502, a first encryption unit 503, a second encryption unit 504, and a storage unit 505. The obtaining unit 501 is configured to obtain at least one piece of original information from a data source server, where each piece of original information in the at least one piece of original information includes an item code and item information; the conversion unit 502 is configured to, for each item code in at least one piece of original information, convert the item code into a hash code according to a preset hash table; the first encryption unit 503 is configured to encrypt the at least one hash code obtained by conversion according to a preset key to obtain at least one encrypted hash code; the second encryption unit 504 is configured to encrypt each item information in the at least one piece of original information according to the key to obtain at least one piece of encrypted item information; the storage unit 505 is configured to store the at least one encrypted hash code and the at least one piece of encrypted item information into a first node of a predetermined block chain, and record a correspondence relationship between the at least one encrypted hash code and each piece of encrypted item information in the at least one piece of encrypted item information and a storage location of each piece of encrypted item information, where the first node is located at a target server.
In this embodiment, specific processing of the obtaining unit 501, the converting unit 502, the first encrypting unit 503, the second encrypting unit 504 and the storing unit 505 of the apparatus 500 for storing data may refer to step 201, step 202, step 203, step 204 and step 205 in the corresponding embodiment of fig. 2.
In some optional implementations of this embodiment, the apparatus 500 further includes a querying unit (not shown) configured to: in response to receiving a query request which comprises a target article code and is sent by a terminal, converting the target article code into a target hash code according to a hash table; encrypting the target hash code according to the secret key to obtain an encrypted target hash code; determining the storage position of the encrypted article information corresponding to the target article code according to the encrypted target hash code; acquiring the information of the encrypted target object from the determined storage position and decrypting the information according to the key; and sending the decrypted target article information to the terminal.
In some optional implementations of this embodiment, the apparatus 500 further comprises a first synchronization unit (not shown) configured to: synchronizing at least one encrypted hash code and at least one piece of encrypted article information stored in a first node of a block chain into a second node of the block chain, wherein the second node is located in a data source server; and sending the hash table and the key to the data source server so that the data source server can verify at least one piece of original information through the second node based on the hash table and the key.
In some optional implementations of this embodiment, the obtaining unit 501 is further configured to: at least one piece of original information is acquired from a data source server in an electronic data exchange manner.
With further reference to fig. 6, as an implementation of the methods shown in the above figures, the present application provides yet another embodiment of an apparatus for storing data, which corresponds to the method embodiment shown in fig. 4, and which is particularly applicable to various electronic devices.
As shown in fig. 6, the apparatus 600 for storing data of the present embodiment includes: a transmitting unit 601 and a second synchronizing unit 602. The sending unit 601 is configured to send at least one piece of original information to the target server, where each piece of original information in the at least one piece of original information includes an item code and item information; the second synchronization unit 602 is configured to synchronize at least one encrypted hash code and at least one piece of encrypted item information stored in a first node of a preset block chain into a second node of the block chain, where the first node is located in a target server, the second node is located in a data source server, the at least one encrypted hash code is obtained by converting an item code into a hash code by the target server based on a preset hash table and encrypting the hash code obtained by conversion according to a preset key, and the at least one piece of encrypted item information is obtained by encrypting the at least one piece of item information by the target server.
In this embodiment, the specific processing of the sending unit 601 and the second synchronizing unit 602 of the apparatus 600 for storing data may refer to step 401 and step 402 in the corresponding embodiment of fig. 4.
In some optional implementations of this embodiment, the apparatus 600 further includes a verification unit (not shown): receiving a hash table and a secret key sent by a target server; decrypting at least one encrypted hash code in a second node of the block chain according to the key to obtain at least one decrypted hash code; converting the at least one decrypted hash code into at least one decrypted item code according to the hash table; and for each decrypted item code in the at least one decrypted item code, determining whether an item code consistent with the decrypted item code exists in the at least one piece of original information, and if the item code consistent with the decrypted item code does not exist, outputting first information.
In some optional implementations of this embodiment, the check unit is further configured to: if the object code consistent with the decrypted object code exists, decrypting the encrypted object information corresponding to the decrypted object code according to the secret key to obtain decrypted object information; and for the decrypted article information, determining whether article information consistent with the decrypted article information exists in at least one piece of original information, and if the article information consistent with the decrypted article information does not exist, outputting second information.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use in implementing a server according to embodiments of the present application. The server shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input section 707 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program, when executed by a Central Processing Unit (CPU)701, performs the above-described functions defined in the method of the present application. It should be noted that the computer readable medium described herein can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes an acquisition unit, a conversion unit, a first encryption unit, a second encryption unit, and a storage unit. Where the names of the units do not in some cases constitute a limitation on the units themselves, for example, the obtaining unit may also be described as a "unit that obtains at least one piece of original information from the data source server".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be present separately and not assembled into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to: acquiring at least one piece of original information from a data source server, wherein each piece of original information in the at least one piece of original information comprises an article code and article information; for each article code in at least one piece of original information, converting the article code into a hash code according to a preset hash table; encrypting the at least one hash code obtained by conversion according to a preset secret key to obtain at least one encrypted hash code; encrypting each item information in at least one piece of original information according to the secret key to obtain at least one piece of encrypted item information; storing at least one encrypted hash code and at least one piece of encrypted article information into a first node of a preset block chain, and recording the corresponding relation between the at least one encrypted hash code and each piece of encrypted article information in the at least one piece of encrypted article information and the storage position of each piece of encrypted article information, wherein the first node is positioned in a target server. Or when the one or more programs are executed by the apparatus, cause the apparatus to: sending at least one piece of original information to a target server, wherein each piece of original information in the at least one piece of original information comprises an article code and article information; synchronizing at least one encrypted hash code and at least one piece of encrypted article information stored in a first node of a preset block chain into a second node of the block chain, wherein the first node is located in a target server, the second node is located in a data source server, the at least one encrypted hash code is obtained by converting an article code into the hash code by the target server based on a preset hash table and encrypting the converted hash code according to a preset key, and the at least one piece of encrypted article information is obtained by encrypting the at least one piece of article information by the target server.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by a person skilled in the art that the scope of the invention as referred to in the present application is not limited to the embodiments with a specific combination of the above-mentioned features, but also covers other embodiments with any combination of the above-mentioned features or their equivalents without departing from the inventive concept. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (16)

1. A method for storing data, comprising:
acquiring at least one piece of original information from a data source server, wherein each piece of original information in the at least one piece of original information comprises an article code and article information;
for each article code in the at least one piece of original information, converting the article code into a hash code according to a preset hash table;
encrypting the at least one hash code obtained by conversion according to a preset secret key to obtain at least one encrypted hash code;
encrypting each item information in the at least one piece of original information according to the secret key to obtain at least one piece of encrypted item information;
storing the at least one encrypted hash code and the at least one piece of encrypted item information into a first node of a preset block chain, and recording the corresponding relation between the at least one encrypted hash code and each piece of encrypted item information in the at least one piece of encrypted item information and the storage position of each piece of encrypted item information, wherein the first node is positioned at a target server.
2. The method of claim 1, wherein the method further comprises:
in response to receiving a query request which is sent by a terminal and comprises a target item code, converting the target item code into a target hash code according to the hash table;
encrypting the target hash code according to the secret key to obtain an encrypted target hash code;
determining the storage position of the encrypted article information corresponding to the target article code according to the encrypted target hash code;
acquiring the information of the encrypted target object from the determined storage position and decrypting according to the key;
and sending the decrypted target article information to the terminal.
3. The method of claim 1, wherein the method further comprises:
synchronizing the at least one encrypted hash code and the at least one piece of encrypted item information stored in a first node of the blockchain to a second node of the blockchain, wherein the second node is located at the data source server;
and sending the hash table and the key to the data source server, so that the data source server verifies the at least one piece of original information through the second node based on the hash table and the key.
4. The method of any of claims 1-3, wherein said obtaining at least one piece of raw information from a data source server comprises:
at least one piece of original information is acquired from a data source server in an electronic data exchange manner.
5. A method for storing data, comprising:
sending at least one piece of original information to a target server, wherein each piece of original information in the at least one piece of original information comprises an article code and article information;
synchronizing at least one encrypted hash code and at least one encrypted item information stored in a first node of a preset block chain into a second node of the block chain, wherein the first node is located in a target server, the second node is located in a data source server, the at least one encrypted hash code is obtained by converting an item code into a hash code by the target server based on a preset hash table and encrypting the converted hash code according to a preset key, and the at least one encrypted item information is obtained by encrypting the at least one item information by the target server.
6. The method of claim 5, wherein the method further comprises:
receiving a hash table and a key sent by the target server;
decrypting at least one encrypted hash code in a second node of the block chain according to the key to obtain at least one decrypted hash code;
converting the at least one decrypted hash code into at least one decrypted item code according to the hash table;
and for each decrypted item code in the at least one decrypted item code, determining whether an item code consistent with the decrypted item code exists in the at least one piece of original information, and if the item code consistent with the decrypted item code does not exist, outputting first information.
7. The method of claim 6, wherein the method further comprises:
if the object code consistent with the decrypted object code exists, decrypting the encrypted object information corresponding to the decrypted object code according to the secret key to obtain decrypted object information;
and for the decrypted article information, determining whether article information consistent with the decrypted article information exists in the at least one piece of original information, and if not, outputting second information.
8. An apparatus for storing data, comprising:
the system comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is configured to acquire at least one piece of original information from a data source server, and each piece of original information in the at least one piece of original information comprises an article code and article information;
the conversion unit is configured to convert each item code in the at least one piece of original information into a hash code according to a preset hash table;
the first encryption unit is configured to encrypt the at least one hash code obtained by conversion according to a preset secret key to obtain at least one encrypted hash code;
the second encryption unit is configured to encrypt each item information in the at least one piece of original information according to the secret key to obtain at least one piece of encrypted item information;
and the storage unit is configured to store the at least one encrypted hash code and the at least one piece of encrypted item information into a first node of a predetermined block chain, and record a corresponding relationship between the at least one encrypted hash code and each piece of encrypted item information in the at least one piece of encrypted item information and a storage location of each piece of encrypted item information, wherein the first node is located in a target server.
9. The apparatus of claim 8, wherein the apparatus further comprises a querying element configured to:
in response to receiving a query request which is sent by a terminal and comprises a target item code, converting the target item code into a target hash code according to the hash table;
encrypting the target hash code according to the secret key to obtain an encrypted target hash code;
determining the storage position of the encrypted article information corresponding to the target article code according to the encrypted target hash code;
acquiring the information of the encrypted target object from the determined storage position and decrypting according to the key;
and sending the decrypted target article information to the terminal.
10. The apparatus of claim 8, wherein the apparatus further comprises a first synchronization unit configured to:
synchronizing the at least one encrypted hash code and the at least one piece of encrypted item information stored in a first node of the blockchain to a second node of the blockchain, wherein the second node is located at the data source server;
and sending the hash table and the key to the data source server, so that the data source server verifies the at least one piece of original information through the second node based on the hash table and the key.
11. The apparatus according to one of claims 8-10, wherein the obtaining unit is further configured to:
at least one piece of original information is acquired from a data source server in an electronic data exchange manner.
12. An apparatus for storing data, comprising:
the system comprises a sending unit, a receiving unit and a processing unit, wherein the sending unit is configured to send at least one piece of original information to a target server, and each piece of original information in the at least one piece of original information comprises an article code and article information;
the second synchronization unit is configured to synchronize at least one encrypted hash code and at least one piece of encrypted item information stored in a first node of a preset block chain into a second node of the block chain, wherein the first node is located in the target server, the second node is located in the data source server, the at least one encrypted hash code is obtained by converting an item code into a hash code by the target server based on a preset hash table and encrypting the hash code obtained by conversion according to a preset key, and the at least one piece of encrypted item information is obtained by encrypting the at least one piece of item information by the target server.
13. The apparatus of claim 12, wherein the apparatus further comprises a verification unit:
receiving a hash table and a key sent by the target server;
decrypting at least one encrypted hash code in a second node of the block chain according to the key to obtain at least one decrypted hash code;
converting the at least one decrypted hash code into at least one decrypted item code according to the hash table;
and for each decrypted item code in the at least one decrypted item code, determining whether an item code consistent with the decrypted item code exists in the at least one piece of original information, and if the item code consistent with the decrypted item code does not exist, outputting first information.
14. The apparatus of claim 13, wherein the verification unit is further configured to:
if the object code consistent with the decrypted object code exists, decrypting the encrypted object information corresponding to the decrypted object code according to the secret key to obtain decrypted object information;
and for the decrypted article information, determining whether article information consistent with the decrypted article information exists in the at least one piece of original information, and if not, outputting second information.
15. A server, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
16. A computer-readable storage medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the method of any one of claims 1-7.
CN201711296463.7A 2017-12-08 2017-12-08 Method, device, server and computer readable storage medium for storing data Active CN109905351B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711296463.7A CN109905351B (en) 2017-12-08 2017-12-08 Method, device, server and computer readable storage medium for storing data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711296463.7A CN109905351B (en) 2017-12-08 2017-12-08 Method, device, server and computer readable storage medium for storing data

Publications (2)

Publication Number Publication Date
CN109905351A CN109905351A (en) 2019-06-18
CN109905351B true CN109905351B (en) 2021-02-26

Family

ID=66940568

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711296463.7A Active CN109905351B (en) 2017-12-08 2017-12-08 Method, device, server and computer readable storage medium for storing data

Country Status (1)

Country Link
CN (1) CN109905351B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111835808B (en) * 2019-08-01 2023-11-14 北京骑胜科技有限公司 Data storage method and device, data reading method and device, and storage medium
CN111310236A (en) * 2019-12-31 2020-06-19 天津津滨信钥信息技术有限公司 Commodity transportation abnormal information recording method, device, equipment and storage medium
CN111506658B (en) * 2020-04-17 2021-09-28 腾讯科技(深圳)有限公司 Data processing method and device, first equipment and storage medium
CN111507695B (en) * 2020-04-17 2022-09-27 腾讯科技(深圳)有限公司 Data processing method, data processing device, node equipment and storage medium
CN111797417A (en) * 2020-07-06 2020-10-20 上海明略人工智能(集团)有限公司 File uploading method and device, storage medium and electronic device
CN112685753B (en) * 2020-12-25 2023-11-28 上海焜耀网络科技有限公司 Method and equipment for storing encrypted data

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103281386A (en) * 2013-06-03 2013-09-04 复旦大学 Method for providing safety protection for item identification and an item resolution service
CN106570710A (en) * 2016-10-27 2017-04-19 纸飞机(北京)科技有限公司 Commodity anti-counterfeiting method and device
CN107276973A (en) * 2016-12-10 2017-10-20 江苏恒为信息科技有限公司 A kind of internet article identity mark is built and verification method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103281386A (en) * 2013-06-03 2013-09-04 复旦大学 Method for providing safety protection for item identification and an item resolution service
CN106570710A (en) * 2016-10-27 2017-04-19 纸飞机(北京)科技有限公司 Commodity anti-counterfeiting method and device
CN107276973A (en) * 2016-12-10 2017-10-20 江苏恒为信息科技有限公司 A kind of internet article identity mark is built and verification method

Also Published As

Publication number Publication date
CN109905351A (en) 2019-06-18

Similar Documents

Publication Publication Date Title
CN109905351B (en) Method, device, server and computer readable storage medium for storing data
US20190034923A1 (en) Secure and confidential custodial transaction system, method and device using zero-knowledge protocol
CN108550037B (en) File processing method and device based on block chain
CN108197891B (en) Electronic signing device and method based on block chain
CN106982203B (en) Robust ATM network system based on block chain technology and information processing method thereof
WO2019214312A1 (en) Blockchain-based logistics information transmission method, system and device
JP4788212B2 (en) Digital signature program and digital signature system
WO2020049452A1 (en) Methods and devices for managing user identity authentication data
CN110601856B (en) Data interaction method and device based on block chain network
US20130329889A1 (en) System and method for providing secure product data collection, monitoring, and tracking
US20150269570A1 (en) Systems and methods in support of authentication of an item
CN111292041B (en) Electronic contract generation method, device, equipment and storage medium
CN112215608A (en) Data processing method and device
WO2019161774A1 (en) Methods, application server, block chain node and media for logistics tracking and source tracing
CN110597836B (en) Information inquiry request response method and device based on block chain network
CN110598433B (en) Block chain-based anti-fake information processing method and device
JPWO2003003329A1 (en) Data originality verification method and system
CN108923925B (en) Data storage method and device applied to block chain
CN108022194A (en) Law-enforcing recorder and its data safety processing method, server and system
CN111630544A (en) Method and system for controlling distribution of products in computer network
EP3891617A1 (en) Secure consensus over a limited connection
CN110689295A (en) Block chain universal RFID translator
US20200344046A1 (en) Product Tracking System and Method
CN116611851A (en) Hotpot condiment product tracing method and system based on blockchain
CN114240399A (en) Government affair data processing method and system based on block chain platform

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