CN102916804B - Two-dimension code coding and decoding method and device based on local color verification - Google Patents
Two-dimension code coding and decoding method and device based on local color verification Download PDFInfo
- Publication number
- CN102916804B CN102916804B CN201210311536.6A CN201210311536A CN102916804B CN 102916804 B CN102916804 B CN 102916804B CN 201210311536 A CN201210311536 A CN 201210311536A CN 102916804 B CN102916804 B CN 102916804B
- Authority
- CN
- China
- Prior art keywords
- quick response
- response code
- information
- dimensional code
- code
- 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
Links
Landscapes
- Editing Of Facsimile Originals (AREA)
- Image Processing (AREA)
Abstract
本发明公开了一种基于局部颜色校验的二维码编码方法及装置、解码方法及装置,其中编码方法是根据事先定义的染色区域编码解码表,随机生成染色区域数据,以生成的染色区域数据作为密钥进行加密,得到二维码生成信息;然后通过二维码生成算法生成二维码黑白图像;最后根据染色区域数据对得到的二维码黑白图像进行染色,得到局部彩色二维码图像。解码方法是读取二维码图像上的染色区域数据,使用标准二维码解码算法进行解码;对解码后的信息以染色区域数据为密钥通过解密算法进行解密,得到二维码图像的原始信息。本发明在原有黑白二色的基础上,增加了染色区域信息,能够扩充二维码的编码空间,提高被仿冒的难度。
The invention discloses a two-dimensional code encoding method and device based on local color verification, a decoding method and a device, wherein the encoding method is to randomly generate dyeing area data according to a previously defined dyeing area encoding and decoding table, and use the generated dyeing area The data is encrypted as a key to obtain the generation information of the two-dimensional code; then the black and white image of the two-dimensional code is generated by the two-dimensional code generation algorithm; finally, the black and white image of the two-dimensional code is dyed according to the dyed area data to obtain the partial color two-dimensional code image. The decoding method is to read the dyed area data on the two-dimensional code image, and use the standard two-dimensional code decoding algorithm to decode; the decoded information is decrypted by the decryption algorithm with the dyed area data as the key, and the original two-dimensional code image is obtained. information. On the basis of the original black and white two colors, the invention adds dyed area information, can expand the coding space of the two-dimensional code, and increases the difficulty of being counterfeited.
Description
技术领域 technical field
本发明涉及二维码编码、解码研究领域,特别涉及一种基于局部颜色校验的二维码编码方法、编码装置及解码方法和解码装置。The invention relates to the field of two-dimensional code coding and decoding research, in particular to a two-dimensional code coding method, coding device, decoding method and decoding device based on local color verification.
背景技术 Background technique
二维码是用某种特定的几何图形按一定规律在平面(二维方向上)分布的黑白相间的图形记录数据符号信息,在代码编制上巧妙地利用构成计算机内部逻辑基础的“0”、“1”比特流的概念,使用若干个与二进制相对应的几何形体来表示文字数值信息,通过图象输入设备或光电扫描设备自动识读以实现信息自动处理。它具有条码技术的一些共性:每种码制有其特定的字符集;每个字符占有一定的宽度;具有一定的校验功能等。同时还具有对不同行的信息自动识别功能、及处理图形旋转变化等特点。Two-dimensional code is to record data symbol information with a specific geometric figure distributed on a plane (two-dimensional direction) according to a certain rule, ingeniously using "0", The concept of "1" bit stream uses several geometric shapes corresponding to binary to represent text and numerical information, which can be automatically read by image input equipment or photoelectric scanning equipment to realize automatic information processing. It has some common features of barcode technology: each code system has its specific character set; each character occupies a certain width; it has certain verification functions, etc. At the same time, it also has the characteristics of automatic identification of information in different rows, and processing of graphic rotation changes.
二维条码具有保密性高、追踪性高、抗损性强、备援性大、成本低等特性,现已广泛地应用在表单、安全保密、追踪、证照、存货盘点、资料备援等方面。但是因为编/解码技术公开,制作假冒的二维码的门槛也很低。另外标准二维码版本都是使用黑白二色,其编码空间也有限。The two-dimensional barcode has the characteristics of high confidentiality, high traceability, strong damage resistance, large backup, and low cost. It has been widely used in forms, security and confidentiality, tracking, licenses, inventory, data backup, etc. . But because the encoding/decoding technology is public, the threshold for making fake QR codes is also very low. In addition, the standard two-dimensional code version uses black and white and two colors, and its coding space is also limited.
因此,需要一种行之有效的防伪标识,一方面能使二维码被仿冒难度加大,另一方面能扩充二维码的编码空间,保证二维码不被篡改。Therefore, there is a need for an effective anti-counterfeiting mark, which can increase the difficulty of counterfeiting the two-dimensional code on the one hand, and expand the coding space of the two-dimensional code on the other hand to ensure that the two-dimensional code is not tampered with.
发明内容 Contents of the invention
本发明的主要目的在于克服现有技术的缺点与不足,提供一种基于局部颜色校验的二维码编码方法、编码装置及解码方法和解码装置,上述编解码装置和方法是基于局部颜色校验的,在原有黑白二色的基础上,增加了染色区域信息,能够扩充二维码的编码空间,同时提高二维码被仿冒的难度。The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art, and provide a two-dimensional code encoding method, encoding device, decoding method and decoding device based on local color verification. The above encoding and decoding device and method are based on local color verification. Experimentally, on the basis of the original black and white two colors, the dyed area information is added, which can expand the coding space of the two-dimensional code and increase the difficulty of the two-dimensional code being counterfeited.
本发明的目的通过以下的技术方案实现:The purpose of the present invention is achieved through the following technical solutions:
一种基于局部颜色校验的二维码编码方法,包括以下步骤:A two-dimensional code encoding method based on local color verification, comprising the following steps:
(1)在二维码模板上,根据事先定义的染色区域编码解码表,随机生成染色区域数据,染色区域数据包括染色区域数量、各染色区域的形状、各染色区域的颜色;(1) On the two-dimensional code template, according to the pre-defined dyeing area code decoding table, the dyeing area data is randomly generated, and the dyeing area data includes the number of dyed areas, the shape of each dyed area, and the color of each dyed area;
(2)将二维码原始信息以步骤(1)生成的染色区域数据作为密钥进行加密,得到二维码生成信息;(2) Encrypt the original information of the QR code with the dyed area data generated in step (1) as a key to obtain the generation information of the QR code;
(3)将步骤(2)得到的二维码生成信息通过二维码生成算法生成二维码黑白图像;(3) Using the two-dimensional code generation information obtained in step (2) to generate a black-and-white image of the two-dimensional code through the two-dimensional code generation algorithm;
(4)根据步骤(1)所制定的二维码模板和生成的染色区域数据对步骤(3)得到的二维码黑白图像进行染色,最终得到局部彩色二维码图像。(4) Dye the black-and-white image of the two-dimensional code obtained in step (3) according to the two-dimensional code template formulated in step (1) and the generated dyed area data, and finally obtain a partial color two-dimensional code image.
优选的,所述步骤(1)中,事先定义的染色区域编码解码表是指事先根据染色区域可能出现的形状和颜色分别建立的编码解码表,在形状编码解码表中,定义每一种形状对应一个数值,同样在颜色编码解码表中,定义每一种颜色对应一个数值,然后连同染色区域数量,建立<染色区域数量i,各染色区域形状S,各染色区域颜色C>的密钥向量。Preferably, in the step (1), the pre-defined coding and decoding table of the stained area refers to the coding and decoding table established in advance according to the possible shapes and colors of the stained area. In the shape coding and decoding table, each shape is defined Corresponding to a numerical value, also in the color coding decoding table, define that each color corresponds to a numerical value, and then together with the number of dyed regions, establish the key vector of <the number of dyed regions i, the shape S of each dyed region, and the color C of each dyed region> .
优选的,所述步骤(2)中,二维码原始信息包括需加密的隐藏信息和不需加密的明文信息,将需加密的隐藏信息以步骤(1)生成的染色区域数据作为密钥进行加密,然后将得到的加密后的隐藏信息和不需加密的明文信息进行拼合得到二维码生成信息。Preferably, in the step (2), the original information of the two-dimensional code includes hidden information that needs to be encrypted and plaintext information that does not need to be encrypted, and the hidden information that needs to be encrypted is encrypted with the dyed area data generated in step (1) as a key. Encrypt, and then combine the obtained encrypted hidden information with the plaintext information that does not need to be encrypted to obtain the two-dimensional code generation information.
更进一步的,所述步骤(2)中,把需加密的隐藏信息,以步骤(1)所生成的<i,S,C>的密钥向量,根据现有公开双向加密算法(不需指定某个,可以根据现有技术任选)进行加密,得到加密后的隐藏信息。Furthermore, in the step (2), the hidden information to be encrypted is used as the key vector of <i, S, C> generated in the step (1), according to the existing public two-way encryption algorithm (no need to specify One, can be selected according to the existing technology) to encrypt to obtain encrypted hidden information.
更进一步的,所述步骤(2)中,将明文信息和加密后的隐藏信息进行拼合采用如下的算法:把明文信息记为M1,加密后的隐藏信息记为M2,使用分隔符w进行拼接。一种简单的拼接方式是二维码信息M=M1+w+M2,密文信息紧跟明文信息后,以此思路可以由二维码生成方进行明文和密文的简单字符串拼接工作。另一种简单拼接方式是插入拼接,二维码信息M=M11+M21+M12+M22……,按照固定的插入位置把隐藏信息插入到明文信息里面,以此思路也可以由二维码生成方进行明文和密文的字符串拼接。Furthermore, in the step (2), the plaintext information and the encrypted hidden information are combined using the following algorithm: record the plaintext information as M 1 , record the encrypted hidden information as M 2 , and use the delimiter w to splice. A simple splicing method is two-dimensional code information M=M 1 +w+M 2 , and the ciphertext information follows the plaintext information. In this way, the two-dimensional code generator can perform simple string splicing of plaintext and ciphertext Work. Another simple splicing method is insertion splicing. The two-dimensional code information M=M 11 +M 21 +M 12 +M 22 ... inserts the hidden information into the plaintext information according to the fixed insertion position. This idea can also be obtained by The two-dimensional code generator performs string concatenation of plaintext and ciphertext.
优选的,所述步骤(3)中,将二维码生成信息生成二维码图像采用如下的二维码生成算法:根据步骤(2)得到的二维码生成信息,使用标准的二维码生成算法(例如二维码PDF417、Datamatrix、Maxicode、QR Code、Code 49、Code16K、Vericode、Ultracode的生成算法),生成标准的二维码黑白图像。Preferably, in the step (3), the following two-dimensional code generation algorithm is used to generate the two-dimensional code image from the two-dimensional code generation information: according to the two-dimensional code generation information obtained in step (2), a standard two-dimensional code is used Generate algorithms (such as generation algorithms of QR code PDF417, Datamatrix, Maxicode, QR Code, Code 49, Code16K, Vericode, Ultracode) to generate standard QR code black and white images.
一种基于局部颜色校验的二维码解码方法,包括以下步骤:A two-dimensional code decoding method based on local color verification, comprising the following steps:
(1)根据事先定义的染色区域编码解码表,读取二维码图像上的染色区域数据,染色区域数据包括染色区域数量、各染色区域的形状、各染色区域的颜色;(1) Read the dyed area data on the two-dimensional code image according to the pre-defined dyed area encoding and decoding table. The dyed area data includes the number of dyed areas, the shape of each dyed area, and the color of each dyed area;
(2)读取二维码图像,把局部染色的二维码图像中的有颜色区域作为黑色区域,然后将二维码图像当作标准黑白二维码图像,使用标准二维码解码算法进行解码;(2) Read the two-dimensional code image, take the colored area in the partially dyed two-dimensional code image as the black area, and then treat the two-dimensional code image as a standard black and white two-dimensional code image, and use the standard two-dimensional code decoding algorithm decoding;
(3)对解码后的信息以染色区域数据为密钥通过解密算法进行解密,得到二维码图像的原始信息。(3) Decrypt the decoded information with the dyed area data as the key through the decryption algorithm to obtain the original information of the two-dimensional code image.
优选的,所述步骤(2)中,采用现有标准的二维码解码算法(例如二维码PDF417、Datamatrix、Maxicode、QR Code、Code 49、Code 16K、Vericode、Ultracode解码算法)对原始的二维码图像信息进行解码。Preferably, in the step (2), an existing standard two-dimensional code decoding algorithm (such as two-dimensional code PDF417, Datamatrix, Maxicode, QR Code, Code 49, Code 16K, Vericode, Ultracode decoding algorithm) is used to decode the original The two-dimensional code image information is decoded.
优选的,所述步骤(3)中,解码后的信息包括已加密的隐藏信息和未加密的明文信息,步骤如下:首先通过拆分算法将解码后的信息拆分为加密的隐藏信息和未加密的明文信息;再将已加密的隐藏信息以步骤(1)生成的染色区域数据作为密钥采用解密算法进行解密,最后得到二维码图像的原始信息。Preferably, in the step (3), the decoded information includes encrypted hidden information and unencrypted plaintext information, and the steps are as follows: firstly, the decoded information is split into encrypted hidden information and unencrypted plaintext information by a splitting algorithm. Encrypted plaintext information; then use the decryption algorithm to decrypt the encrypted hidden information using the dyed area data generated in step (1) as a key, and finally obtain the original information of the two-dimensional code image.
更进一步的,所述步骤(3)中,将明文信息和加密后的隐藏信息进行拆分采用如下的算法:在所述步骤(2)得到的二维码简单拼接信息中,寻找进行明文和密文的拆分依据的分隔符(记为w),分隔符前后分别为明文数据和密文数据,一种简单的拆分方式是根据二维码信息M=M1+w+M2,拆分明文数据M1和密文数据M2。在所述步骤(2)得到二维码插入拼接信息中,根据二维码信息M=M11+M21+M12+M22……,还原M1=M11+M12+M13……,M2=M21+M22+M23……,还原明文数据M1和密文数据M2。Furthermore, in the step (3), the following algorithm is used to split the plaintext information and the encrypted hidden information: in the simple splicing information of the two-dimensional code obtained in the step (2), search for plaintext and encrypted information. The splitting of ciphertext is based on the delimiter (denoted as w). The delimiter is followed by plaintext data and ciphertext data respectively. A simple splitting method is based on the two-dimensional code information M=M 1 +w+M 2 , Split plaintext data M 1 and ciphertext data M 2 . In the step (2) to obtain the two-dimensional code insertion splicing information, according to the two-dimensional code information M = M 11 + M 21 + M 12 + M 22 ..., restore M 1 = M 11 + M 12 + M 13 ... ..., M 2 =M 21 +M 22 +M 23 ..., restore plaintext data M 1 and ciphertext data M 2 .
优选的,所述步骤(3)中,对步骤(2)所得到密文数据以染色区域数据为密钥通过标准的双向解密算法进行解密。Preferably, in the step (3), the ciphertext data obtained in the step (2) is decrypted by using the dyed area data as a key through a standard two-way decryption algorithm.
一种基于局部颜色校验的二维码编码装置,包括:A two-dimensional code encoding device based on local color verification, comprising:
染色区域数据生成装置,用于在二维码模板中根据事先定义的染色区域编码解码表生成染色区域;A dyeing area data generation device, used to generate a dyeing area in the two-dimensional code template according to a pre-defined dyeing area encoding and decoding table;
二维码生成装置,包括加密模块和二维码编码模块,所述加密模块与所述二维码编码模块连接,所述二维码生成装置与染色区域数据生成装置连接;加密模块,用于以染色区域数据为密钥对需加密的隐藏信息进行加密;二维码编码模块,用于将加密模块加密后得到的二维码生成信息生成二维码黑白图像;The two-dimensional code generating device includes an encryption module and a two-dimensional code encoding module, the encryption module is connected to the two-dimensional code encoding module, and the two-dimensional code generating device is connected to the stained area data generating device; the encryption module is used for Encrypt the hidden information to be encrypted with the dyed area data as the key; the two-dimensional code encoding module is used to generate the two-dimensional code black and white image by encrypting the two-dimensional code generation information obtained after the encryption module is encrypted;
二维码彩色图像生成装置,根据染色区域数据生成装置的数据对二维码生成装置生成的二维码黑白图像进行染色,得到局部染色的二维码彩色图像。The two-dimensional code color image generation device dyes the two-dimensional code black-and-white image generated by the two-dimensional code generation device according to the data of the dyed area data generation device to obtain a partially dyed two-dimensional code color image.
优选的,所述二维码生成装置还包括拼合模块,拼合模块用于将不需加密的明文信息和已加密的隐藏信息进行拼合,然后将拼合后的数据发送到二维码编码模块;所述拼合模块分别与加密模块、二维码编码模块连接。Preferably, the two-dimensional code generating device further includes a splicing module, which is used to splice plaintext information that does not need to be encrypted and encrypted hidden information, and then send the spliced data to the two-dimensional code encoding module; The combination module is respectively connected with the encryption module and the two-dimensional code encoding module.
一种基于局部颜色校验的二维码解码装置,包括:A two-dimensional code decoding device based on local color verification, comprising:
二维码染色区域读取装置,用于根据事先定义的染色区域编码解码表读取二维码图像中染色区域数据;The two-dimensional code dyeing area reading device is used to read the dyeing area data in the two-dimensional code image according to the previously defined dyeing area encoding and decoding table;
二维码读取装置,包括:Two-dimensional code reading device, including:
读取模块,用于读取二维码图像;A reading module for reading two-dimensional code images;
二维码解码模块,用于对读取模块读取到的二维码图像信息进行解码;The two-dimensional code decoding module is used to decode the two-dimensional code image information read by the reading module;
解密模块,用于以染色区域数据为密钥对解码后加密的隐藏信息进行解密;The decryption module is used to decrypt the encrypted hidden information after decoding with the dyed area data as the key;
所述读取模块、二维码解码模块、解密模块依次连接。The reading module, the two-dimensional code decoding module and the decryption module are connected in sequence.
优选的,所述二维码读取装置还包括拆分模块,用于将二维码解码模块解码后的信息拆分成不经加密的明文信息和经加密的隐藏信息;所述拆分模块分别与二维码解码模块、解密模块连接。Preferably, the two-dimensional code reading device further includes a splitting module, which is used to split the information decoded by the two-dimensional code decoding module into unencrypted plaintext information and encrypted hidden information; the splitting module Connect with the two-dimensional code decoding module and the decryption module respectively.
本发明与现有技术相比,具有如下优点和有益效果:Compared with the prior art, the present invention has the following advantages and beneficial effects:
1、本发明通过以染色区域数据作为二维码隐藏信息的密钥,使二维码的局部颜色和二维码的数据配对,实现对数据的监控、监管,本发明的编码方法、解码方法、编码装置及解码装置具有相同或相应的技术特征:以染色区域数据作为二维码隐藏信息的密钥进行加密或解密过程。本发明一方面可以通过局部彩色对二维码编码空间进行扩展,另一方面可以使用本发明的二维码读取设备读取隐藏在二维码中的信息,保证了二维码的完整性、安全性和保密性,并使二维码能携带隐藏信息,加强了二维码的防伪性和唯一性,开拓二维码作为数据标签外的新应用领域,使得二维码在流通过程的各个环节,都能查验到二维码的真伪,防范假冒现象。1. The present invention uses the data of the dyed area as the key of the hidden information of the two-dimensional code to pair the local color of the two-dimensional code with the data of the two-dimensional code, so as to realize the monitoring and supervision of the data. The encoding method and decoding method of the present invention The encoding device and the decoding device have the same or corresponding technical features: the encryption or decryption process is performed using the dyed area data as the key for the hidden information of the two-dimensional code. On the one hand, the present invention can expand the coding space of the two-dimensional code through partial color; on the other hand, the two-dimensional code reading device of the present invention can be used to read the information hidden in the two-dimensional code, which ensures the integrity of the two-dimensional code , security and confidentiality, and enable two-dimensional codes to carry hidden information, strengthen the anti-counterfeiting and uniqueness of two-dimensional codes, open up new application fields for two-dimensional codes as data labels, and make two-dimensional codes in the circulation process In every link, the authenticity of the QR code can be checked to prevent counterfeiting.
2、本发明可以广泛应用于需要标签辅助的商品流通、生产过程控制、管理过程控制等等各行各业,例如供应商把产品信息及防伪信息通过局部色彩叠加算法在普通黑白二维码基础上生成局部为彩色的二维码。在市场上,消费者通过通用的二维码读取程序,读取二维码中的产品信息;供应商通过专业读取设备,读取二维码中局部彩色的隐藏信息,达到数据溯源、销售监控等管理。2. The present invention can be widely used in various industries such as commodity circulation, production process control, and management process control that require label assistance. For example, suppliers use local color superposition algorithms to add product information and anti-counterfeiting information on the basis of ordinary black and white two-dimensional codes. Generate a partially colored QR code. In the market, consumers read the product information in the QR code through a general-purpose QR code reading program; suppliers use professional reading equipment to read the partially colored hidden information in the QR code to achieve data traceability, Sales monitoring and other management.
附图说明 Description of drawings
图1为本发明实施例1二维码编码装置的结构示意图。FIG. 1 is a schematic structural diagram of a two-dimensional code encoding device according to Embodiment 1 of the present invention.
图2为本发明实施例1二维码解码装置的结构示意图。FIG. 2 is a schematic structural diagram of a two-dimensional code decoding device according to Embodiment 1 of the present invention.
图3为本发明实施例1编码方法及解码方法在商品防窜货应用中的流程图。Fig. 3 is a flow chart of the encoding method and decoding method in embodiment 1 of the present invention in the application of commodity anti-channeling.
具体实施方式 Detailed ways
下面结合实施例及附图对本发明作进一步详细的描述,但本发明的实施方式不限于此。The present invention will be further described in detail below in conjunction with the embodiments and the accompanying drawings, but the embodiments of the present invention are not limited thereto.
实施例1Example 1
本实施例中基于局部颜色校验的二维码编码装置如图1所示,该装置包括染色区域数据生成装置、二维码生成装置和二维码彩色图像生成装置,所述二维码生成装置包括依次连接的加密模块、拼合模块和二维码编码模块。The two-dimensional code encoding device based on local color verification in this embodiment is shown in Figure 1, the device includes a dyeing area data generating device, a two-dimensional code generating device and a two-dimensional code color image generating device, the two-dimensional code generating device The device includes an encryption module, a splicing module and a two-dimensional code encoding module connected in sequence.
染色区域数据生成装置,用于在二维码模板中根据事先定义的染色区域编码解码表生成染色区域的相关数据(包括染色区域数量、颜色、形状等)。The dyeing area data generation device is used to generate the relevant data of the dyeing area (including the number, color, shape, etc.) of the dyeing area in the two-dimensional code template according to the pre-defined dyeing area encoding and decoding table.
加密模块,用于以染色区域数据为密钥对需加密的隐藏信息进行加密。The encryption module is used to encrypt the hidden information to be encrypted by using the dyed area data as a key.
拼合模块,用于对不经加密处理的明文信息和经加密处理的隐藏信息进行拼合,然后将拼合后的数据发送到二维码编码模块。The merging module is used to merging the unencrypted plaintext information and the encrypted hidden information, and then send the merging data to the two-dimensional code encoding module.
二维码编码模块用于将经加密的隐藏信息和未经加密的明文信息生成标准的二维码黑白图像。二维码编码模块可采用二维码PDF417、Datamatrix、Maxicode、QR Code、Code 49、Code 16K、Vericode、Ultracode的生成算法进行生成。The two-dimensional code encoding module is used to generate standard two-dimensional code black and white images from encrypted hidden information and unencrypted plaintext information. The two-dimensional code encoding module can be generated by the generation algorithm of two-dimensional code PDF417, Datamatrix, Maxicode, QR Code, Code 49, Code 16K, Vericode, and Ultracode.
二维码彩色图像生成装置,根据染色区域数据生成装置所得到的染色区域、数量和颜色对二维码生成装置生成的二维码黑白图像进行染色,得到局部染色的二维码彩色图像。The two-dimensional code color image generation device dyes the two-dimensional code black-and-white image generated by the two-dimensional code generation device according to the dyed area, quantity and color obtained by the dyed area data generation device, and obtains a partially dyed two-dimensional code color image.
本实施例中基于局部颜色校验的二维码解码装置如图2所示,包括二维码染色区域读取装置和二维码读取装置;所述二维码解码装置包括依次连接的读取模块、二维码解码模块、拆分模块和解密模块。In this embodiment, the two-dimensional code decoding device based on local color verification is shown in Figure 2, which includes a two-dimensional code dyeing area reading device and a two-dimensional code reading device; the two-dimensional code decoding device includes sequentially connected reading devices Extraction module, two-dimensional code decoding module, splitting module and decryption module.
二维码染色区域读取装置,用于根据事先定义的染色区域编码解码表读取二维码图像中染色区域数据;染色区域的数据包括染色区域数量、颜色、形状等。The two-dimensional code dyeing area reading device is used to read the dyeing area data in the two-dimensional code image according to the pre-defined dyeing area encoding and decoding table; the data of the dyeing area includes the number, color, shape, etc. of the dyeing area.
读取模块,用于读取二维码图像。The reading module is used to read the two-dimensional code image.
二维码解码模块,用于对读取模块读取到的二维码图像信息进行解码。The two-dimensional code decoding module is used to decode the two-dimensional code image information read by the reading module.
拆分模块,用于将二维码图像解码后的信息拆分成不经加密处理的明文信息和经加密处理的隐藏信息。The splitting module is configured to split the decoded information of the two-dimensional code image into unencrypted plaintext information and encrypted hidden information.
解密模块,用于以染色区域数据为密钥对拆分模块拆分后的经加密处理的隐藏信息进行解密。The decryption module is used to decrypt the encrypted hidden information split by the split module by using the dyed area data as a key.
图3为本实施例在商品防窜货应用中的示意图。如图所示,本实施例按照图3所示的编码方法完成编码过程后,生产厂商在产品及其包装上粘贴或打印局部彩色二维码,生产厂商、消费者和销售检查部门可根据需要按图所示的解码方法对条形码和二维码进行解码并输出结果。具体的,本实施例中采用的编码方法和解码方法如下。FIG. 3 is a schematic diagram of this embodiment in the application of commodity anti-channeling. As shown in the figure, after the present embodiment completes the coding process according to the coding method shown in Figure 3, the manufacturer pastes or prints a partial color two-dimensional code on the product and its packaging, and the manufacturer, consumer and sales inspection department can Decode the barcode and QR code according to the decoding method shown in the figure and output the result. Specifically, the encoding method and decoding method adopted in this embodiment are as follows.
本实施例中基于局部颜色校验的二维码编码方法,包括以下步骤:The two-dimensional code coding method based on local color verification in the present embodiment comprises the following steps:
(1)在二维码模板(矩形或正方形)上,根据事先定义的染色区域编码解码表,随机生成染色区域数据,染色区域数据包括染色区域数量、各染色区域的形状、各染色区域的颜色。事先定义的染色区域编码解码表是指事先根据染色区域可能出现的形状和颜色分别建立的编码解码表,在形状编码解码表中,定义每一种形状对应一个数值,同样在颜色编码解码表中,定义每一种颜色对应一个数值,然后连同染色区域数量,建立<染色区域数量i,各染色区域形状S,各染色区域颜色C>的密钥向量。(1) On the QR code template (rectangular or square), according to the pre-defined dyeing area coding and decoding table, the dyeing area data is randomly generated. The dyeing area data includes the number of dyed areas, the shape of each dyed area, and the color of each dyed area . The pre-defined color coding and decoding table refers to the coding and decoding table established in advance according to the possible shapes and colors of the coloring area. In the shape coding and decoding table, it is defined that each shape corresponds to a value. Also in the color coding and decoding table , define that each color corresponds to a numerical value, and then together with the number of dyed regions, establish the key vector of <the number of dyed regions i, the shape S of each dyed region, and the color C of each dyed region>.
(2)二维码原始信息包括需加密的隐藏信息M1和不需加密的明文信息M2;使用双向加密算法将隐藏信息M1以染色区域数据向量<i,S,C>作为密钥进行加密,得到加密后的隐藏信息M1′=F(M1,<i,S,C>);将M1′和M2通过拼合算法拼合,得到二维码生成信息M=P(M1′,M2)。一种简单的拼接方式是使用分隔符w进行拼接,二维码信息M=M1+w+M2,密文信息紧跟明文信息后,以此思路可以由二维码生成方进行明文和密文的简单字符串拼接工作。另一种简单拼接方式是插入拼接,二维码信息M=M11+M21+M12+M22……,按照固定的插入位置把隐藏信息插入到明文信息里面,以此思路也可以由二维码生成方进行明文和密文的字符串拼接。(2) The original information of the two-dimensional code includes the hidden information M 1 that needs to be encrypted and the plaintext information M 2 that does not need to be encrypted; use the two-way encryption algorithm to use the hidden information M 1 with the dyed area data vector <i, S, C> as the key Encrypt to obtain the encrypted hidden information M 1 ′=F(M 1 ,<i,S,C>); combine M 1 ′ and M 2 through the combination algorithm to obtain the two-dimensional code generation information M=P(M 1 ', M 2 ). A simple splicing method is to use the separator w for splicing. The two-dimensional code information M=M 1 +w+M 2 , and the ciphertext information follows the plaintext information. In this way, the plaintext and Simple string concatenation of ciphertexts works. Another simple splicing method is insertion splicing. The two-dimensional code information M=M 11 +M 21 +M 12 +M 22 ... inserts the hidden information into the plaintext information according to the fixed insertion position. This idea can also be obtained by The two-dimensional code generator performs string concatenation of plaintext and ciphertext.
(3)将步骤(2)得到的二维码生成信息通过标准的二维码生成算法(例如二维码PDF417、Datamatrix、Maxicode、QR Code、Code 49、Code 16K、Vericode、Ultracode生成算法),生成标准的二维码黑白图像。(3) Pass the QR code generation information obtained in step (2) through standard QR code generation algorithms (such as QR code PDF417, Datamatrix, Maxicode, QR Code, Code 49, Code 16K, Vericode, Ultracode generation algorithms), Generate a standard black and white image of a QR code.
(4)根据步骤(1)所制定的二维码模板和生成的染色区域数据对步骤(3)得到的二维码黑白图像进行染色,最终得到局部彩色二维码图像。(4) Dye the black-and-white image of the two-dimensional code obtained in step (3) according to the two-dimensional code template formulated in step (1) and the generated dyed area data, and finally obtain a partial color two-dimensional code image.
本实施例中基于局部颜色校验的二维码解码方法,包括以下步骤:In this embodiment, the two-dimensional code decoding method based on local color verification includes the following steps:
(1)根据事先定义的染色区域编码解码表,读取二维码图像上的染色区域数据,染色区域数据包括染色区域数量i,、各染色区域的形状S,、各染色区域的颜色C,获得染色区域数据向量<i,S,C>。(1) Read the dyed area data on the two-dimensional code image according to the pre-defined dyed area encoding and decoding table. The dyed area data includes the number of dyed areas i, the shape S of each dyed area, and the color C of each dyed area. Get the stained area data vector <i,S,C>.
(2)读取二维码图像,把局部染色的二维码图像中的有颜色区域作为黑色区域,然后将二维码图像当作标准黑白二维码图像,使用标准二维码解码算法进行解码得到信息M。(2) Read the two-dimensional code image, take the colored area in the partially dyed two-dimensional code image as the black area, and then treat the two-dimensional code image as a standard black and white two-dimensional code image, and use the standard two-dimensional code decoding algorithm Decode to get information M.
(3)通过拆分算法<M1′,M2>=P-1(M)得到经加密处理的隐藏信息M1′和未经加密的明文信息M2;再通过解密算法对M1′以染色区域数据向量<i,S,C>作为密钥进行解密,得到加密前的隐藏信息M1,将原始信息M1和M2输出。(3) Obtain the encrypted hidden information M 1 ′ and the unencrypted plaintext information M 2 through the split algorithm <M 1 ′, M 2 >=P -1 (M); and then decrypt M 1 ′ through the decryption algorithm Use the dyed area data vector <i, S, C> as the key to decrypt, get the hidden information M 1 before encryption, and output the original information M 1 and M 2 .
其中二维码可以包括如下信息:隐藏信息包括防伪信息、密码信息和识别信息;可以为产品供应商信息、产品分销商信息、产品原产地信息、产品重量、出厂时间信息、产品有效期、产品批号和产品总数量信息;证件、票据的发售点信息、有效期、使用单位或个人信息、金额、发出单位、接收单位、发出时间、规格、往返地的信息;证件有效期、审核单位信息、证件所属人或单位信息等。明文信息可以为产品序列号、产品基本信息、产品基本介绍、产品供应商信息、产品分销商信息、产品原产地信息、产品重量、出厂时间信息、产品有效期、产品批号和产品总数量信息;证件、票据的发售点信息、有效期、使用单位或个人信息、金额、发出单位、接收单位、发出时间、规格、往返地信息;证件有效期、审核单位信息、证件所属人或单位信息;或特定的密码加密/解码所采用的密钥信息等。Among them, the two-dimensional code can include the following information: hidden information includes anti-counterfeiting information, password information and identification information; it can be product supplier information, product distributor information, product origin information, product weight, delivery time information, product expiration date, product batch number and the total quantity information of the products; information on the point of sale of certificates and bills, validity period, user or personal information, amount, issuing unit, receiving unit, issuing time, specifications, information on the place to and from; valid period of the certificate, information on the reviewing unit, and the owner of the certificate or unit information, etc. Plaintext information can be product serial number, basic product information, basic product introduction, product supplier information, product distributor information, product origin information, product weight, delivery time information, product validity period, product batch number and total product quantity information; , information on the point of sale, validity period, user or personal information, amount, issuing unit, receiving unit, issuing time, specifications, and destination information of the bill; validity period of the certificate, information on the reviewing unit, information on the person or unit of the certificate; or a specific password Key information used for encryption/decryption, etc.
在实际应用中,消费者可通过手机、PDA、电脑摄像头等,读取条形码中的产品序号和二维码的明文信息。In practical applications, consumers can read the product serial number in the barcode and the plaintext information of the QR code through mobile phones, PDAs, computer cameras, etc.
销售检查部门可使用本实施例的二维码读取装置,读取二维码的明文信息、以染色区域数据为密钥读取二维码的隐藏信息;可检查产品包装与产品是否相符,是否被拆封销售;进行产品销售防窜货管理;进行产品真伪鉴别。The sales inspection department can use the two-dimensional code reading device of this embodiment to read the plaintext information of the two-dimensional code, and read the hidden information of the two-dimensional code with the dyed area data as a key; it can check whether the product packaging is consistent with the product, Whether it is unpacked and sold; conduct product sales anti-smuggling management; conduct product authenticity identification.
另外,本实施例所述编码解码装置和方法还可应用在税务发票上,在按本实施例所述的编码方法完成编码过程后,发票打印单位在发票上打印二维码;消费者和相关检查部门可根据需要按本实施例所述的解码方法对条形码和二维码进行解码并输出结果。In addition, the encoding and decoding device and method described in this embodiment can also be applied to tax invoices. After the encoding process is completed according to the encoding method described in this embodiment, the invoice printing unit prints a two-dimensional code on the invoice; consumers and related The inspection department can decode the barcode and the two-dimensional code according to the decoding method described in this embodiment and output the result as needed.
其中二维码的内容包括明文信息:发票开具单位、商品明细、金额、纳税人编号、开票日期等,还包括隐藏信息:税务机关识别号、明文信息校验等。The content of the QR code includes plain text information: invoice issuing unit, commodity details, amount, taxpayer number, invoice date, etc., as well as hidden information: tax authority identification number, plain text information verification, etc.
消费者可通过手机、PDA、电脑摄像头等读取发票序号和二维码的明文信息。Consumers can read the invoice serial number and the plaintext information of the QR code through mobile phones, PDAs, computer cameras, etc.
相关检查部门可通过本实施例所述的二维码读取装置,读取二维码的隐藏信息和明文信息。Relevant inspection departments can read the hidden information and plaintext information of the two-dimensional code through the two-dimensional code reading device described in this embodiment.
因此,本发明可以广泛应用于需要标签辅助的商品流通、生产过程控制、管理过程控制等等各行各业,例如供应商把产品信息及防伪信息通过局部色彩叠加算法在普通黑白二维码基础上生成局部为彩色的二维码。在市场上,消费者通过通用的二维码读取程序,读取二维码中的产品信息;供应商通过专业读取设备,读取二维码中局部彩色的隐藏信息,达到数据溯源、销售监控等管理。Therefore, the present invention can be widely used in various industries such as commodity circulation, production process control, and management process control that require label assistance. Generate a partially colored QR code. In the market, consumers read the product information in the QR code through a general-purpose QR code reading program; suppliers use professional reading equipment to read the partially colored hidden information in the QR code to achieve data traceability, Sales monitoring and other management.
上述实施例为本发明较佳的实施方式,但本发明的实施方式并不受上述实施例的限制,其他的任何未背离本发明的精神实质与原理下所作的改变、修饰、替代、组合、简化,均应为等效的置换方式,都包含在本发明的保护范围之内。The above-mentioned embodiment is a preferred embodiment of the present invention, but the embodiment of the present invention is not limited by the above-mentioned embodiment, and any other changes, modifications, substitutions, combinations, Simplifications should be equivalent replacement methods, and all are included in the protection scope of the present invention.
Claims (6)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210311536.6A CN102916804B (en) | 2012-08-28 | 2012-08-28 | Two-dimension code coding and decoding method and device based on local color verification |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210311536.6A CN102916804B (en) | 2012-08-28 | 2012-08-28 | Two-dimension code coding and decoding method and device based on local color verification |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102916804A CN102916804A (en) | 2013-02-06 |
CN102916804B true CN102916804B (en) | 2015-05-20 |
Family
ID=47615046
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210311536.6A Active CN102916804B (en) | 2012-08-28 | 2012-08-28 | Two-dimension code coding and decoding method and device based on local color verification |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102916804B (en) |
Families Citing this family (24)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103310258B (en) * | 2013-06-09 | 2016-02-17 | 江苏科技大学 | A kind of self-adaptation expansion black and white code encoding method |
CN103489026B (en) * | 2013-09-24 | 2017-02-15 | 深圳市中选科技有限公司 | Colorful two-dimension code, generating method and generating system thereof and printed article |
CN103745252B (en) * | 2013-12-27 | 2017-04-05 | 广州市宝比万像科技有限公司 | Coding row, two-dimentional code encoding method and Quick Response Code coding/decoding method |
CN104239927B (en) * | 2014-08-01 | 2017-02-15 | 周奇 | Colored two-dimension code generating method and decoding method |
CN104392260A (en) * | 2014-12-17 | 2015-03-04 | 肖学静 | Two-dimensional code anti-counterfeiting method based on additional information |
CN104636784A (en) * | 2015-02-28 | 2015-05-20 | 立德高科(北京)数码科技有限责任公司 | Two-dimensional code, and generation method and identification method thereof |
CN104636785B (en) * | 2015-02-28 | 2018-08-07 | 北京慧眼食珍科技有限公司 | Quick Response Code, generation method with Quick Response Code software installation information and recognition methods |
CN105046306A (en) * | 2015-05-05 | 2015-11-11 | 华中科技大学 | Method for encoding color multi-dimensional codes containing information of variety of biological characteristics |
CN105117757B (en) * | 2015-08-26 | 2018-07-06 | 复旦大学无锡研究院 | A kind of Quick Response Code encryption and decryption approaches based on random grain |
CN105069498B (en) * | 2015-09-09 | 2017-10-17 | 杭州甄别网络科技有限公司 | The colour-enciphered method and device of Quick Response Code |
CN106529633B (en) | 2015-09-10 | 2019-11-15 | 阿里巴巴集团控股有限公司 | Generation method, coding/decoding method and the device of two dimensional code |
JP2017091140A (en) * | 2015-11-09 | 2017-05-25 | 三星電子株式会社Samsung Electronics Co.,Ltd. | Code transmission/reception system, code receiver, code transmitter, code reception method, code transmission method, and program |
CN105825257B (en) * | 2016-03-09 | 2018-05-29 | 东北大学 | Information hiding and hiding information extracting method and system based on two-dimensional bar code |
CN105976004B (en) * | 2016-04-25 | 2019-05-07 | 华南农业大学 | A color two-dimensional code multi-dimensional information encoding and decoding method and device |
CN106330976B (en) * | 2016-11-03 | 2020-01-03 | 武汉斗鱼网络科技有限公司 | Information encryption and decryption method and device |
KR20180113028A (en) * | 2017-04-05 | 2018-10-15 | 주식회사 멀티코시 | Anti-forgery qrcode and image conversion method thereof |
CN107423793A (en) * | 2017-04-28 | 2017-12-01 | 南京邮电大学 | A kind of Quick Response Code generation identification technology of new type of safe |
CN109756459B (en) * | 2017-11-06 | 2022-03-29 | 阿里巴巴集团控股有限公司 | Data processing method, data identification method, data processing device, data identification device, and data processing medium |
CN108268178B (en) * | 2018-02-27 | 2021-07-13 | Tcl移动通信科技(宁波)有限公司 | Mobile terminal touch screen coordinate output control, mobile terminal and storage medium |
CN108921266B (en) * | 2018-09-29 | 2021-01-22 | 长安大学 | Static two-dimensional code encryption display method and device based on image segmentation |
CN109784454A (en) * | 2019-01-16 | 2019-05-21 | 王诗会 | A kind of information concealing method based on two dimensional code, device and electronic equipment |
CN110705997A (en) * | 2019-08-28 | 2020-01-17 | 江苏南大数码科技有限公司 | Anti-counterfeiting coding method compatible with heterogeneous system |
CN111428531A (en) * | 2020-03-13 | 2020-07-17 | 郑州大学 | Art QR code recognition method and device, electronic equipment and storage medium |
CN112949800B (en) * | 2021-01-27 | 2024-02-06 | 中国银联股份有限公司 | Method, device and storage medium for generating, playing and processing graphic code video |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009003770A (en) * | 2007-06-22 | 2009-01-08 | Nikon Corp | Color two-dimensional code reader, its method of reading, and electronic camera |
CN102184380A (en) * | 2011-05-10 | 2011-09-14 | 华南农业大学 | Color-superposition two-dimension code system and application method thereof |
CN102270294A (en) * | 2011-08-12 | 2011-12-07 | 华南农业大学 | Bar code and two-dimension code hybrid coding and decoding methods and devices |
KR20120040773A (en) * | 2010-10-20 | 2012-04-30 | 김장익 | Encryption and decoding method of two dimensional code pattern, distribution management method, and readign equipment by using the same |
-
2012
- 2012-08-28 CN CN201210311536.6A patent/CN102916804B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2009003770A (en) * | 2007-06-22 | 2009-01-08 | Nikon Corp | Color two-dimensional code reader, its method of reading, and electronic camera |
KR20120040773A (en) * | 2010-10-20 | 2012-04-30 | 김장익 | Encryption and decoding method of two dimensional code pattern, distribution management method, and readign equipment by using the same |
CN102184380A (en) * | 2011-05-10 | 2011-09-14 | 华南农业大学 | Color-superposition two-dimension code system and application method thereof |
CN102270294A (en) * | 2011-08-12 | 2011-12-07 | 华南农业大学 | Bar code and two-dimension code hybrid coding and decoding methods and devices |
Non-Patent Citations (1)
Title |
---|
基于移动终端彩色二维条码编解码算法研究与应用;贾华国;《中国优秀硕士学位论文全文数据库 信息科技辑》;20111215(第S1期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN102916804A (en) | 2013-02-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102916804B (en) | Two-dimension code coding and decoding method and device based on local color verification | |
CN102902997B (en) | A kind of Quick Response Code hybrid coding, decoding device and method | |
CN102184380B (en) | Color-superposition two-dimension code system and application method thereof | |
CN102270294A (en) | Bar code and two-dimension code hybrid coding and decoding methods and devices | |
CN102930317B (en) | Books Quick Response Code identification generation apparatus, Quick Response Code identification recognition device and system | |
CN103198344B (en) | Tax control secure two-dimensional code coding, decoding processing method | |
US8578162B2 (en) | Unique identifier, method for providing the unique identifier and use of the unique identifier | |
CN103020682B (en) | Books Quick Response Code identification generation apparatus, Quick Response Code identification recognition device and system | |
CN104766113B (en) | A kind of light and shade code anti-fake label and its method for anti-counterfeit | |
WO2017045594A1 (en) | Anti-counterfeit method | |
CN105976005A (en) | Two-dimensional code encrypting method, two-dimensional code generating device and two-dimensional code scanning device | |
CN104268610B (en) | A hierarchical QR code generation method and reading method | |
WO2008086715A1 (en) | Sanhe code for identifying merchandises | |
CN103034884A (en) | Commodity packaging anti-fake device and device and system for anti-fake recognition with built-in secret key | |
CN103049777A (en) | Security application method for two-dimension code and encoding/decoding system | |
CN107992923A (en) | A kind of QR Quick Response Codes generation and the method read | |
EP2910042B1 (en) | Secure information transfer via bar codes | |
CN111242259A (en) | Intelligent anti-counterfeiting code encoding and decoding method and system | |
CN104112205A (en) | Commodity authentication and source tracing system and method based on combined public-key cryptosystem | |
CN106022187A (en) | High-efficient O2O implementation method | |
CN104899748A (en) | Two-dimensional code and scratch-off code composite identifying method based on identity authentication technology | |
CN104574119A (en) | Commodity identifying and tracing method | |
CN102842053B (en) | A kind of false proof figure code label and manufacture method thereof | |
US7916863B2 (en) | Security printing method and system for enhancing security printing | |
CN106022797A (en) | Smart device APP image recognition method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |