CN107707345B - Method and device for encrypting and verifying bar code - Google Patents

Method and device for encrypting and verifying bar code Download PDF

Info

Publication number
CN107707345B
CN107707345B CN201610648028.5A CN201610648028A CN107707345B CN 107707345 B CN107707345 B CN 107707345B CN 201610648028 A CN201610648028 A CN 201610648028A CN 107707345 B CN107707345 B CN 107707345B
Authority
CN
China
Prior art keywords
encryption code
encryption
queue
code
effective
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
CN201610648028.5A
Other languages
Chinese (zh)
Other versions
CN107707345A (en
Inventor
毛立勇
刘勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201610648028.5A priority Critical patent/CN107707345B/en
Publication of CN107707345A publication Critical patent/CN107707345A/en
Application granted granted Critical
Publication of CN107707345B publication Critical patent/CN107707345B/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
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0866Generation of secret information including derivation or calculation of cryptographic keys or passwords involving user or device identifiers, e.g. serial number, physical or biometrical information, DNA, hand-signature or measurable physical characteristics
    • 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/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0816Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
    • H04L9/0819Key transport or distribution, i.e. key establishment techniques where one party creates or otherwise obtains a secret value, and securely transfers it to the other(s)

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Storage Device Security (AREA)

Abstract

The embodiment of the invention discloses a method and a device for encrypting and verifying a bar code. The encryption method of the bar code comprises the following steps: establishing a fixed encryption code queue; sending the encryption code validation rules in the encryption code queue and the encryption code queue to verification equipment; and selecting effective encryption codes from the encryption code queue according to an encryption code effective rule, and sending the effective encryption codes to the user client to update the bar codes of the user, wherein the bar codes are used for scanning by the verification equipment to obtain the encryption codes and verifying the encryption codes. The encryption code queue may provide a greater number of encryption codes with a limited number of bits than encryption with time stamps. And the encryption code can still be accurately verified under the condition that the time reliability of the verification equipment is low.

Description

Method and device for encrypting and verifying bar code
Technical Field
The embodiment of the invention relates to a data encryption technology, in particular to a method and a device for encrypting and verifying a bar code.
Background
Discount of the supermarket is a common scene in daily life, and with the development of computer and network technologies, the privilege of the user gradually changes and is realized in an electronic data mode.
A typical application scenario is that an operator providing preferential activities provides electronic one-dimensional codes for users, and the electronic one-dimensional codes are used for code scanning of consumer front-end devices such as supermarkets. The consumption front-end equipment directly verifies the information of the one-dimensional code after scanning the code, and does not perform information interactive verification with a server of an operator in real time. The specific process is as follows: the operator server provides one-dimensional codes to the user client or in multimedia messages or WeChat and other modes, wherein the one-dimensional codes comprise parameters representing preferential activities and encryption codes; the method comprises the steps that after code scanning is carried out on consumption front-end equipment, information in a one-dimensional code is obtained, the effectiveness of the consumption front-end equipment is verified by the consumption front-end equipment, particularly the effectiveness of an encryption code is verified, and the consumption front-end equipment can know the rule of time effectiveness of the encryption code from an operator server in advance and verify according to the rule; if the verification is passed, the user can be provided with an offer.
In order to limit the use times and use time limit of the user to the preference, an encryption code is set for constraint; each time the user opens the one-dimensional code, the one-dimensional code can be monitored by the operator server, so that the one-dimensional code is updated, namely the one-dimensional code is actually updated when the user opens the one-dimensional code next time. The updated valid one-dimensional code can be reused, and if the one-dimensional code is not updated normally, the one-dimensional code is invalid after being used.
The updating of the one-dimensional code is mainly to update the encryption code therein, and in the prior art, in order to embody timeliness, the date and time is often used as the encryption code. However, the bit space is limited due to the hardware capability of the consuming front-end device, and the number of bits that can be allocated for encryption is also limited.
In the prior art, if a timestamp is used as an encryption code, the following defects exist:
1. the limited number of encryption bits results in a limited selectable value for the timestamp, which can be recycled in a short time, e.g., 4 encryption bits can correspond to a timestamp that is only available for a valid time of about half a day;
2. the consumption front-end equipment is low in time reliability and is likely to have deviation with the time of the encryption code updated by the operator server, and if the two times of comparison have larger deviation, the verification cannot be passed.
Disclosure of Invention
The embodiment of the invention provides a method and a device for encrypting and verifying a bar code, which are used for ensuring the reliability of time-efficiency verification of the bar code.
In a first aspect, an embodiment of the present invention provides a barcode encryption method, applied to an encryption server, including:
establishing a fixed encryption code queue;
sending the encryption code validation rules in the encryption code queue and the encryption code queue to verification equipment;
and selecting effective encryption codes from the encryption code queue according to an encryption code effective rule, and sending the effective encryption codes to the user client to update the bar codes of the user, wherein the bar codes are used for scanning by the verification equipment to obtain the encryption codes and verifying the encryption codes.
In a second aspect, an embodiment of the present invention further provides a method for verifying a barcode, which is applied to a verification device, and includes:
receiving an encryption code queue and an encryption code validation rule sent by an encryption server;
scanning a bar code provided by a user client to obtain an encryption code to be verified;
and judging whether the encryption code to be verified is in the effective area of the encryption code queue according to the encryption code queue and the encryption code validation rule so as to verify the validity of the bar code.
In a third aspect, an embodiment of the present invention further provides an encryption apparatus for a barcode, which is applied to an encryption server, and includes:
the queue establishing module is used for establishing a fixed encryption code queue;
the transmission module is used for transmitting the encryption code validation rules in the encryption code queue and the encryption code queue to verification equipment;
and the encryption code selection module is used for selecting effective encryption codes from the encryption code queue according to the encryption code validation rule and sending the effective encryption codes to the user client so as to update the bar code of the user, wherein the bar code is used for scanning by the verification equipment to obtain the encryption codes and verifying the encryption codes.
In a fourth aspect, an embodiment of the present invention further provides a device for verifying a barcode, which is applied to a verification device, and includes:
the receiving module is used for receiving the encryption code queue and the encryption code validation rule sent by the encryption server;
the encryption code acquisition module is used for scanning a bar code provided by a user client to acquire an encryption code to be verified;
and the judging module is used for judging whether the encryption code to be verified is in the effective area of the encryption code queue according to the encryption code queue and the encryption code validation rule so as to verify the validity of the bar code.
The embodiment of the invention updates the bar code of the user by sending the pre-established fixed encryption code queue and the encryption code validation rule to the verification equipment and sending the effective encryption code to the user client. Compared with the time stamp adopted as the encryption code, the encryption code queue can provide a larger number of encryption codes under the condition that the distributed encryption bits are the same. And the encryption code can still be accurately verified under the condition that the time reliability of the verification equipment is low. The reliability of the time efficiency verification of the bar code can be ensured.
Drawings
Fig. 1 is a schematic flowchart of an encryption method for a barcode according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of an encryption method for bar codes according to a second embodiment of the present invention;
fig. 3 is a schematic flowchart of an encryption method for a barcode according to a third embodiment of the present invention;
fig. 4 is a schematic flowchart of an encryption method for bar codes according to a fourth embodiment of the present invention;
fig. 5 is a schematic flowchart of an encryption method for a barcode according to a fifth embodiment of the present invention;
fig. 6 is a schematic flowchart of a method for verifying a barcode according to a sixth embodiment of the present invention;
fig. 7 is a schematic flowchart of a method for verifying a barcode according to a seventh embodiment of the present invention;
fig. 8 is a schematic flowchart of a method for verifying a barcode according to an eighth embodiment of the present invention;
fig. 9 is a schematic structural diagram of an encryption apparatus for bar codes according to a ninth embodiment of the present invention;
fig. 10 is a schematic structural diagram of a barcode verification apparatus according to a tenth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a schematic flow chart of a barcode encryption method according to an embodiment of the present invention, where the method is suitable for encrypting a barcode. May be performed by a bar code encryption device, which may be implemented by means of hardware and/or software, and may generally be applied in an encryption server, which may typically be integrated in an operator server.
Referring to fig. 1, the method for encrypting a barcode includes:
s110, establishing a fixed encryption code queue.
The encryption code is a code generated by hiding data. Even if the unauthorized user obtains the encryption code, the unauthorized user still cannot know the data corresponding to the encryption code. The bar code typically includes an encryption code, which typically includes a predetermined number of digits in a multi-digit number, for verifying the bar code to determine whether the bar code is valid. Typically, the encryption code may be filled in a predetermined position in the combination of numbers that make up the bar code. For example, the encryption code is filled in a preset position of 10 bits to 14 bits in an 18-bit bar code. The encryption code is usually generated in advance according to the design requirement and filled in the bar code when in use. In this embodiment, a fixed encryption code queue is established by the encryption server. The encryption code queue comprises a plurality of encryption codes. Once the fixed encryption code queue is determined, the encryption code sequence and the encryption code content in the encryption code queue are not changed.
S120, the encryption code validation rules in the encryption code queue and the encryption code queue are sent to verification equipment.
Generally, the encryption code is disabled after use to prevent unauthorized reading of the bar code. Whether the bar code currently comprising the encryption code is valid can be judged according to the validation rule of the encryption code. The effective rule of the encryption code can be preset by the encryption server. The encryption server can send the encryption code validation rules in the encryption code queue and the encryption code queue to the verification device through a network or other modes, so that the verification device can verify the bar codes according to the encryption code validation rules and the encryption code queue.
And step 130, selecting effective encryption codes from the encryption code queue according to the encryption code validation rule, and sending the effective encryption codes to the user client to update the bar codes of the user, wherein the bar codes are used for scanning by the verification equipment to obtain the encryption codes and verifying the encryption codes.
The encryption code information in the bar code displayed by the user client can be acquired from the encryption device through network connection. And the encryption device selects effective encryption codes from the established fixed encryption code queue according to the encryption code validation rule and sends the effective encryption codes to the user client. Because the information such as the partner identification code and the user ID included in the bar code does not change, the user client can update the bar code only according to the effective encryption code sent by the encryption device. And when the scanning is needed, the display is carried out at the client of the user. The bar code updated by the user client can be scanned by using verification equipment such as a bar code scanning gun and the like to obtain the encrypted code included in the bar code, and the bar code is verified according to the effective rule of the encrypted code to determine whether the bar code updated by the user client is effective.
The embodiment sends the pre-established fixed encryption code queue and the encryption code validation rule to the verification equipment, and sends the valid encryption code to the user client so as to update the bar code of the user. Compared with the time stamp adopted as the encryption code, the encryption code queue can provide a larger number of encryption codes under the condition that the distributed encryption bits are the same. And the encryption code can still be accurately verified under the condition that the time reliability of the verification equipment is low. The reliability of the time efficiency verification of the bar code can be ensured. .
In a preferred implementation manner of this embodiment, the effective encryption code may be selected from the encryption code queue according to the validity rule of the encryption code, and sent to the user client, so as to update the barcode of the user, which is specifically optimized as follows: and if the barcode is monitored to be opened in the user client, selecting an effective encryption code from the encryption code queue according to the encryption code validation rule, and sending the effective encryption code to the user client so as to update the barcode of the user.
Usually, the user will choose to open the barcode from the client only when the barcode needs to be scanned. In this embodiment, if the user client sends an update request to the encryption server when monitoring that the user opens the barcode, the encryption server selects the valid encryption code according to the request and the validation rule of the encryption code, and sends the valid encryption code to the user client, thereby achieving the effect of updating the barcode. The effective encryption code can be selected to update the bar code of the user according to the operation of opening the bar code by the user. The user is prevented from being disturbed when the user does not need the encryption device, and effective encryption codes can be saved.
Example two
Fig. 2 is a schematic flowchart of an encryption method for a barcode according to a second embodiment of the present invention. In this embodiment, the encryption code queue is optimized as a digital queue composed according to a set generation rule, and accordingly, the encryption code queue is specifically optimized as follows: and sending the encryption code validation rules in the encryption code queue and the encryption code queue to verification equipment.
Correspondingly, the method for encrypting the barcode provided by the embodiment specifically includes:
and step 210, establishing a fixed encryption code queue, wherein the encryption code queue is a digital queue formed according to a set generation rule.
Each digit of the bar code is a number, and therefore, the encrypted code queue is also a number queue. Meanwhile, for the convenience of verification, the encryption code queue may be a digital queue generated according to a certain rule. In this embodiment, the encryption code queue is generated according to a set generation rule. Illustratively, it may be a queue of integer numbers that sequentially increments or decrements, such as (1,2,3^ 999); or the encryption code queue is a number queue composed of prime numbers, singular numbers or even numbers in sequence.
S220, sending the set generation rule for generating the encryption code queue and the encryption code validation rule to the verification equipment.
The verification equipment can obtain the corresponding encryption code queue according to the set generation rule of the encryption code queue, and can verify the validity of the bar code according to the set generation rule and the encryption code validation rule of the encryption code queue. In this embodiment, the encryption server may send a set generation rule for generating an encryption code queue and the encryption code validation rule to the verification device through a network. So that the authentication device can generate a queue of encrypted codes. And verifying the validity of the bar code.
And S230, selecting effective encryption codes from the encryption code queue according to the encryption code validation rule, and sending the effective encryption codes to the user client to update the bar code of the user, wherein the bar code is used for scanning by the verification equipment to obtain the encryption codes and verifying the encryption codes.
In this embodiment, the encryption code queue is optimized as a digital queue formed according to a set generation rule, and accordingly, the encryption code queue is specifically optimized as follows: sending the encryption code validation rules in the encryption code queue and the encryption code queue to verification equipment, specifically optimizing as follows: and sending the set generation rule for generating the encryption code queue and the encryption code validation rule to the verification equipment. Various encryption code digital queues can be generated according to different set generation rules. The user can set different generation rules according to the requirement. Meanwhile, only the set generation rule of the generated encryption code queue is needed, and the encryption code queue does not need to be sent again, so that the data transmission quantity between the encryption server and the verification device can be effectively reduced.
EXAMPLE III
Fig. 3 is a schematic flowchart of an encryption method for a barcode according to a third embodiment of the present invention. In this embodiment, the encryption code validation rule is optimized to the start position of the effective area and the number of code bits of the effective area; or an effective area start position and an effective area end position. Correspondingly, effective encryption codes are selected from the encryption code queue according to the effective rule of the encryption codes and are sent to the user client, so that the bar codes of the users can be updated to be specifically optimized as follows: and according to the effective rule of the encryption codes, selecting the next effective encryption code in the effective area of the encryption code queue according to the position of the encryption code updated last time, and sending the next effective encryption code to the user client so as to update the bar code of the user.
Correspondingly, the method for encrypting the barcode provided by the embodiment specifically includes:
s310, establishing a fixed encryption code queue.
S320, sending the starting position of the effective region of the encryption code and the number of the code bits of the effective region, or the starting position of the effective region and the ending position of the effective region, and the encryption code queue to verification equipment.
In this embodiment, the number of encryption codes usable per day may be determined according to the required usage time of the encryption code queue. And further determining the effective rule of the encryption code. For example, the number of the encryption codes may be calculated according to the start position of the valid region of the encryption codes and the number of bits of the valid region code, or the start position of the valid region and the end position of the valid region code, as the validity rule of the encryption codes. Illustratively, the encryption code has 4 bits, and the encryption code sequence may be (0, 9999). If the number of usable encryption codes per day is 200 and the effective range of the encryption codes is 0-199, the effective rule of the encryption codes is that the initial position of the effective area of the encryption codes is 0 and the number of code bits of the effective area is 200. Alternatively, the effective rule of the encryption code may be that the start position of the effective area of the encryption code is 0, and the end position of the effective area of the encryption code is 199.
S330, according to the effective rule of the encryption codes, selecting the next effective encryption code in the effective area of the encryption code queue according to the position of the encryption code updated last time, and sending the next effective encryption code to the user client so as to update the bar code of the user.
Because the encryption code queue not only comprises valid encryption codes, but also comprises invalid encryption codes. When updating the barcode of the user client, the next valid encryption code needs to be selected in the valid area of the encryption code queue according to the valid rule of the encryption code in step S320 and according to the location of the encryption code updated last time. Illustratively, the encryption code queue is (0, 9999). The effective rule of the encryption code is that the start position of the effective area of the encryption code is 0, and the end position of the effective area is 199. If the position of the last updated encryption code is 21, selecting the next valid encryption code 22 at the position 21 from the valid areas 0-199 of the encryption code queue, and sending the valid encryption code 22 to the user client to update the barcode of the user.
The embodiment optimizes the effective rule of the encryption codes into the starting position of the effective area and the number of code bits of the effective area; or an effective area start position and an effective area end position. Correspondingly, effective encryption codes are selected from the encryption code queue according to the effective rule of the encryption codes and are sent to the user client, so that the bar codes of the users can be updated to be specifically optimized as follows: and according to the effective rule of the encryption codes, selecting the next effective encryption code in the effective area of the encryption code queue according to the position of the encryption code updated last time, and sending the next effective encryption code to the user client so as to update the bar code of the user. The encryption codes in a certain area can be selected from the encryption code queue as effective encryption codes. The corresponding number of the encryption codes is convenient to set according to the requirement. And selecting the next encryption code to send to the user client according to the encryption code validation rule and the encryption code position updated last time, so that the waste of effective encryption codes in the encryption code queue is avoided, and the availability of the effective encryption codes in the encryption code queue is enhanced.
Example four
Fig. 4 is a schematic flowchart of an encryption method for a barcode according to a fourth embodiment of the present invention. In this embodiment, the method further includes the following steps: and updating the encryption code validation rule and/or the encryption code queue according to a preset rotation rule, and sending the encryption code validation rule and/or the encryption code queue to the verification equipment.
Correspondingly, the method for encrypting the barcode provided by the embodiment specifically includes:
step 410, establishing a fixed encryption code queue.
And step 420, sending the encryption code validation rules in the encryption code queue and the encryption code queue to a verification device.
And 430, selecting effective encryption codes from the encryption code queue according to the encryption code validation rule, and sending the effective encryption codes to the user client to update the bar codes of the user, wherein the bar codes are used for scanning by the verification equipment to obtain the encryption codes and verifying the encryption codes.
And step 440, recording the encryption code queue, the encryption code validation rule and the position of the currently updated valid encryption code in the encryption code queue respectively for each user.
Typically, information for each user is included in the bar code. Illustratively, it may be the user's number, which is part of the bar code. For each user, the bar code encryption code will typically comprise a different encryption code. Meanwhile, the encryption code queue, the encryption code validation rule and the position of the currently updated valid encryption code in the encryption code queue are respectively recorded for each user. When each user client sends an updating request, the encryption code corresponding to the user can be selected to be sent to the user client. And updating the user bar code.
The present embodiment adds the following steps: and respectively recording the encryption code queue, the encryption code validation rule and the position of the currently updated effective encryption code in the encryption code queue for each user. Different effective encryption codes can be set for different users, and the effective encryption codes of different users can be updated.
EXAMPLE five
Fig. 5 is a schematic flowchart of an encryption method for a barcode according to a fifth embodiment of the present invention. In this embodiment, the method further includes the following steps: and updating the encryption code validation rule and/or the encryption code queue according to a preset rotation rule, and sending the encryption code validation rule and/or the encryption code queue to the verification equipment.
Correspondingly, the method for encrypting the barcode provided by the embodiment specifically includes:
step 510, establishing a fixed encryption code queue;
and step 520, sending the encryption code validation rules in the encryption code queue and the encryption code queue to verification equipment.
And 530, selecting effective encryption codes from the encryption code queue according to the encryption code validation rule, and sending the effective encryption codes to the user client to update the bar codes of the user, wherein the bar codes are used for scanning by the verification equipment to obtain the encryption codes and verifying the encryption codes.
And 540, updating the encryption code validation rule and/or the encryption code queue according to a preset rotation rule, and sending the encryption code validation rule and/or the encryption code queue to the verification equipment.
Since the number of encrypted codes in the encryption code queue is not infinitely extended, it may happen that all the encryption codes in the encryption code queue are used. Therefore, the encryption codes need to be rotated to meet the requirement of updating the bar codes. In this embodiment, the encryption code validation rule and/or the encryption code queue are updated according to a preset rotation rule. For example, the encryption range of the current day may be replaced by a set time (e.g., 24 hours), and the previous encryption range may be moved by a set distance as a new encryption range. For example, yesterday 1-200 is valid, today 30-230. Or updating the encryption code queue according to a set time, for example, yesterday encryption code queue is a number queue composed of odd numbers, today encryption code queue is a number queue composed of even numbers. Or, the encryption code validation rule and the encryption code queue can be updated simultaneously to achieve the purpose of rotating the encryption codes. And updating the encryption code validation rule and/or the encryption code queue according to a preset rotation rule to be sent to verification equipment, so that the verification equipment can verify the validity of the bar code according to the rotation rule.
The present embodiment adds the following steps: and updating the encryption code validation rule and/or the encryption code queue according to a preset rotation rule, and sending the encryption code validation rule and/or the encryption code queue to the verification equipment. The encryption codes in different periods can be repeatedly used according to a preset alternation rule. The kind of the encryption code queue and/or the number of encryption codes usable in the encryption code queue are increased.
EXAMPLE six
Fig. 6 is a schematic flowchart of a method for verifying a barcode according to a sixth embodiment of the present invention, where the method according to the present embodiment may be executed by a barcode verification apparatus, and the apparatus may be implemented by hardware and/or software, and may be generally applied to a verification device. And the authentication of the bar code is realized through the cooperation with the encryption server and the user client.
Referring to fig. 6, the method for verifying a barcode includes:
and step 610, receiving the encryption code queue and the encryption code validation rule sent by the encryption server.
The encryption server establishes a fixed encryption code queue and sends the generated encryption code queue and the encryption code validation rule to the verification equipment, so that the verification equipment can authenticate the validity of the bar code displayed by the user client according to the received encryption code queue and the received encryption code validation rule.
Step 620, scanning the bar code provided by the user client to obtain the encryption code to be verified.
After a light source emitted by the verification equipment is reflected on the bar code, reflected light irradiates a photoelectric converter in the verification equipment, and the photoelectric converter converts the reflected light signals into corresponding electric signals according to different intensities. And the analog electric signal is converted into a corresponding digital signal, so that the information contained in the bar code is acquired. Because the encryption code is arranged at a fixed position in the bar code, the encryption code to be verified can be obtained by reading the fixed position.
Step 630, according to the encryption code queue and the encryption code validation rule, judging whether the encryption code to be verified is in the effective area of the encryption code queue to verify the validity of the bar code.
According to the received encryption code queue and the encryption code validation rule, the effective area of the encryption code queue can be determined, whether the obtained encryption code to be verified is in the effective area or not is judged, and if the encryption code to be verified is in the effective area, the bar code is valid; otherwise, the bar code is invalid.
In the embodiment, validity authentication is performed on the scanned bar code according to the validation rule of the encryption codes in the received encryption code queue and the encryption code queue. Compared with the method of encrypting by adopting a timestamp, the verification device can accurately verify the validity of the encryption code without depending on self timing.
In a preferred implementation manner of this embodiment, the method for verifying a barcode may further include the following steps: and respectively recording the received encryption code queue and the encryption code validation rule for each user. For each user, the bar code encryption code will typically comprise a different encryption code. Meanwhile, aiming at each user, the received encryption code queue and the validation rule of the encryption code corresponding to the user are respectively recorded. The targeted verification of the encryption code of each user can be realized.
EXAMPLE seven
Fig. 7 is a flowchart illustrating a bar code verification method according to a seventh embodiment of the present invention. In this embodiment, the encryption code queue and the encryption code validation rule sent by the encryption server are received and optimized based on the above embodiment as follows: receiving a set generation rule of an encryption code queue sent by an encryption server and an encryption code validation rule, and generating the encryption code queue according to the set generation rule.
Correspondingly, the method for verifying the barcode provided by the embodiment specifically includes:
and step 710, receiving a set generation rule of an encryption code queue and an effective rule of the encryption code sent by an encryption server, and generating the encryption code queue according to the set generation rule.
Because the encryption code queue contains more data, the verification device needs to accept a large amount of data to accept the complete encryption code queue. In this embodiment, the verification device may obtain the corresponding encryption code queue by receiving a set generation rule of the encryption code queue and an encryption code validation rule sent by the encryption server. Thereby achieving the purpose of reducing the data transmission quantity. For example, the set generation rule of the encryption code queue can be an integer number queue which is sequentially increased or decreased, such as (1,2,3^ 999); or the encryption code queue is a number queue composed of prime numbers, singular numbers or even numbers in sequence, and the like.
And 720, scanning the bar code provided by the user client to obtain the encryption code to be verified.
And step 730, judging whether the encryption code to be verified is in the effective area of the encryption code queue according to the generated encryption code queue and the encryption code validation rule so as to verify the validity of the bar code.
In this embodiment, the encryption code queue and the encryption code validation rule sent by the encryption server are received and optimized as follows: receiving a set generation rule of an encryption code queue sent by an encryption server and an encryption code validation rule, and generating the encryption code queue according to the set generation rule. The verification device only needs to receive the set generation rule of the encryption code queue to be generated, and does not need to receive the whole encryption code queue, so that the data transmission quantity can be effectively reduced.
Example eight
Fig. 8 is a schematic flowchart of a method for verifying a barcode according to an eighth embodiment of the present invention. In this embodiment, the encryption code validation rule is optimized based on the above embodiment as follows: an active area start position and an active area code bit number; or an effective area start position and an effective area end position.
Correspondingly, the method for verifying the barcode provided by the embodiment specifically includes:
step 810, receiving an encryption code queue and an encryption code validation rule sent by an encryption server, wherein the encryption code validation rule comprises:
an active area start position and an active area code bit number; or
An effective area start position and an effective area end position.
In this embodiment, the number of encryption codes usable per day may be determined according to the required usage time of the encryption code queue. And further determining the effective rule of the encryption code. For example, the number of the encryption codes may be calculated according to the start position of the valid region of the encryption codes and the number of bits of the valid region code, or the start position of the valid region and the end position of the valid region code, as the validity rule of the encryption codes. Illustratively, the encryption code has 4 bits, and the encryption code range (0,9999) has an effective rule that the start position of the effective area of the encryption code is 0 and the number of bits of the effective area is 200 if the number of usable encryption codes per day is 200 and the effective range of the encryption code is 0-199. Or the effective rule of the encryption code is that the start position of the effective area of the encryption code is 0, and the end position of the effective area is 199.
And step 820, scanning the bar code provided by the user client to obtain the encryption code to be verified.
And step 830, judging whether the encryption code to be verified is in the effective area of the encryption code queue according to the encryption code queue and the encryption code validation rule so as to verify the validity of the bar code.
The embodiment optimizes the effective rule of the encryption codes as follows: an active area start position and an active area code bit number; or an effective area start position and an effective area end position. The validity rule of the encryption codes can be determined according to the using amount of the encryption codes. And the waste of effective encryption codes in the encryption code queue is avoided.
In a preferred implementation manner of this embodiment, the determining whether the encryption code to be verified is in the effective area of the encryption code queue to verify the validity of the barcode may be specifically optimized as:
calculating the distance g of the encryption code to be verified according to the following formula: g ═ ((c + L) -p)% L, where c is the position sequence number of the encryption code to be verified in the encryption code queue, L is the encryption code queue length, and p is the position sequence number of the last used encryption code in the encryption code queue;
the time difference tx is calculated according to the following formula: t2-t1, wherein t1 is the time of the last verification of the encryption code, and t2 is the time of the verification of the encryption code at this time;
if the distance g is larger than 0 and smaller than n, determining that the encryption code to be verified is valid, wherein n is the number of code bits in the valid area;
and if the distance is identified to be equal to 0 and the time difference is smaller than the set time range value, determining that the encryption code to be verified is valid.
According to the formula g ═ c + L-p)% L, the distance between the current encryption code to be verified and the last encryption code to be verified can be quickly judged, and if the distance between the encryption codes is within the range of the preset number n of encryption codes, the current encryption code to be verified is valid. It should be noted that the update rule of the encryption code is not increased by 1 every time, but other setting functions may be used to determine the encryption code every time, and the verification device only needs to use the same setting function to perform verification.
In addition, if the code is refreshed for the first time on the same day, the encryption code verified for the last time does not exist, and only the encryption code to be verified currently is judged whether to be in the encryption code queue, if so, the verification is valid.
If the distance between the encryption code to be verified and the encryption code verified last time is identified to be equal to 0, and the time difference is smaller than the set time range value, the encryption code reaches the upper limit of the number of the valid encryption codes in a period, and therefore the same encryption code appears. As long as the time between two code swipes is within the same period, tx cannot exceed the time of one period, for example, 24 hours. The encryption code is valid. Through the comparison, the possibility that the bar code is illegally brushed for an unlimited number of times due to bar code leakage can be effectively avoided.
Example nine
Fig. 9 is a schematic structural diagram of an encryption apparatus for a barcode according to a ninth embodiment of the present invention, where the barcode encryption apparatus is applied to an encryption server, and as shown in fig. 9, the apparatus includes:
a queue establishing module 910, configured to establish a fixed encryption code queue;
a sending module 920, configured to send the validation rules of the encryption codes in the encryption code queue and the encryption code queue to a verification device;
and an encryption code selecting module 930, configured to select an effective encryption code from the encryption code queue according to an encryption code validation rule, and send the effective encryption code to the user client, so as to update the barcode of the user, where the barcode is used for the verification device to scan to obtain the encryption code and perform verification.
The embodiment sends the pre-established fixed encryption code queue and the encryption code validation rule to the verification equipment, and sends the valid encryption code to the user client so as to update the bar code of the user. Compared with the time stamp adopted as the encryption code, the encryption code queue can provide a larger number of encryption codes under the condition that the distributed encryption bits are the same. And the encryption code can still be accurately verified under the condition that the time reliability of the verification equipment is low. The reliability of the time efficiency verification of the bar code can be ensured.
On the basis of the above embodiments, the encryption code queue is a digital queue composed according to a set generation rule;
correspondingly, the sending module is configured to:
and sending the set generation rule for generating the encryption code queue and the encryption code validation rule to the verification equipment.
On the basis of the above embodiments, the encryption code queue is a digital queue with ascending or descending order; or
The encryption code queue is a number queue composed of prime numbers, singular numbers or even numbers in sequence.
On the basis of the above embodiments, the validation rule of the encryption code includes:
an active area start position and an active area code bit number; or
An effective area start position and an effective area end position.
On the basis of the foregoing embodiments, the encryption code selection module is configured to:
and according to the effective rule of the encryption codes, selecting the next effective encryption code in the effective area of the encryption code queue according to the position of the encryption code updated last time, and sending the next effective encryption code to the user client so as to update the bar code of the user.
On the basis of the above embodiments, the apparatus further includes:
and the recording module is used for respectively recording the encryption code queue, the encryption code validation rule and the position of the currently updated effective encryption code in the encryption code queue aiming at each user.
On the basis of the foregoing embodiments, the encryption code selection module is configured to:
and if the barcode is monitored to be opened in the user client, selecting an effective encryption code from the encryption code queue according to the encryption code validation rule, and sending the effective encryption code to the user client so as to update the barcode of the user.
On the basis of the above embodiments, the apparatus further includes:
and the updating module is used for updating the encryption code validation rule and/or the encryption code queue according to a preset rotation rule and sending the encryption code validation rule and/or the encryption code queue to the verification equipment.
The bar code encryption device provided by the embodiment of the invention can be used for executing the bar code encryption method provided by any embodiment of the invention, has corresponding functional modules and realizes the same beneficial effects.
Example ten
Fig. 10 is a schematic structural diagram of a barcode verification apparatus according to a ninth embodiment of the present invention, where the barcode encryption apparatus is applied to a verification device, and as shown in fig. 10, the apparatus includes:
the receiving module 1010 is used for receiving the encryption code queue and the encryption code validation rule sent by the encryption server;
an encryption code obtaining module 1020, configured to scan a barcode provided by a user client to obtain an encryption code to be verified;
the judging module 1030 is configured to judge whether the encrypted code to be verified is in the effective area of the encrypted code queue according to the encrypted code queue and the encrypted code validation rule, so as to verify the validity of the barcode.
In the embodiment, validity authentication is performed on the scanned bar code according to the validation rule of the encryption codes in the received encryption code queue and the encryption code queue. Compared with the method of encrypting by adopting a timestamp, the verification device can accurately verify the validity of the encryption code without depending on self timing.
On the basis of the above embodiments, the apparatus further includes:
and the recording module is used for respectively recording the received encryption code queue and the encryption code validation rule aiming at each user.
On the basis of the above embodiments, the encryption code queue is a digital queue with ascending or descending order; or the encryption code queue is a digital queue consisting of prime numbers, singular numbers or even numbers in sequence.
On the basis of the above embodiments, the validation rule of the encryption code includes:
an active area start position and an active area code bit number; or
An effective area start position and an effective area end position.
On the basis of the foregoing embodiments, the determining module is configured to:
calculating the distance g of the encryption code to be verified according to the following formula: g ═ ((c + L) -p)% L, where c is the position sequence number of the encryption code to be verified in the encryption code queue, L is the encryption code queue length, and p is the position sequence number of the last used encryption code in the encryption code queue;
the time difference tx is calculated according to the following formula: t2-t1, wherein t1 is the time of the last verification of the encryption code, and t2 is the time of the verification of the encryption code at this time;
if the distance g is larger than 0 and smaller than n, determining that the encryption code to be verified is valid, wherein n is the number of code bits in the valid area;
and if the distance is identified to be equal to 0 and the time difference is smaller than the set time range value, determining that the encryption code to be verified is valid.
The bar code verification device provided by the embodiment of the invention can be used for executing the bar code verification method provided by any embodiment of the invention, has corresponding functional modules and realizes the same beneficial effects.
It will be apparent to those skilled in the art that the modules or steps of the invention described above may be implemented by an apparatus as described above. Alternatively, the embodiments of the present invention may be implemented by programs executable by a computer device, so that they can be stored in a storage device and executed by a processor, where the programs may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.; or separately as individual integrated circuit modules, or as a single integrated circuit module from a plurality of modules or steps within them. Thus, the present invention is not limited to any specific combination of hardware and software.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (20)

1. An encryption method of bar codes is applied to an encryption server and is characterized by comprising the following steps:
establishing a fixed encryption code queue; the encryption code queue is a digital queue formed according to a set generation rule;
sending the set generation rule, the encryption code validation rule in the encryption code queue and the encryption code queue to the verification equipment; wherein, the encryption code queue is a digital queue with ascending order or descending order; or the encryption code queue is a digital queue consisting of prime numbers, singular numbers or even numbers in sequence;
and selecting effective encryption codes from the encryption code queue according to an encryption code effective rule, and sending the effective encryption codes to the user client to update the bar codes of the user, wherein the bar codes are used for scanning by the verification equipment to obtain the encryption codes and verifying the encryption codes.
2. The method of claim 1, wherein the encryption code validation rules comprise:
an active area start position and an active area code bit number; or
An effective area start position and an effective area end position.
3. The method of claim 2, wherein selecting the valid encryption code from the encryption code queue according to the encryption code validation rule, and sending the valid encryption code to the user client to update the user's barcode comprises:
and according to the effective rule of the encryption codes, selecting the next effective encryption code in the effective area of the encryption code queue according to the position of the encryption code updated last time, and sending the next effective encryption code to the user client so as to update the bar code of the user.
4. The method of claim 3, further comprising:
and respectively recording the encryption code queue, the encryption code validation rule and the position of the currently updated effective encryption code in the encryption code queue for each user.
5. The method of claim 1, wherein selecting the valid encryption code from the encryption code queue according to the encryption code validation rule, and sending the valid encryption code to the user client to update the user's barcode comprises:
and if the barcode is monitored to be opened in the user client, selecting an effective encryption code from the encryption code queue according to the encryption code validation rule, and sending the effective encryption code to the user client so as to update the barcode of the user.
6. The method of claim 1, further comprising:
and updating the encryption code validation rule and/or the encryption code queue according to a preset rotation rule, and sending the encryption code validation rule and/or the encryption code queue to the verification equipment.
7. A bar code verification method is applied to verification equipment and is characterized by comprising the following steps:
receiving a set generation rule of an encryption code queue, an encryption code validation rule and an encryption code queue generated according to the set generation rule sent by an encryption server; wherein, the encryption code queue is a digital queue with ascending order or descending order; or the encryption code queue is a digital queue consisting of prime numbers, singular numbers or even numbers in sequence;
scanning a bar code provided by a user client to obtain an encryption code to be verified;
and judging whether the encryption code to be verified is in the effective area of the encryption code queue according to the encryption code queue and the encryption code validation rule so as to verify the validity of the bar code.
8. The method of claim 7, further comprising:
and respectively recording the received encryption code queue and the encryption code validation rule for each user.
9. The method according to any of claims 7-8, wherein the encryption code validation rules comprise:
an active area start position and an active area code bit number; or
An effective area start position and an effective area end position.
10. The method of claim 9, wherein determining whether the encrypted code to be verified is within a valid region of an encrypted code queue to verify validity of the bar code comprises:
calculating the distance g of the encryption code to be verified according to the following formula: g ═ ((c + L) -p)% L, where c is the position sequence number of the encryption code to be verified in the encryption code queue, L is the encryption code queue length, and p is the position sequence number of the last used encryption code in the encryption code queue;
the time difference tx is calculated according to the following formula: t2-t1, wherein t1 is the time of the last verification of the encryption code, and t2 is the time of the verification of the encryption code at this time;
if the distance g is larger than 0 and smaller than n, determining that the encryption code to be verified is valid, wherein n is the number of code bits in the valid area;
and if the distance is identified to be equal to 0 and the time difference is smaller than the set time range value, determining that the encryption code to be verified is valid.
11. An encryption device of bar code, which is applied to an encryption server, is characterized by comprising:
the queue establishing module is used for establishing a fixed encryption code queue; the encryption code queue is a digital queue formed according to a set generation rule;
the sending module is used for sending the set generation rule, the encryption code validation rule in the encryption code queue and the encryption code queue to the verification equipment; wherein, the encryption code queue is a digital queue with ascending order or descending order; or the encryption code queue is a digital queue consisting of prime numbers, singular numbers or even numbers in sequence;
and the encryption code selection module is used for selecting effective encryption codes from the encryption code queue according to the encryption code validation rule and sending the effective encryption codes to the user client so as to update the bar code of the user, wherein the bar code is used for scanning by the verification equipment to obtain the encryption codes and verifying the encryption codes.
12. The apparatus of claim 11, wherein the encryption code validation rules comprise:
an active area start position and an active area code bit number; or
An effective area start position and an effective area end position.
13. The apparatus of claim 12, wherein the encryption code selection module is configured to:
and according to the effective rule of the encryption codes, selecting the next effective encryption code in the effective area of the encryption code queue according to the position of the encryption code updated last time, and sending the next effective encryption code to the user client so as to update the bar code of the user.
14. The apparatus of claim 13, further comprising:
and the recording module is used for respectively recording the encryption code queue, the encryption code validation rule and the position of the currently updated effective encryption code in the encryption code queue aiming at each user.
15. The apparatus of claim 11, wherein the encryption code selection module is configured to:
and if the barcode is monitored to be opened in the user client, selecting an effective encryption code from the encryption code queue according to the encryption code validation rule, and sending the effective encryption code to the user client so as to update the barcode of the user.
16. The apparatus of claim 11, further comprising:
and the updating module is used for updating the encryption code validation rule and/or the encryption code queue according to a preset rotation rule and sending the encryption code validation rule and/or the encryption code queue to the verification equipment.
17. A bar code verification device applied to verification equipment is characterized by comprising:
the receiving module is used for receiving a set generation rule of an encryption code queue, an encryption code validation rule and the encryption code queue generated according to the set generation rule sent by the encryption server; wherein, the encryption code queue is a digital queue with ascending order or descending order; or the encryption code queue is a digital queue consisting of prime numbers, singular numbers or even numbers in sequence;
the encryption code acquisition module is used for scanning a bar code provided by a user client to acquire an encryption code to be verified;
and the judging module is used for judging whether the encryption code to be verified is in the effective area of the encryption code queue according to the encryption code queue and the encryption code validation rule so as to verify the validity of the bar code.
18. The apparatus of claim 17, further comprising:
and the recording module is used for respectively recording the received encryption code queue and the encryption code validation rule aiming at each user.
19. The apparatus according to any one of claims 17-18, wherein the encryption code validation rules comprise:
an active area start position and an active area code bit number; or
An effective area start position and an effective area end position.
20. The apparatus of claim 19, wherein the determining module is configured to:
calculating the distance g of the encryption code to be verified according to the following formula: g ═ ((c + L) -p)% L, where c is the position sequence number of the encryption code to be verified in the encryption code queue, L is the encryption code queue length, and p is the position sequence number of the last used encryption code in the encryption code queue;
the time difference tx is calculated according to the following formula: t2-t1, wherein t1 is the time of the last verification of the encryption code, and t2 is the time of the verification of the encryption code at this time;
if the distance g is larger than 0 and smaller than n, determining that the encryption code to be verified is valid, wherein n is the number of code bits in the valid area;
and if the distance is identified to be equal to 0 and the time difference is smaller than the set time range value, determining that the encryption code to be verified is valid.
CN201610648028.5A 2016-08-09 2016-08-09 Method and device for encrypting and verifying bar code Active CN107707345B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610648028.5A CN107707345B (en) 2016-08-09 2016-08-09 Method and device for encrypting and verifying bar code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610648028.5A CN107707345B (en) 2016-08-09 2016-08-09 Method and device for encrypting and verifying bar code

