CN113159252A - Commodity anti-counterfeiting two-dimensional code generation method based on different scrambling rules - Google Patents
Commodity anti-counterfeiting two-dimensional code generation method based on different scrambling rules Download PDFInfo
- Publication number
- CN113159252A CN113159252A CN202110378301.8A CN202110378301A CN113159252A CN 113159252 A CN113159252 A CN 113159252A CN 202110378301 A CN202110378301 A CN 202110378301A CN 113159252 A CN113159252 A CN 113159252A
- Authority
- CN
- China
- Prior art keywords
- scrambling
- sequence
- chaotic sequence
- row
- rules
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 32
- 230000000739 chaotic effect Effects 0.000 claims abstract description 218
- 239000011159 matrix material Substances 0.000 claims abstract description 178
- 230000001174 ascending effect Effects 0.000 claims abstract description 27
- 238000000605 extraction Methods 0.000 claims abstract description 13
- 238000006243 chemical reaction Methods 0.000 claims abstract description 7
- 238000005516 engineering process Methods 0.000 description 15
- 238000004519 manufacturing process Methods 0.000 description 12
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000011161 development Methods 0.000 description 2
- 230000035945 sensitivity Effects 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000012512 characterization method Methods 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000009792 diffusion process Methods 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 230000001788 irregular Effects 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06K—GRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
- G06K19/00—Record carriers for use with machines and with at least a part designed to carry digital markings
- G06K19/06—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
- G06K19/06009—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
- G06K19/06037—Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Bakery Products And Manufacturing Methods Therefor (AREA)
Abstract
Description
技术领域technical field
本发明涉及数码防伪技术领域,特别涉及一种基于不同置乱规则的商品防伪二维码生成方法。The invention relates to the technical field of digital anti-counterfeiting, in particular to a method for generating anti-counterfeiting two-dimensional codes for commodities based on different scrambling rules.
背景技术Background technique
数码防伪技术是基于日益猖獗的假冒伪劣产品所应运而生的,现代的数码防伪是一种综合利用数字编码技术、加密技术、数据库技术、计算机网络,交互式语音处理(IRV)等技术的新型高科技防伪技术。由于传统防伪技术的种种缺点,综观其数码防伪技术的发展过程,并根据防伪码生成方式的不同数码防伪技术主要经历了随机条码防伪模型、加密有序流水号防伪模型以及综合防伪模型三个阶段。在各方人士的不懈努力之下,数码防伪技术已经成为了防伪行业中运用最为广泛的技术之一,在产品防伪领域起着举足轻重的作用。Digital anti-counterfeiting technology came into being based on the increasingly rampant counterfeit and shoddy products. Modern digital anti-counterfeiting is a new type of technology that comprehensively utilizes digital coding technology, encryption technology, database technology, computer network, interactive voice processing (IRV) and other technologies. High-tech anti-counterfeiting technology. Due to various shortcomings of traditional anti-counterfeiting technology, looking at the development process of its digital anti-counterfeiting technology, and according to the different methods of anti-counterfeiting code generation, digital anti-counterfeiting technology has mainly experienced three stages: random barcode anti-counterfeiting model, encrypted and ordered serial number anti-counterfeiting model and comprehensive anti-counterfeiting model. . With the unremitting efforts of all parties, digital anti-counterfeiting technology has become one of the most widely used technologies in the anti-counterfeiting industry, and plays a pivotal role in the field of product anti-counterfeiting.
随着社会不断进步,市场日益发展。对于企业来说,数码防伪能保持品牌好的口碑。同时,“一物一码”的防伪方式,大大增加了造假者的造假成本,可以记录产品的定位信息,统计产品查询次数和查询方式,根据企业要求设置查询警戒线。目前智能终端已成为人们日常生活中重要的组成部分,而数码防伪技术也逐渐融入互联网,用户通过智能终端扫描商品防伪二维码进行“一键式”真伪查询,互联网的发展和普及为数码防伪系统的落地奠定了良好的基础。With the continuous progress of society, the market is developing day by day. For enterprises, digital anti-counterfeiting can maintain a good brand reputation. At the same time, the anti-counterfeiting method of "one item, one code" greatly increases the cost of counterfeiting for counterfeiters. It can record the positioning information of products, count the number of product inquiries and inquiries, and set up inquiries warning lines according to enterprise requirements. At present, smart terminals have become an important part of people's daily life, and digital anti-counterfeiting technology has gradually been integrated into the Internet. Users scan the anti-counterfeiting QR code of goods through smart terminals to conduct "one-click" authenticity checks. The development and popularization of the Internet has become a digital The implementation of the anti-counterfeiting system has laid a good foundation.
数码防伪中最根本的部分就是利用加密算法生成商品防伪码,其中加密算法的选择就变得尤为重要。由于混沌系统具有高随机性和参数敏感性,产生的混沌信号对加密信号的扩散性和置乱性有很大的影响,混沌信号作为一种天然的密码而被引入数码防伪的加密中,用混沌密码技术进行商品信息的加密是一个很好的选择。在此情况下,利用混沌密码技术,提出一种基于不同置乱规则的商品防伪二维码生成方法,以生成具有“唯一性和不可伪造性”的商品防伪二维码,具有很好的实际应用推广价值。The most fundamental part of digital anti-counterfeiting is to use encryption algorithm to generate commodity anti-counterfeiting code, in which the choice of encryption algorithm becomes particularly important. Due to the high randomness and parameter sensitivity of the chaotic system, the generated chaotic signal has a great influence on the diffusion and scrambling of the encrypted signal. As a natural password, the chaotic signal is introduced into the encryption of digital anti-counterfeiting. The chaotic encryption technology is a good choice for the encryption of commodity information. In this case, using chaotic cryptography technology, a method for generating anti-counterfeiting two-dimensional codes for commodities based on different scrambling rules is proposed to generate anti-counterfeiting two-dimensional codes for commodities with "uniqueness and unforgeability", which has a good practical App promotion value.
发明内容SUMMARY OF THE INVENTION
发明目的:本发明的目的是为了解决现有技术中的不足,提供一种基于不同置乱规则的商品防伪二维码生成方法,利用混沌映射迭代并抽取产生的混沌序列,按照不同置乱规则对商品标识码转换而成的组合分别按行、列进行置乱,并将行列置乱后二进制矩阵中每列元素转换而成的数值型数据依次填入表征灰度图片的矩阵中,生成一幅灰度图像,进而组合生成商品防伪二维码,以此保证所提基于不同置乱规则的商品防伪二维码生成方法简单可行,具有很强的安全性、不易破解,生成的商品防伪二维码具有“唯一性和不可伪造性”。Purpose of the invention: The purpose of the present invention is to solve the deficiencies in the prior art, and provide a method for generating anti-counterfeiting two-dimensional codes based on different scrambling rules. The combination converted from the commodity identification code is scrambled by row and column, and the numerical data converted from the elements of each column in the binary matrix after the row and column are scrambled are filled in the matrix representing the grayscale image in turn to generate a grayscale images, and then combined to generate a product anti-counterfeiting two-dimensional code, so as to ensure that the proposed product anti-counterfeiting two-dimensional code generation method based on different scrambling rules is simple and feasible, has strong security, and is not easy to crack. The generated product anti-counterfeiting two-dimensional code Dimension codes are "unique and unforgeable".
技术方案:一种基于不同置乱规则的商品防伪二维码生成方法,其特征在于,包括如下几个步骤:Technical solution: a method for generating anti-counterfeiting two-dimensional codes for commodities based on different scrambling rules, characterized in that it includes the following steps:
(1)转码(1) Transcoding
首先,将表征某件商品唯一身份信息的商品标识码A,逐个字符转换为数值型数据,得到数值序列 First, convert the product identification code A, which represents the unique identity information of a certain product, into numerical data character by character to obtain a numerical sequence
然后,依次将数值序列P中元素Pi逐个转换成8bits的二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8},并将个二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8}从左往右逐列填入矩阵B中,其中矩阵某行对应于各二进制序列的某位,从而得到组合二进制矩阵B,Then, convert the elements P i in the numerical sequence P into 8-bit binary sequences {PB i1 , PB i2 , PB i3 , PB i4 , PB i5 , PB i6 , PB i7 , PB i8 } one by one, and convert A binary sequence {PB i1 , PB i2 , PB i3 , PB i4 , PB i5 , PB i6 , PB i7 , PB i8 } is filled into matrix B column by column from left to right, where A row of the matrix corresponds to a bit of each binary sequence, so as to obtain the combined binary matrix B,
其中商品标识码A为GBK编码的字符,商品标识码A的长度表示为数值序列P的长度为组合二进制矩阵B的大小为且 The commodity identification code A is a character encoded by GBK, and the length of the commodity identification code A is expressed as The length of the numerical sequence P is The size of the combined binary matrix B is and
(2)混沌序列的产生(2) Generation of chaotic sequences
首先,利用数值序列P及其转换的组合二进制矩阵B,以及外部密钥α和β,按照如下公式(1)-(3)分别计算得到Bernoulli混沌映射的初值x1和参数λ以及初次抽取位置n,First, using the numerical sequence P and its converted combined binary matrix B, as well as the external keys α and β, according to the following formulas (1)-(3), the initial value x 1 and parameter λ of the Bernoulli chaotic map and the initial extraction are calculated respectively. position n,
令则make but
x1=0.02+mod(α+kp,0.98), (1)x 1 =0.02+mod(α+kp,0.98), (1)
λ=0.01+mod(β+kp,0.99), (2)λ=0.01+mod(β+kp,0.99), (2)
其中,<B>表示组合二进制矩阵B中含有二进制位‘0’的个数,外部密钥满足α∈(0,1),β∈(0,1),表示对某数取整且取整后的值不大于该数,Among them, <B> represents the number of binary bits '0' in the combined binary matrix B, and the external key satisfies α∈(0,1), β∈(0,1), Indicates that a number is rounded and the rounded value is not greater than the number,
然后,由混沌映射的初值x1和参数λ,对如下公式(4)所示Bernoulli混沌映射进行迭代,式中k表示迭代次数(k=1,2,...)、xk+1表示第k次迭代得到的混沌信号,Then, based on the initial value x 1 of the chaotic map and the parameter λ, the Bernoulli chaotic map shown in the following formula (4) is iterated, where k represents the number of iterations (k=1, 2,...), x k+1 represents the chaotic signal obtained at the kth iteration,
得到混沌序列X={x1,x2,...},Get the chaotic sequence X={x 1 , x 2 ,...},
最后,对混沌序列X={x1,x2,...}进行如下操作:Finally, perform the following operations on the chaotic sequence X={x 1 , x 2 ,...}:
S10.令混沌序列Y为空序列,且i=1,S10. Let the chaotic sequence Y be an empty sequence, and i=1,
S11.从混沌序列X中抽取第n个元素,并放入混沌序列Y中,即Y=[Y,xn],S11. Extract the nth element from the chaotic sequence X and put it into the chaotic sequence Y, that is, Y=[Y, x n ],
S12.比较i与的大小,若则对抽取位置n按照如下公式(5)进行调整,且令i=i+1,随后转向步骤S11,S12. Compare i with size, if Then adjust the extraction position n according to the following formula (5), and let i=i+1, then turn to step S11,
若则停止操作,从而得到混沌序列 like Then stop the operation, so as to get the chaotic sequence
(3)组合二进制矩阵B的置乱(3) Scrambling of the combined binary matrix B
首先,从混沌序列中第1个元素开始连续抽取8个元素,得到混沌序列Y1={Y11,Y12,...,Y17,Y18}={Y1,Y2,...,Y7,Y8},同时从混沌序列中第9个元素开始连续抽取个元素,得到混沌序列 First, from the chaotic sequence The first element in the 1st element starts to extract 8 elements continuously, and obtains the chaotic sequence Y1={Y1 1 ,Y1 2 ,...,Y1 7 ,Y1 8 }={Y 1 ,Y 2 ,...,Y 7 ,Y 8 }, while the chaotic sequence The 9th element in the start of continuous extraction elements, get a chaotic sequence
然后,按照如下公式(6)计算得到参数rule_select,根据rule_select选择不同的置乱规则,Then, the parameter rule_select is calculated according to the following formula (6), and different scrambling rules are selected according to rule_select,
当rule_select=0时,则将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵按列进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为 When rule_select=0, the chaotic sequence Y1 is sorted in descending order, and the combined binary matrix B is scrambled row by row according to the scrambling rules before and after the chaotic sequence Y1 is sorted to obtain the row-scrambling binary matrix The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 }, and then the chaotic sequence Y2 is sorted in descending order, according to the chaotic sequence Y2 before sorting , after the position change scrambling rules, the binary matrix after row scrambling Scramble by column to get a binary matrix after row and column scramble Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
当rule_select=1时,则将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵按列进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为 When rule_select=1, the chaotic sequence Y1 is sorted in descending order, and the combined binary matrix B is scrambled by row according to the scrambling rules before and after the chaotic sequence Y1 is sorted to obtain the row-scrambled binary matrix The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 }, and then the chaotic sequence Y2 is sorted in ascending order, according to the chaotic sequence Y2 before sorting , after the position change scrambling rules, the binary matrix after row scrambling Scramble by column to get a binary matrix after row and column scramble Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
当rule_select=2时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵按列进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为 When rule_select=2, sort the chaotic sequence Y1 in ascending order, and scramble the combined binary matrix B by row according to the scrambling rules of the position change before and after the chaotic sequence Y1 is sorted to obtain the row-scrambled binary matrix The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 }, and then the chaotic sequence Y2 is sorted in descending order, according to the chaotic sequence Y2 before sorting , after the position change scrambling rules, the binary matrix after row scrambling Scramble by column to get a binary matrix after row and column scramble Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
当rule_select=3时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵按列进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为 When rule_select=3, the chaotic sequence Y1 is sorted in ascending order, and the combined binary matrix B is scrambled row by row according to the scrambling rules before and after the chaotic sequence Y1 is sorted to obtain the row-scrambling binary matrix The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 }, and then the chaotic sequence Y2 is sorted in ascending order, according to the chaotic sequence Y2 before sorting , after the position change scrambling rules, the binary matrix after row scrambling Scramble by column to get a binary matrix after row and column scramble Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
当rule_select=4时,则将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为再将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵按行进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},When rule_select=4, the chaotic sequence Y2 is sorted in descending order, and the combined binary matrix B is scrambled by column according to the scrambling rules of the position change before and after the chaotic sequence Y2 is sorted to obtain a column-scrambled binary matrix Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as Then sort the chaotic sequence Y1 in descending order, scrambling the rules according to the position change before and after the sorting of the chaotic sequence Y1, and scramble the binary matrix of the column. Scramble by row to get a binary matrix after row and column scrambling The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 },
当rule_select=5时,则将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为再将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵按行进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},When rule_select=5, the chaotic sequence Y2 is sorted in descending order, and the combined binary matrix B is scrambled by column according to the scrambling rules of the position change before and after the chaotic sequence Y2 is sorted to obtain the column-scrambled binary matrix Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as Then sort the chaotic sequence Y1 in ascending order, scrambling the rules according to the position change before and after the sorting of the chaotic sequence Y1, and scramble the binary matrix of the column. Scramble by row to get a binary matrix after row and column scrambling The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 },
当rule_select=6时,则将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为再将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵按行进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},When rule_select=6, the chaotic sequence Y2 is sorted in ascending order, and the combined binary matrix B is scrambled by column according to the scrambling rules of the position change before and after the chaotic sequence Y2 is sorted to obtain the column-scrambled binary matrix Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as Then sort the chaotic sequence Y1 in descending order, scrambling the rules according to the position change before and after the sorting of the chaotic sequence Y1, and scramble the binary matrix of the column. Scramble by row to get a binary matrix after row and column scrambling The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 },
当rule_select=7时,则将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为再将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵按行进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},When rule_select=7, the chaotic sequence Y2 is sorted in ascending order, and the combined binary matrix B is scrambled by column according to the scrambling rules of the position change before and after the chaotic sequence Y2 is sorted to obtain a column-scrambled binary matrix Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as Then sort the chaotic sequence Y1 in ascending order, scrambling the rules according to the position change before and after the sorting of the chaotic sequence Y1, and scramble the binary matrix of the column. Scramble by row to get a binary matrix after row and column scrambling The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 },
最后,依次将行列置乱后的二进制矩阵的每列元素转换成数值型数据其中表示为从而得到数值序列 Finally, the binary matrix after scrambling the rows and columns in turn elements of each column of Convert to numeric data in Expressed as to get the sequence of numbers
(4)二维码的生成(4) Generation of QR code
其中,表示对某数取整且取整后的值不小于该数,in, Indicates that a number is rounded and the rounded value is not less than the number,
然后,按照自定义的矩阵数据填放规则,将数值序列中元素依次填放入表征灰度图片的矩阵M中,从而生成灰度图片C,其中矩阵M的大小为H×L,灰度图片C的大小为30H×30L,Then, according to the custom matrix data filling rules, the numerical sequence is The elements in the middle are filled in the matrix M representing the grayscale picture in turn, thereby generating the grayscale picture C, where the size of the matrix M is H×L, and the size of the grayscale picture C is 30H×30L,
最后,将商品标识码A和生成的灰度图片C进行组合,并利用二维码生成器将组合的商品标识码和灰度图片转换为二维码,从而得到商品防伪二维码。Finally, combine the product identification code A and the generated grayscale image C, and use a two-dimensional code generator to convert the combined product identification code and grayscale image into a two-dimensional code, thereby obtaining a product anti-counterfeiting two-dimensional code.
进一步地,一种基于不同置乱规则的商品防伪二维码生成方法里步骤(1)中所述的将表征某件商品唯一身份信息的商品标识码A,逐个字符转换为数值型数据,是指将商品标识码A中逐个字符采用unicode2native(·)函数转换为数值型数据,即对于双字节字符的转换表示为对于单字节字符的转换表示为从而得到数值序列 Further, in a method for generating a product anti-counterfeiting two-dimensional code based on different scrambling rules, the product identification code A representing the unique identity information of a certain product described in step (1) is converted into numerical data character by character, which is Refers to converting each character in the product identification code A into numerical data using the unicode2native(·) function, that is, the conversion of double-byte characters is expressed as The conversion for single-byte characters is expressed as to get the sequence of numbers
进一步地,一种基于不同置乱规则的商品防伪二维码生成方法里步骤(1)中所述的依次将数值序列P中元素Pi逐个转换成8bits的二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8},是指采用dec 2 bin(Pi,8)函数,即[PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8]=dec 2 bin(Pi,8)。Further, in a method for generating anti-counterfeiting two-dimensional codes for commodities based on different scrambling rules, as described in step (1), the elements P i in the numerical sequence P are converted one by one into a binary sequence of 8 bits {PB i1 , PB i2 , PB i3 ,PB i4 ,PB i5 ,PB i6 ,PB i7 ,PB i8 }, refers to the use of dec 2 bin(P i ,8) function, namely [PB i1 ,PB i2 ,PB i3 ,PB i4 ,PB i5 , PB i6 , PB i7 , PB i8 ]=dec 2 bin(P i ,8).
进一步地,一种基于不同置乱规则的商品防伪二维码生成方法里步骤(4)中所述的按照自定义的矩阵数据填放规则,将数值序列中元素依次填放入表征灰度图片的矩阵M中,是指按如下三个步骤进行:Further, according to the self-defined matrix data filling rules described in step (4) in a method for generating a product anti-counterfeiting two-dimensional code based on different scrambling rules, the numerical sequence is The elements in the middle are sequentially filled into the matrix M representing the grayscale image, which means that the following three steps are performed:
步骤1.判断数值序列的长度是否小于数值H×L,Step 1. Judge the sequence of values length Is it less than the value H×L,
如果是,则在数值序列的尾端增补上个元素,数值大小为0且最后一个元素大小为得到增补后的数值序列即 If yes, then in the numeric sequence added to the end of elements, the value size is 0 and the last element size is get the appended numeric sequence which is
如果不是,则令增补后的数值序列等于数值序列即 If not, then let the appended numeric sequence is equal to the sequence of numbers which is
步骤2.从表征灰度图片的矩阵M的左上角位置开始,按行且每行从左往右,依次将增补后的数值序列中元素填放入矩阵M中,表示如下,Step 2. Starting from the position of the upper left corner of the matrix M representing the grayscale image, row by row and from left to right in each row, sequentially add the supplemented numerical sequence The elements are filled into the matrix M, which is expressed as follows,
步骤3.将矩阵M中各元素分别用小矩阵块代替,小矩阵块的矩阵大小为30×30、元素数值均与M中该元素数值一致,表示如下,Step 3. Replace each element in the matrix M with a small matrix block. The matrix size of the small matrix block is 30×30, and the element value is consistent with the value of the element in M, which is expressed as follows,
将矩阵MC转换为灰度图片,从而生成灰度图片C,其中灰度图片C的大小为30H×30L。Convert the matrix MC into a grayscale picture, thereby generating a grayscale picture C, where the size of the grayscale picture C is 30H×30L.
进一步地,一种基于不同置乱规则的商品防伪二维码生成方法里步骤(4)中所述的将商品标识码A和生成的灰度图片C进行组合,是指将生成的灰度图片C与商品标识码A上下连接的组合方式,即将商品标识码A放在生成的灰度图片C正下方。Further, the combination of the product identification code A and the generated grayscale picture C described in step (4) in a method for generating a product anti-counterfeiting two-dimensional code based on different scrambling rules refers to combining the generated grayscale picture. The combination method of connecting C and the product identification code A up and down, that is, placing the product identification code A directly below the generated grayscale image C.
有益效果:本发明利用混沌映射迭代并随机抽取产生的混沌序列,对商品标识码转换而成的组合二进制矩阵分别按行、按列不同置乱规则进行置乱,并将行列置乱后二进制矩阵中每列元素转换而成的数值型数据依次填入表征灰度图片的矩阵中,生成一幅灰度图像,进而组合生成商品防伪二维码,以此保证所提基于不同置乱规则的商品防伪二维码生成方法简单可行,具有很强的安全性、不易破解,生成的商品防伪二维码具有“唯一性和不可伪造性”。Beneficial effect: the present invention utilizes the chaotic sequence generated by chaotic mapping iteration and random extraction to scramble the combined binary matrix converted from the commodity identification code according to different scrambling rules of rows and columns, and scrambling the binary matrix after row and column scrambling. The numerical data converted from the elements in each column is filled in the matrix representing the grayscale image in turn to generate a grayscale image, and then combined to generate the product anti-counterfeiting QR code, so as to ensure the proposed products based on different scrambling rules. The anti-counterfeiting two-dimensional code generation method is simple and feasible, has strong security, and is not easy to crack, and the generated anti-counterfeiting two-dimensional code has "uniqueness and unforgeability".
附图说明Description of drawings
图1为本发明的一种基于混沌置乱加密的商品防伪二维码生成流程示意图;Fig. 1 is a kind of product anti-counterfeiting two-dimensional code generation flow schematic diagram based on chaos scrambling encryption of the present invention;
图2为本发明的实施例1中的灰度图片C;2 is a grayscale picture C in Embodiment 1 of the present invention;
图3为本发明的实施例1中的商品防伪二维码。FIG. 3 is a product anti-counterfeiting two-dimensional code in Embodiment 1 of the present invention.
具体实施方式Detailed ways
如图1所示的一种基于不同置乱规则的商品防伪二维码生成方法,包括如下几个步骤:As shown in Figure 1, a product anti-counterfeiting QR code generation method based on different scrambling rules includes the following steps:
(1)转码(1) Transcoding
首先,将表征某件商品唯一身份信息的商品标识码A,逐个字符采用unicode2native(·)函数转换为数值型数据,即对于双字节字符的转换表示为对于单字节字符的转换表示为从而得到数值序列 First, the product identification code A, which represents the unique identity information of a certain product, is converted into numerical data character by character using the unicode2native(·) function, that is, the conversion of double-byte characters is expressed as The conversion for single-byte characters is expressed as to get the sequence of numbers
然后,采用dec 2 bin(Pi,8)函数,依次将数值序列P中元素Pi逐个转换成8bits的二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8},并将个二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8}从左往右逐列填入矩阵B中,其中矩阵某行对应于各二进制序列的某位,从而得到组合二进制矩阵B,Then, using the dec 2 bin(P i ,8) function, the elements P i in the numerical sequence P are converted one by one into a binary sequence of 8 bits {PB i1 ,PB i2 ,PB i3 ,PB i4 ,PB i5 ,PB i6 ,PB i7 ,PB i8 }, and set A binary sequence {PB i1 , PB i2 , PB i3 , PB i4 , PB i5 , PB i6 , PB i7 , PB i8 } is filled into matrix B column by column from left to right, where A row of the matrix corresponds to a bit of each binary sequence, so as to obtain the combined binary matrix B,
其中商品标识码A为GBK编码的字符,商品标识码A的长度表示为数值序列P的长度为组合二进制矩阵B的大小为且 The commodity identification code A is a character encoded by GBK, and the length of the commodity identification code A is expressed as The length of the numerical sequence P is The size of the combined binary matrix B is and
(2)混沌序列的产生(2) Generation of chaotic sequences
首先,利用数值序列P及其转换的组合二进制矩阵B,以及外部密钥α和β,按照如下所示公式分别计算得到Bernoulli混沌映射的初值x1和参数λ以及初次抽取位置n,First, using the numerical sequence P and its converted combined binary matrix B, as well as the external keys α and β, the initial value x 1 and parameter λ of the Bernoulli chaotic map and the initial extraction position n are calculated according to the following formulas, respectively.
令则make but
x1=0.02+mod(α+kp,0.98),x 1 =0.02+mod(α+kp,0.98),
λ=0.01+mod(β+kp,0.99),λ=0.01+mod(β+kp,0.99),
其中,<B>表示组合二进制矩阵B中含有二进制位‘0’的个数,外部密钥满足α∈(0,1),β∈(0,1),表示对某数取整且取整后的值不大于该数,Among them, <B> represents the number of binary bits '0' in the combined binary matrix B, and the external key satisfies α∈(0,1), β∈(0,1), Indicates that a number is rounded and the rounded value is not greater than the number,
然后,由混沌映射的初值x1和参数λ,对如下公式所示的Bernoulli混沌映射进行迭代,式中k表示迭代次数(k=1,2,...)、xk+1表示第k次迭代得到的混沌信号,Then, based on the initial value x 1 of the chaotic map and the parameter λ, the Bernoulli chaotic map shown in the following formula is iterated, where k represents the number of iterations (k=1, 2,...), and x k+1 represents the first The chaotic signal obtained by k iterations,
得到混沌序列X={x1,x2,...},Get the chaotic sequence X={x 1 , x 2 ,...},
最后,对混沌序列X={x1,x2,...}进行如下操作:Finally, perform the following operations on the chaotic sequence X={x 1 , x 2 ,...}:
S10.令混沌序列Y为空序列,且i=1,S10. Let the chaotic sequence Y be an empty sequence, and i=1,
S11.从混沌序列X中抽取第n个元素,并放入混沌序列Y中,即Y=[Y,xn],S11. Extract the nth element from the chaotic sequence X and put it into the chaotic sequence Y, that is, Y=[Y, x n ],
S12.比较i与的大小,若则对抽取位置n按照如下所示公式进行调整,且令i=i+1,随后转向步骤S11,S12. Compare i with size, if Then adjust the extraction position n according to the following formula, and let i=i+1, then turn to step S11,
若则停止操作,从而得到混沌序列 like Then stop the operation, so as to get the chaotic sequence
(3)组合二进制矩阵B的置乱(3) Scrambling of the combined binary matrix B
首先,从混沌序列中第1个元素开始连续抽取8个元素,得到混沌序列Y1={Y11,Y12,...,Y17,Y18}={Y1,Y2,...,Y7,Y8},同时从混沌序列中第9个元素开始连续抽取个元素,得到混沌序列 First, from the chaotic sequence The first element in the 1st element starts to extract 8 elements continuously, and obtains the chaotic sequence Y1={Y1 1 ,Y1 2 ,...,Y1 7 ,Y1 8 }={Y 1 ,Y 2 ,...,Y 7 ,Y 8 }, while the chaotic sequence The 9th element in the start of continuous extraction elements, get a chaotic sequence
然后,按照如下所示公式计算得到参数rule_select,根据rule_select选择不同的置乱规则,Then, calculate the parameter rule_select according to the formula shown below, and select different scrambling rules according to rule_select,
当rule_select=0时,则将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵按列进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为 When rule_select=0, the chaotic sequence Y1 is sorted in descending order, and the combined binary matrix B is scrambled row by row according to the scrambling rules before and after the chaotic sequence Y1 is sorted to obtain the row-scrambling binary matrix The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 }, and then the chaotic sequence Y2 is sorted in descending order, according to the chaotic sequence Y2 before sorting , after the position change scrambling rules, the binary matrix after row scrambling Scramble by column to get a binary matrix after row and column scramble Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
当rule_select=1时,则将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵按列进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为 When rule_select=1, the chaotic sequence Y1 is sorted in descending order, and the combined binary matrix B is scrambled by row according to the scrambling rules before and after the chaotic sequence Y1 is sorted to obtain the row-scrambled binary matrix The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 }, and then the chaotic sequence Y2 is sorted in ascending order, according to the chaotic sequence Y2 before sorting , after the position change scrambling rules, the binary matrix after row scrambling Scramble by column to get a binary matrix after row and column scramble Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
当rule_select=2时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵按列进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为 When rule_select=2, sort the chaotic sequence Y1 in ascending order, and scramble the combined binary matrix B by row according to the scrambling rules of the position change before and after the chaotic sequence Y1 is sorted to obtain the row-scrambled binary matrix The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 }, and then the chaotic sequence Y2 is sorted in descending order, according to the chaotic sequence Y2 before sorting , after the position change scrambling rules, the binary matrix after row scrambling Scramble by column to get a binary matrix after row and column scramble Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
当rule_select=3时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵按列进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为 When rule_select=3, the chaotic sequence Y1 is sorted in ascending order, and the combined binary matrix B is scrambled row by row according to the scrambling rules before and after the chaotic sequence Y1 is sorted to obtain the row-scrambling binary matrix The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 }, and then the chaotic sequence Y2 is sorted in ascending order, according to the chaotic sequence Y2 before sorting , after the position change scrambling rules, the binary matrix after row scrambling Scramble by column to get a binary matrix after row and column scramble Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
当rule_select=4时,则将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为再将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵按行进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},When rule_select=4, the chaotic sequence Y2 is sorted in descending order, and the combined binary matrix B is scrambled by column according to the scrambling rules of the position change before and after the chaotic sequence Y2 is sorted to obtain a column-scrambled binary matrix Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as Then sort the chaotic sequence Y1 in descending order, scrambling the rules according to the position change before and after the sorting of the chaotic sequence Y1, and scramble the binary matrix of the column. Scramble by row to get a binary matrix after row and column scrambling The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 },
当rule_select=5时,则将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为再将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵按行进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},When rule_select=5, the chaotic sequence Y2 is sorted in descending order, and the combined binary matrix B is scrambled by column according to the scrambling rules of the position change before and after the chaotic sequence Y2 is sorted to obtain the column-scrambled binary matrix Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as Then sort the chaotic sequence Y1 in ascending order, scrambling the rules according to the position change before and after the sorting of the chaotic sequence Y1, and scramble the binary matrix of the column. Scramble by row to get a binary matrix after row and column scrambling The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 },
当rule_select=6时,则将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为再将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵按行进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},When rule_select=6, the chaotic sequence Y2 is sorted in ascending order, and the combined binary matrix B is scrambled by column according to the scrambling rules of the position change before and after the chaotic sequence Y2 is sorted to obtain the column-scrambled binary matrix Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as Then sort the chaotic sequence Y1 in descending order, scrambling the rules according to the position change before and after the sorting of the chaotic sequence Y1, and scramble the binary matrix of the column. Scramble by row to get a binary matrix after row and column scrambling The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 },
当rule_select=7时,则将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为再将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵按行进行置乱,得到行列置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},When rule_select=7, the chaotic sequence Y2 is sorted in ascending order, and the combined binary matrix B is scrambled by column according to the scrambling rules of the position change before and after the chaotic sequence Y2 is sorted to obtain a column-scrambled binary matrix Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as Then sort the chaotic sequence Y1 in ascending order, scrambling the rules according to the position change before and after the sorting of the chaotic sequence Y1, and scramble the binary matrix of the column. Scramble by row to get a binary matrix after row and column scrambling The scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {T1 1 ,T1 2 ,...,T1 7 ,T1 8 },
最后,依次将行列置乱后的二进制矩阵的每列元素转换成数值型数据其中表示为从而得到数值序列 Finally, the binary matrix after scrambling the rows and columns in turn elements of each column of Convert to numeric data in Expressed as to get the sequence of numbers
(4)二维码的生成(4) Generation of QR code
其中,表示对某数取整且取整后的值不小于该数,in, Indicates that a number is rounded and the rounded value is not less than the number,
然后,依次按如下步骤进行:Then, proceed as follows in sequence:
步骤①.判断数值序列的长度是否小于数值H×L,Step 1. Judging the numerical sequence length Is it less than the value H×L,
如果是,则在数值序列的尾端增补上个元素,数值大小为0且最后一个元素大小为得到增补后的数值序列即 If yes, then in the numeric sequence added to the end of elements, the value size is 0 and the last element size is get the appended numeric sequence which is
如果不是,则令增补后的数值序列等于数值序列即 If not, then let the appended numeric sequence is equal to the sequence of numbers which is
步骤②.从表征灰度图片的矩阵M的左上角位置开始,按行且每行从左往右,依次将增补后的数值序列中元素填放入矩阵M中,表示如下,Step 2. Starting from the upper left corner of the matrix M representing the grayscale image, row by row and from left to right in each row, sequentially add the supplemented numerical sequence The elements are filled into the matrix M, which is expressed as follows,
步骤③.将矩阵M中各元素分别用小矩阵块代替,小矩阵块的矩阵大小为30×30、元素数值均与M中该元素数值一致,表示如下,Step 3. Replace each element in the matrix M with a small matrix block, the matrix size of the small matrix block is 30×30, and the element value is consistent with the element value in M, which is expressed as follows,
将矩阵MC转换为灰度图片,从而生成灰度图片C,其中灰度图片C的大小为30H×30L,Convert the matrix MC to a grayscale image to generate a grayscale image C, where the size of the grayscale image C is 30H×30L,
最后,将生成的灰度图片C与商品标识码A上下连接的组合方式,即将商品标识码A放在生成的灰度图片C正下方,并利用二维码生成器将组合的商品标识码和灰度图片转换为二维码,从而得到商品防伪二维码。Finally, the combination of the generated grayscale picture C and the product identification code A is connected up and down, that is, the product identification code A is placed directly below the generated grayscale picture C, and the combined product identification code and The grayscale image is converted into a two-dimensional code, thereby obtaining a product anti-counterfeiting two-dimensional code.
下面结合具体的实施例对本发明作进一步说明:Below in conjunction with specific embodiment, the present invention will be further described:
实施例1Example 1
按照上述一种基于不同置乱规则的商品防伪二维码生成方法,步骤如下:According to the above-mentioned method for generating a product anti-counterfeiting QR code based on different scrambling rules, the steps are as follows:
(1)首先,将表征某件商品唯一身份信息的商品标识码A=“江苏省##集团××公司☆****商品 生产日期2021-01-01 生产线Ⅱ0 1 生产序号1 2 3 4 5 6”,逐个字符转换为数值型数据,得到数值序列P={189,173,203,213,202,161,163,163,163,163,188,175,205,197,161,193,161,193,185,171,203,190,161,238,42,42,42,42,201,204,198,183,32,201,250,178,250,200,213,198,218,50,48,50,49,45,48,49,45,48,49,32,201,250,178,250,207,223,162,242,163,176,163,177,32,201,250,178,250,208,242,186,197,163,177,163,178,163,179,163,180,163,181,163,182},其中商品标识码A为GBK编码的字符,商品标识码A的长度表示为数值序列P的长度为 (1) First, the product identification code A that characterizes the unique identity information of a certain product = "Jiangsu Province ##GroupXX Company ☆****Product Production Date 2021-01-01 Production Line II0 1 Production Serial Number 1 2 3 4 5 6”,逐个字符转换为数值型数据,得到数值序列P={189,173,203,213,202,161,163,163,163,163,188,175,205,197,161,193,161,193,185,171,203,190,161,238,42,42,42,42,201,204,198,183,32,201,250,178,250,200,213,198,218,50,48,50,49,45,48,49,45,48,49, 32,201,250,178,250,207,223,162,242,163,176,163,177,32,201,250,178,250,208,242,186,197,163,177,163,178,163,179,163,180,163,181,163,182},其中商品标识码A为GBK编码的字符,商品标识码A的长度表示为 The length of the numerical sequence P is
然后,依次将数值序列P中元素Pi逐个转换成8bits的二进制序列,并从左往右逐列填入二进制矩阵B中,从而得到组合二进制矩阵B,Then, convert the elements P i in the numerical sequence P into a binary sequence of 8 bits one by one, and fill in the binary matrix B column by column from left to right, thereby obtaining the combined binary matrix B,
(2)混沌序列的产生(2) Generation of chaotic sequences
首先,利用数值序列P及其转换的二进制矩阵B,以及外部密钥α=0.12345和β=0.54321,按照如下所示的公式分别计算得到Bernoulli混沌映射的初值x1和参数λ以及初次抽取位置n,First, using the numerical sequence P and its converted binary matrix B, as well as the external keys α=0.12345 and β=0.54321, the initial value x 1 and parameter λ of the Bernoulli chaotic map and the initial extraction position are calculated according to the formulas shown below. n,
令则make but
x1=0.02+mod(0.12345+0.320977516596008,0.98)=0.464427516596008,x 1 =0.02+mod(0.12345+0.320977516596008,0.98)=0.464427516596008,
λ=0.01+mod(0.54321+0.320977516596008,0.99)=0.874187516596008,λ=0.01+mod(0.54321+0.320977516596008,0.99)=0.874187516596008,
然后,由混沌映射的初值x1=0.464427516596008和参数λ=0.874187516596008,对如下公式所示的Bernoulli混沌映射进行迭代,得到混沌序列X={x1,x2,...},Then, based on the initial value of the chaotic map x 1 =0.464427516596008 and the parameter λ=0.874187516596008, the Bernoulli chaotic map shown in the following formula is iterated to obtain the chaotic sequence X={x 1 ,x 2 ,...},
最后,对混沌序列X={x1,x2,...}进行如下操作:Finally, perform the following operations on the chaotic sequence X={x 1 , x 2 ,...}:
S10.令混沌序列Y为空序列,且i=1,S10. Let the chaotic sequence Y be an empty sequence, and i=1,
S11.从混沌序列X中抽取第n个元素,并放入混沌序列Y中,即Y=[Y,xn],S11. Extract the nth element from the chaotic sequence X and put it into the chaotic sequence Y, that is, Y=[Y, x n ],
S12.比较i与93的大小,若i<93,则对抽取位置n按照如下所示公式进行调整,且令i=i+1,随后转向步骤S11,S12. Compare the size of i and 93, if i<93, adjust the extraction position n according to the formula shown below, and set i=i+1, then turn to step S11,
若i=93,则停止操作,从而得到混沌序列Y={Y1,Y2,...,Y92,Y93};If i=93, stop the operation, so as to obtain the chaotic sequence Y={Y 1 , Y 2 ,..., Y 92 , Y 93 };
(3)组合二进制矩阵B的行、列置乱(3) The rows and columns of the combined binary matrix B are scrambled
首先,从混沌序列Y={Y1,Y2,...,Y92,Y93}中第1个元素开始依次抽取8个元素,得到混沌序列Y1={Y1,Y2,...,Y7,Y8},同时从混沌序列Y={Y1,Y2,...,Y92,Y93}中第9个元素开始依次抽取85个元素,得到混沌序列Y2={Y21,Y22,...,Y284,Y285},First, extract 8 elements from the first element in the chaotic sequence Y={Y 1 , Y 2 ,...,Y 92 , Y 93 }, and obtain the chaotic sequence Y1={Y 1 ,Y 2 ,... .,Y 7 ,Y 8 }, and simultaneously extract 85 elements from the 9th element in the chaotic sequence Y={Y 1 ,Y 2 ,...,Y 92 ,Y 93 }, and obtain the chaotic sequence Y2={ Y2 1 ,Y2 2 ,...,Y2 84 ,Y2 85 },
然后,按照如下所示公式计算参数rule_select,根据rule_select选择不同的置乱规则,Then, calculate the parameter rule_select according to the formula shown below, and select different scrambling rules according to rule_select,
rule_select=mod(26024+4176991+6502309+13812+331,8)=3,rule_select=mod(26024+4176991+6502309+13812+331,8)=3,
当rule_select=3时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B进行行置乱,得到行置乱后的二进制矩阵其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{2,4,6,1,7,3,5,8},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵进行列置乱,得到行列置乱后的二进制矩阵其中混沌序列Y2排序前、后的位置变化置乱规则可表示为{77,82,75,29,35,65,31,56,23,79,69,8,78,52,49,83,4,68,64,63,45,85,21,81,24,66,59,40,39,76,55,26,5,58,38,37,44,28,46,18,34,42,62,54,84,30,47,53,3,73,27,70,61,33,9,60,74,36,17,19,57,2,72,10,80,13,48,7,11,22,12,20,67,41,14,6,1,43,32,25},When rule_select=3, the chaotic sequence Y1 is sorted in ascending order, and the row scrambling is performed on the combined binary matrix B according to the scrambling rules before and after the chaotic sequence Y1 is sorted to obtain the row-scrambling binary matrix Among them, the scrambling rules of the position change before and after the chaotic sequence Y1 can be expressed as {2,4,6,1,7,3,5,8}, and then the chaotic sequence Y2 is sorted in ascending order, according to the chaotic sequence Y2 before sorting , after the position change scrambling rules, the binary matrix after row scrambling Perform column scrambling to get the binary matrix after row and column scrambling Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as {77, 82, 75, 29, 35, 65, 31, 56, 23, 79, 69, 8, 78, 52, 49, 83, 4,68,64,63,45,85,21,81,24,66,59,40,39,76,55,26,5,58,38,37,44,28,46,18,34, 42,62,54,84,30,47,53,3,73,27,70,61,33,9,60,74,36,17,19,57,2,72,10,80,13, 48,7,11,22,12,20,67,41,14,6,1,43,32,25},
最后,依次将行列置乱后的二进制矩阵的每列元素转换成数值型数据从而得到数值序列Finally, the binary matrix after scrambling the rows and columns in turn elements of each column of Convert to numeric data to get the sequence of numbers
(4)二维码的生成(4) Generation of QR code
首先,确定灰度图片的大小,得到行数为H=9,列数为L=10First, determine the size of the grayscale image, and get the number of rows as H=9 and the number of columns as L=10
然后,依次按如下步骤进行:Then, proceed as follows in sequence:
步骤①.在数值序列的尾端增补上5个元素,数值大小为0且最后一个元素大小为85,得到增补后的数值序列Step ①. In the numerical sequence Add 5 elements to the end of the value, the size of the value is 0 and the size of the last element is 85, and the added value sequence is obtained.
步骤②.从表征灰度图片的矩阵M的左上角位置开始,按行且每行从左往右,依次将增补后的数值序列中元素填放入矩阵M中,其中矩阵M的大小为9×10,表示如下,Step 2. Starting from the upper left corner of the matrix M representing the grayscale image, row by row and from left to right in each row, sequentially add the supplemented numerical sequence The elements are filled into the matrix M, where the size of the matrix M is 9 × 10, which is expressed as follows,
步骤③.将矩阵M中各元素分别用小矩阵块代替,小矩阵块的矩阵大小为30×30、元素数值均与M中该元素数值一致,表示如下,Step 3. Replace each element in the matrix M with a small matrix block, the matrix size of the small matrix block is 30×30, and the element value is consistent with the element value in M, which is expressed as follows,
随后将矩阵MC转换为灰度图片,从而生成灰度图片C,如图2所示,其中灰度图片C的大小为270×300。Then, the matrix MC is converted into a grayscale picture, thereby generating a grayscale picture C, as shown in FIG. 2 , where the size of the grayscale picture C is 270×300.
最后,将生成的灰度图片C与商品标识码A上下连接的组合方式,即将商品标识码A放在生成的灰度图片C正下方,并利用二维码生成器将组合的商品标识码和灰度图片转换为二维码,从而得到商品防伪二维码,如图3所示。Finally, the combination of the generated grayscale picture C and the product identification code A is connected up and down, that is, the product identification code A is placed directly below the generated grayscale picture C, and the combined product identification code and The grayscale image is converted into a two-dimensional code, thereby obtaining a product anti-counterfeiting two-dimensional code, as shown in Figure 3.
实施例2Example 2
按照上述一种基于不同置乱规则的商品防伪二维码生成方法,某件商品的商品标识码字符串A及其商品防伪二维码生成步骤与具体实施例1相似,仅某个外部密钥发生细微变化:α=0.12345000000001;或β=0.54321000000001,商品防伪二维码的生成结果如表1所示。由下表可见:一旦外部密钥即使发生细微变化,生成的商品防伪二维码会发生极大的变化,由此可见本专利所提一种基于不同置乱规则的商品防伪二维码生成方法具有密钥敏感性。According to the above-mentioned method for generating a product anti-counterfeiting two-dimensional code based on different scrambling rules, the product identification code string A of a product and its product anti-counterfeiting two-dimensional code generation steps are similar to those in the specific embodiment 1, and only a certain external key A slight change occurs: α=0.12345000000001; or β=0.54321000000001, the generation results of the product anti-counterfeiting QR code are shown in Table 1. It can be seen from the following table: once the external key changes slightly, the generated anti-counterfeiting two-dimensional code will change greatly. It can be seen that a method for generating anti-counterfeiting two-dimensional code based on different scrambling rules proposed in this patent Has key sensitivity.
表1外部密钥发生微变时,商品防伪二维码的生成结果Table 1 The generation results of commodity anti-counterfeiting QR code when the external key changes slightly
实施例3Example 3
按照上述一种基于不同置乱规则的商品防伪二维码生成方法,外部密钥及其商品防伪二维码生成步骤与具体实施例1相似,仅某件商品的商品标识码字符串A发生细微变化“冮苏省##集团××公司☆****商品生产日期2021-01-01生产线Ⅱ01生产序号123456”;或者“江苏省##集团××公司☆****商品生产日期2021-11-01生产线Ⅱ01生产序号123456”;或者“江苏省##集团××公司☆****商品生产日期2021-01-01生产线Ⅱ02生产序号123465”,商品防伪二维码的生成结果如表2所示。由下表可见:一旦表征某件商品唯一身份信息的商品标识码字符串即使发生细微变化,生成的商品防伪二维码会发生极大的变化,由此可见本专利所提一种基于不同置乱规则的商品防伪二维码生成方法对商品身份信息(即商品标识码)具有敏感性。According to the above-mentioned method for generating a product anti-counterfeiting two-dimensional code based on different scrambling rules, the steps for generating an external key and its product anti-counterfeiting two-dimensional code are similar to those in the specific embodiment 1, and only the product identification code string A of a certain product has subtle occurrences. Change “冮Su Province##Group××Company ☆****Product Production Date 2021-01-01 Production Line II01 Production Serial No. 123456”; or “Jiangsu Province##Group××Company☆****Product Production Date 2021” -11-01 Production line II01 production serial number 123456"; or "Jiangsu ##Groupxx Company ☆**** product production date 2021-01-01 Production line II02 production serial number 123465", the generation result of the product anti-counterfeiting QR code is as follows shown in Table 2. It can be seen from the following table: once the product identification code string representing the unique identity information of a certain product changes slightly, the generated product anti-counterfeiting QR code will change greatly. The generation method of commodity anti-counterfeiting QR code with irregular rules is sensitive to commodity identity information (ie commodity identification code).
表2商品标识码发生微变时,商品防伪二维码的生成结果Table 2 When the product identification code changes slightly, the generation results of the product anti-counterfeiting QR code
由上述具体实施例2和例3分析可知,本专利所提一种基于不同置乱规则的商品防伪二维码生成方法所生成商品防伪二维码不仅与外部密钥密切相关,而且依赖于表征某件商品唯一身份信息的商品标识码,因此本专利所提的一种基于不同置乱规则的商品防伪二维码生成方法具有很强的安全性,可以较好地抵抗已知/选择明文攻击,不易破解,以保证生成的商品防伪二维码具有“唯一性和不可伪造性”。From the analysis of the above-mentioned specific examples 2 and 3, it can be seen that the product anti-counterfeiting two-dimensional code generated by the product anti-counterfeiting two-dimensional code generation method based on different scrambling rules proposed in this patent is not only closely related to the external key, but also depends on the characterization. The product identification code of the unique identity information of a certain product, so a product anti-counterfeiting QR code generation method based on different scrambling rules proposed in this patent has strong security and can better resist known/selected plaintext attacks , it is not easy to crack, so as to ensure that the generated product anti-counterfeiting QR code is "unique and unforgeable".
以上所述,仅是本发明的较佳实施例而已,并非对本发明作任何形式上的限制,虽然本发明已以较佳实施例揭露如上,然而并非用以限定本发明,任何熟悉本专业的技术人员,在不脱离本发明技术方案范围内,当可利用上述揭示的技术内容作出些许更动或修饰为等同变化的等效实施例,但凡是未脱离本发明技术方案的内容,依据本发明的技术实质对以上实施例所作的任何简单修改、等同变化与修饰,均仍属于本发明技术方案的范围内。The above are only preferred embodiments of the present invention, and do not limit the present invention in any form. Although the present invention has been disclosed above with preferred embodiments, it is not intended to limit the present invention. Technical personnel, within the scope of the technical solution of the present invention, can make some changes or modifications to equivalent embodiments of equivalent changes by using the technical content disclosed above, but any content that does not depart from the technical solution of the present invention, according to the present invention Any simple modifications, equivalent changes and modifications made to the above embodiments still fall within the scope of the technical solutions of the present invention.
Claims (5)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110378301.8A CN113159252A (en) | 2021-04-08 | 2021-04-08 | Commodity anti-counterfeiting two-dimensional code generation method based on different scrambling rules |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110378301.8A CN113159252A (en) | 2021-04-08 | 2021-04-08 | Commodity anti-counterfeiting two-dimensional code generation method based on different scrambling rules |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113159252A true CN113159252A (en) | 2021-07-23 |
Family
ID=76889099
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110378301.8A Pending CN113159252A (en) | 2021-04-08 | 2021-04-08 | Commodity anti-counterfeiting two-dimensional code generation method based on different scrambling rules |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113159252A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113935344A (en) * | 2021-10-12 | 2022-01-14 | 南通大学 | Commodity anti-counterfeiting code batch generation method based on trademark picture scrambling encryption |
CN113947096A (en) * | 2021-10-12 | 2022-01-18 | 南通大学 | Commodity anti-counterfeiting code identification method based on picture-to-character string decryption |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5751811A (en) * | 1995-08-30 | 1998-05-12 | Magnotti; Joseph C. | 32N +D bit key encryption-decryption system using chaos |
CN109284803A (en) * | 2018-11-19 | 2019-01-29 | 南通大学 | A kind of product anti-counterfeiting two-dimensional code generation method |
CN110033066A (en) * | 2019-03-21 | 2019-07-19 | 江苏工程职业技术学院 | A kind of generation method of colour garbage classification two dimensional code |
CN111382452A (en) * | 2020-02-25 | 2020-07-07 | 南通大学 | An encryption method for converting Chinese characters to pictures |
CN112116046A (en) * | 2020-09-28 | 2020-12-22 | 江苏工程职业技术学院 | Garbage classification two-dimensional code generation method based on layered encryption |
CN112149773A (en) * | 2020-09-16 | 2020-12-29 | 南通大学 | Commodity anti-counterfeiting code generation method based on Chinese character encryption |
-
2021
- 2021-04-08 CN CN202110378301.8A patent/CN113159252A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5751811A (en) * | 1995-08-30 | 1998-05-12 | Magnotti; Joseph C. | 32N +D bit key encryption-decryption system using chaos |
CN109284803A (en) * | 2018-11-19 | 2019-01-29 | 南通大学 | A kind of product anti-counterfeiting two-dimensional code generation method |
CN110033066A (en) * | 2019-03-21 | 2019-07-19 | 江苏工程职业技术学院 | A kind of generation method of colour garbage classification two dimensional code |
CN111382452A (en) * | 2020-02-25 | 2020-07-07 | 南通大学 | An encryption method for converting Chinese characters to pictures |
CN112149773A (en) * | 2020-09-16 | 2020-12-29 | 南通大学 | Commodity anti-counterfeiting code generation method based on Chinese character encryption |
CN112116046A (en) * | 2020-09-28 | 2020-12-22 | 江苏工程职业技术学院 | Garbage classification two-dimensional code generation method based on layered encryption |
Non-Patent Citations (1)
Title |
---|
盛苏英等: "基于混沌的数码防伪系统研究与实现", 《微电子学与计算机》 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113935344A (en) * | 2021-10-12 | 2022-01-14 | 南通大学 | Commodity anti-counterfeiting code batch generation method based on trademark picture scrambling encryption |
CN113947096A (en) * | 2021-10-12 | 2022-01-18 | 南通大学 | Commodity anti-counterfeiting code identification method based on picture-to-character string decryption |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112884104B (en) | A method for generating anti-counterfeiting two-dimensional code based on chaos encryption | |
CN112884105B (en) | A method for generating anti-counterfeiting two-dimensional code based on shift encryption | |
CN113255860B (en) | A product anti-counterfeiting two-dimensional code generation method based on layered encryption | |
CN113052286A (en) | Commodity anti-counterfeiting two-dimensional code generation method based on scrambling encryption | |
CN109472338B (en) | Batch generation method of commodity anti-counterfeiting two-dimensional codes | |
CN113159252A (en) | Commodity anti-counterfeiting two-dimensional code generation method based on different scrambling rules | |
CN112001468B (en) | A method for generating and recognizing anti-counterfeiting codes for character-type commodities | |
CN104050400B (en) | A kind of web page interlinkage guard method that steganography is encoded based on command character | |
CN112001467A (en) | Commodity anti-counterfeiting code generation and identification method based on picture encryption and decryption | |
CN107425956B (en) | A method for generating anti-counterfeiting codes for character-type commodities | |
CN112163230B (en) | A method for generating anti-counterfeiting code of goods with Chinese character encryption | |
CN112149773B (en) | Commodity anti-counterfeiting code generation method based on Chinese character encryption | |
CN116305015A (en) | Watermark Embedding Method for Neural Network Model Against Robustness Attack | |
CN117494081A (en) | Text watermark generation and detection method based on large language model with biased output | |
CN111382820B (en) | Four-lattice pure-color commodity anti-counterfeiting code generation method | |
CN112149774A (en) | Chinese character commodity anti-counterfeiting code generation method | |
CN112217627B (en) | Layered encrypted commodity anti-counterfeiting code generation method | |
CN104376236B (en) | Scheme self-adaptive digital watermark embedding grammar and extracting method based on camouflage science | |
CN113935345B (en) | A batch generation method of commodity anti-counterfeiting code based on string-to-image encryption | |
CN110111477A (en) | A kind of lottery information anti-counterfeiting authentication method and system based on Information hiding | |
CN1482560A (en) | Network seal authentication system | |
CN113935343B (en) | Commodity anti-counterfeiting code generation method based on character string-to-picture encryption | |
CN107612678A (en) | A kind of steganography method based on network topology structure figure | |
CN113935346B (en) | A product anti-counterfeiting code generation method based on trademark image scrambling and encryption | |
CN112614196B (en) | Image robustness Hash authentication method based on quaternion convolution neural network |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210723 |
|
RJ01 | Rejection of invention patent application after publication |