Publications (2)

Publication Number Publication Date
CN107707345A CN107707345A (en) 2018-02-16
CN107707345B true CN107707345B (en) 2021-08-13

Family

ID=61168922

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610648028.5A Active CN107707345B (en) 2016-08-09 2016-08-09 Method and device for encrypting and verifying bar code

Country Status (1)

Country Link
CN (1) CN107707345B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20120137093A (en) * 2011-06-10 2012-12-20 고려대학교 산학협력단 Secret key of password generating system and method using 2 dimensional barcode

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105373927B (en) * 2014-08-26 2020-06-02 腾讯科技(深圳)有限公司 Ticket code generation method and device of electronic ticket and server
CN104581726B (en) * 2015-01-15 2018-07-17 天地融科技股份有限公司 A kind of authentication method and system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20120137093A (en) * 2011-06-10 2012-12-20 고려대학교 산학협력단 Secret key of password generating system and method using 2 dimensional barcode

Also Published As

Publication number Publication date
CN107707345A (en) 2018-02-16

Similar Documents

Publication Publication Date Title
CN106600259A (en) Mobile payment method and device, and mobile terminal
CN105426743B (en) Account authority authorization method, account login method, server and client
JP2011524560A (en) Data collection and targeted advertising systems and methods
US8789167B2 (en) Fraud-proof location identification system
CN107888553B (en) Verification method, server and system
CN1868153B (en) Methods and apparatus for determining device integrity
CN110290146A (en) Share generation method, device, server and the storage medium of password
CN104137577A (en) Positioning method and apparatus and computer program product
CN108235075B (en) Video quality grade matching method, computer readable storage medium and terminal
CN110909314A (en) Data sharing method, device and equipment based on block chain and readable storage medium
CN107707345B (en) Method and device for encrypting and verifying bar code
KR101108684B1 (en) Apparatus, Method for Providing Three Dimensional Display and Terminal for Three Dimensional Display
CN109741099B (en) Method and device for acquiring equipment characteristic information
US9047618B2 (en) Operating system based event verification
CN111026926A (en) Data processing method, device, equipment and storage medium
CN106502728B (en) Management method and device for downloading application program and electronic equipment
CN114205406B (en) Red packet receiving and sending method, device, equipment and storage medium
CN109905395A (en) A kind of believable method of verifying client and relevant apparatus
CN115688066A (en) Electronic signature method, device, storage medium and computer equipment
CN114302207A (en) Bullet screen display method, device, system, equipment and storage medium
CN111787642A (en) Third-party application based authentication networking method and device
CN103782304B (en) The method of pre-configured key during for manufacture
CN105139059A (en) Two-dimensional code generation method and device
CN112214751A (en) Verification code generation method and device
CN105163331B (en) A kind of method and mobile terminal shared for mobile terminal flow

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