[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

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 PDF

Info

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
Application number
CN202110378301.8A
Other languages
Chinese (zh)
Inventor
盛苏英
刘焰森
陆国平
张小美
张振娟
吴新华
任洁
朱建红
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nantong University
Original Assignee
Nantong University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nantong University filed Critical Nantong University
Priority to CN202110378301.8A priority Critical patent/CN113159252A/en
Publication of CN113159252A publication Critical patent/CN113159252A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record 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/06009Record 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/06037Record 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

The invention discloses a commodity anti-counterfeiting two-dimensional code generation method based on different scrambling rules, which comprises the following steps: carrying out numerical data and 8-bit binary conversion on a commodity identification code representing unique identity information of a certain commodity to obtain a combined binary matrix B; adjusting extraction positions in real time, performing chaotic iteration and extracting to generate chaotic sequences Y1 and Y2; respectively carrying out row-column scrambling and row-column scrambling on the matrix B according to different scrambling rules by respectively utilizing respective ascending or descending sorting front and rear position change rules of the sequence Y1 and the sequence Y2 to obtain a binary matrix after row-column scrambling
Figure DDA0003011689380000011
Will matrix
Figure DDA0003011689380000012
And the numerical data converted from each row of elements are sequentially filled in a matrix representing the gray level picture to generate a gray level image, and the gray level image is combined to generate the commodity anti-counterfeiting two-dimensional code. The invention providesThe commodity anti-counterfeiting two-dimensional code generation method based on different scrambling rules is simple and feasible, has strong safety and is not easy to crack, and the generated commodity anti-counterfeiting two-dimensional code has uniqueness and non-forgeability.

Description

一种基于不同置乱规则的商品防伪二维码生成方法A product anti-counterfeiting two-dimensional code generation method based on different scrambling rules

技术领域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,逐个字符转换为数值型数据,得到数值序列

Figure BDA0003011689360000021
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
Figure BDA0003011689360000021

然后,依次将数值序列P中元素Pi逐个转换成8bits的二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8},并将

Figure BDA0003011689360000022
个二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8}从左往右逐列填入矩阵B中,其中
Figure BDA0003011689360000023
矩阵某行对应于各二进制序列的某位,从而得到组合二进制矩阵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
Figure BDA0003011689360000022
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
Figure BDA0003011689360000023
A row of the matrix corresponds to a bit of each binary sequence, so as to obtain the combined binary matrix B,

Figure BDA0003011689360000024
Figure BDA0003011689360000024

其中商品标识码A为GBK编码的字符,商品标识码A的长度表示为

Figure BDA0003011689360000025
数值序列P的长度为
Figure BDA0003011689360000026
组合二进制矩阵B的大小为
Figure BDA0003011689360000027
Figure BDA0003011689360000028
The commodity identification code A is a character encoded by GBK, and the length of the commodity identification code A is expressed as
Figure BDA0003011689360000025
The length of the numerical sequence P is
Figure BDA0003011689360000026
The size of the combined binary matrix B is
Figure BDA0003011689360000027
and
Figure BDA0003011689360000028

(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,

Figure BDA0003011689360000029
则make
Figure BDA0003011689360000029
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)

Figure BDA00030116893600000210
Figure BDA00030116893600000210

其中,<B>表示组合二进制矩阵B中含有二进制位‘0’的个数,外部密钥满足α∈(0,1),β∈(0,1),

Figure BDA00030116893600000211
表示对某数取整且取整后的值不大于该数,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),
Figure BDA00030116893600000211
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,

Figure BDA0003011689360000031
Figure BDA0003011689360000031

得到混沌序列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与

Figure BDA0003011689360000032
的大小,若
Figure BDA0003011689360000033
则对抽取位置n按照如下公式(5)进行调整,且令i=i+1,随后转向步骤S11,S12. Compare i with
Figure BDA0003011689360000032
size, if
Figure BDA0003011689360000033
Then adjust the extraction position n according to the following formula (5), and let i=i+1, then turn to step S11,

Figure BDA0003011689360000034
Figure BDA0003011689360000034

Figure BDA0003011689360000035
则停止操作,从而得到混沌序列
Figure BDA0003011689360000036
like
Figure BDA0003011689360000035
Then stop the operation, so as to get the chaotic sequence
Figure BDA0003011689360000036

(3)组合二进制矩阵B的置乱(3) Scrambling of the combined binary matrix B

首先,从混沌序列

Figure BDA0003011689360000037
中第1个元素开始连续抽取8个元素,得到混沌序列Y1={Y11,Y12,...,Y17,Y18}={Y1,Y2,...,Y7,Y8},同时从混沌序列
Figure BDA0003011689360000038
中第9个元素开始连续抽取
Figure BDA0003011689360000039
个元素,得到混沌序列
Figure BDA00030116893600000310
First, from the chaotic sequence
Figure BDA0003011689360000037
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
Figure BDA0003011689360000038
The 9th element in the start of continuous extraction
Figure BDA0003011689360000039
elements, get a chaotic sequence
Figure BDA00030116893600000310

然后,按照如下公式(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,

Figure BDA00030116893600000311
Figure BDA00030116893600000311

当rule_select=0时,则将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵

Figure BDA00030116893600000312
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure BDA00030116893600000313
按列进行置乱,得到行列置乱后的二进制矩阵
Figure BDA00030116893600000314
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA00030116893600000315
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
Figure BDA00030116893600000312
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
Figure BDA00030116893600000313
Scramble by column to get a binary matrix after row and column scramble
Figure BDA00030116893600000314
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA00030116893600000315

Figure BDA0003011689360000041
Figure BDA0003011689360000041

当rule_select=1时,则将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵

Figure BDA0003011689360000042
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure BDA0003011689360000043
按列进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000044
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000045
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
Figure BDA0003011689360000042
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
Figure BDA0003011689360000043
Scramble by column to get a binary matrix after row and column scramble
Figure BDA0003011689360000044
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000045

Figure BDA0003011689360000046
Figure BDA0003011689360000046

Figure BDA0003011689360000051
Figure BDA0003011689360000051

当rule_select=2时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵

Figure BDA0003011689360000052
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure BDA0003011689360000053
按列进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000054
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000055
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
Figure BDA0003011689360000052
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
Figure BDA0003011689360000053
Scramble by column to get a binary matrix after row and column scramble
Figure BDA0003011689360000054
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000055

Figure BDA0003011689360000056
Figure BDA0003011689360000056

当rule_select=3时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵

Figure BDA0003011689360000057
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure BDA0003011689360000061
按列进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000062
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000063
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
Figure BDA0003011689360000057
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
Figure BDA0003011689360000061
Scramble by column to get a binary matrix after row and column scramble
Figure BDA0003011689360000062
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000063

Figure BDA0003011689360000064
Figure BDA0003011689360000064

当rule_select=4时,则将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵

Figure BDA0003011689360000065
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000066
再将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure BDA0003011689360000067
按行进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000068
其中混沌序列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
Figure BDA0003011689360000065
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000066
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.
Figure BDA0003011689360000067
Scramble by row to get a binary matrix after row and column scrambling
Figure BDA0003011689360000068
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 },

Figure BDA0003011689360000069
Figure BDA0003011689360000069

Figure BDA0003011689360000071
Figure BDA0003011689360000071

当rule_select=5时,则将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵

Figure BDA0003011689360000072
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000073
再将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure BDA0003011689360000074
按行进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000075
其中混沌序列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
Figure BDA0003011689360000072
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000073
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.
Figure BDA0003011689360000074
Scramble by row to get a binary matrix after row and column scrambling
Figure BDA0003011689360000075
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 },

Figure BDA0003011689360000076
Figure BDA0003011689360000076

当rule_select=6时,则将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵

Figure BDA0003011689360000077
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000078
再将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure BDA0003011689360000081
按行进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000082
其中混沌序列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
Figure BDA0003011689360000077
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000078
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.
Figure BDA0003011689360000081
Scramble by row to get a binary matrix after row and column scrambling
Figure BDA0003011689360000082
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 },

Figure BDA0003011689360000083
Figure BDA0003011689360000083

当rule_select=7时,则将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵

Figure BDA0003011689360000084
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000085
再将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure BDA0003011689360000086
按行进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000087
其中混沌序列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
Figure BDA0003011689360000084
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000085
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.
Figure BDA0003011689360000086
Scramble by row to get a binary matrix after row and column scrambling
Figure BDA0003011689360000087
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 },

Figure BDA0003011689360000088
Figure BDA0003011689360000088

Figure BDA0003011689360000091
Figure BDA0003011689360000091

最后,依次将行列置乱后的二进制矩阵

Figure BDA0003011689360000092
的每列元素
Figure BDA0003011689360000093
转换成数值型数据
Figure BDA0003011689360000094
其中
Figure BDA0003011689360000095
表示为
Figure BDA0003011689360000096
从而得到数值序列
Figure BDA0003011689360000097
Finally, the binary matrix after scrambling the rows and columns in turn
Figure BDA0003011689360000092
elements of each column of
Figure BDA0003011689360000093
Convert to numeric data
Figure BDA0003011689360000094
in
Figure BDA0003011689360000095
Expressed as
Figure BDA0003011689360000096
to get the sequence of numbers
Figure BDA0003011689360000097

(4)二维码的生成(4) Generation of QR code

Figure BDA0003011689360000098
Figure BDA0003011689360000098

其中,

Figure BDA0003011689360000099
表示对某数取整且取整后的值不小于该数,in,
Figure BDA0003011689360000099
Indicates that a number is rounded and the rounded value is not less than the number,

然后,按照自定义的矩阵数据填放规则,将数值序列

Figure BDA00030116893600000910
中元素依次填放入表征灰度图片的矩阵M中,从而生成灰度图片C,其中矩阵M的大小为H×L,灰度图片C的大小为30H×30L,Then, according to the custom matrix data filling rules, the numerical sequence is
Figure BDA00030116893600000910
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(·)函数转换为数值型数据,即对于双字节字符的转换表示为

Figure BDA00030116893600000911
对于单字节字符的转换表示为
Figure BDA00030116893600000912
从而得到数值序列
Figure BDA00030116893600000914
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
Figure BDA00030116893600000911
The conversion for single-byte characters is expressed as
Figure BDA00030116893600000912
to get the sequence of numbers
Figure BDA00030116893600000914

进一步地,一种基于不同置乱规则的商品防伪二维码生成方法里步骤(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)中所述的按照自定义的矩阵数据填放规则,将数值序列

Figure BDA00030116893600000913
中元素依次填放入表征灰度图片的矩阵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
Figure BDA00030116893600000913
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.判断数值序列

Figure BDA0003011689360000101
的长度
Figure BDA0003011689360000102
是否小于数值H×L,Step 1. Judge the sequence of values
Figure BDA0003011689360000101
length
Figure BDA0003011689360000102
Is it less than the value H×L,

如果是,则在数值序列

Figure BDA0003011689360000103
的尾端增补上
Figure BDA0003011689360000104
个元素,数值大小为0且最后一个元素大小为
Figure BDA0003011689360000105
得到增补后的数值序列
Figure BDA0003011689360000106
Figure BDA0003011689360000107
If yes, then in the numeric sequence
Figure BDA0003011689360000103
added to the end of
Figure BDA0003011689360000104
elements, the value size is 0 and the last element size is
Figure BDA0003011689360000105
get the appended numeric sequence
Figure BDA0003011689360000106
which is
Figure BDA0003011689360000107

如果不是,则令增补后的数值序列

Figure BDA0003011689360000108
等于数值序列
Figure BDA0003011689360000109
Figure BDA00030116893600001010
If not, then let the appended numeric sequence
Figure BDA0003011689360000108
is equal to the sequence of numbers
Figure BDA0003011689360000109
which is
Figure BDA00030116893600001010

步骤2.从表征灰度图片的矩阵M的左上角位置开始,按行且每行从左往右,依次将增补后的数值序列

Figure BDA00030116893600001011
中元素填放入矩阵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
Figure BDA00030116893600001011
The elements are filled into the matrix M, which is expressed as follows,

Figure BDA00030116893600001012
Figure BDA00030116893600001012

步骤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,

Figure BDA00030116893600001013
Figure BDA00030116893600001013

将矩阵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(·)函数转换为数值型数据,即对于双字节字符的转换表示为

Figure BDA0003011689360000111
对于单字节字符的转换表示为
Figure BDA0003011689360000112
从而得到数值序列
Figure BDA0003011689360000113
Figure BDA0003011689360000114
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
Figure BDA0003011689360000111
The conversion for single-byte characters is expressed as
Figure BDA0003011689360000112
to get the sequence of numbers
Figure BDA0003011689360000113
Figure BDA0003011689360000114

然后,采用dec 2 bin(Pi,8)函数,依次将数值序列P中元素Pi逐个转换成8bits的二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8},并将

Figure BDA0003011689360000115
个二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8}从左往右逐列填入矩阵B中,其中
Figure BDA0003011689360000116
矩阵某行对应于各二进制序列的某位,从而得到组合二进制矩阵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
Figure BDA0003011689360000115
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
Figure BDA0003011689360000116
A row of the matrix corresponds to a bit of each binary sequence, so as to obtain the combined binary matrix B,

Figure BDA0003011689360000117
Figure BDA0003011689360000117

其中商品标识码A为GBK编码的字符,商品标识码A的长度表示为

Figure BDA0003011689360000118
数值序列P的长度为
Figure BDA0003011689360000119
组合二进制矩阵B的大小为
Figure BDA00030116893600001110
Figure BDA00030116893600001111
The commodity identification code A is a character encoded by GBK, and the length of the commodity identification code A is expressed as
Figure BDA0003011689360000118
The length of the numerical sequence P is
Figure BDA0003011689360000119
The size of the combined binary matrix B is
Figure BDA00030116893600001110
and
Figure BDA00030116893600001111

(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.

Figure BDA0003011689360000121
则make
Figure BDA0003011689360000121
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),

Figure BDA0003011689360000122
Figure BDA0003011689360000122

其中,<B>表示组合二进制矩阵B中含有二进制位‘0’的个数,外部密钥满足α∈(0,1),β∈(0,1),

Figure BDA0003011689360000123
表示对某数取整且取整后的值不大于该数,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),
Figure BDA0003011689360000123
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,

Figure BDA0003011689360000124
Figure BDA0003011689360000124

得到混沌序列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与

Figure BDA0003011689360000125
的大小,若
Figure BDA0003011689360000126
则对抽取位置n按照如下所示公式进行调整,且令i=i+1,随后转向步骤S11,S12. Compare i with
Figure BDA0003011689360000125
size, if
Figure BDA0003011689360000126
Then adjust the extraction position n according to the following formula, and let i=i+1, then turn to step S11,

Figure BDA0003011689360000127
Figure BDA0003011689360000127

Figure BDA0003011689360000128
则停止操作,从而得到混沌序列
Figure BDA0003011689360000129
like
Figure BDA0003011689360000128
Then stop the operation, so as to get the chaotic sequence
Figure BDA0003011689360000129

(3)组合二进制矩阵B的置乱(3) Scrambling of the combined binary matrix B

首先,从混沌序列

Figure BDA00030116893600001210
中第1个元素开始连续抽取8个元素,得到混沌序列Y1={Y11,Y12,...,Y17,Y18}={Y1,Y2,...,Y7,Y8},同时从混沌序列
Figure BDA00030116893600001211
中第9个元素开始连续抽取
Figure BDA00030116893600001212
个元素,得到混沌序列
Figure BDA00030116893600001213
First, from the chaotic sequence
Figure BDA00030116893600001210
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
Figure BDA00030116893600001211
The 9th element in the start of continuous extraction
Figure BDA00030116893600001212
elements, get a chaotic sequence
Figure BDA00030116893600001213

然后,按照如下所示公式计算得到参数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,

Figure BDA00030116893600001214
Figure BDA00030116893600001214

当rule_select=0时,则将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵

Figure BDA00030116893600001215
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure BDA0003011689360000131
按列进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000132
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000133
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
Figure BDA00030116893600001215
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
Figure BDA0003011689360000131
Scramble by column to get a binary matrix after row and column scramble
Figure BDA0003011689360000132
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000133

Figure BDA0003011689360000134
Figure BDA0003011689360000134

当rule_select=1时,则将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵

Figure BDA0003011689360000135
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure BDA0003011689360000136
按列进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000137
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000138
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
Figure BDA0003011689360000135
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
Figure BDA0003011689360000136
Scramble by column to get a binary matrix after row and column scramble
Figure BDA0003011689360000137
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000138

Figure BDA0003011689360000141
Figure BDA0003011689360000141

当rule_select=2时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵

Figure BDA0003011689360000142
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure BDA0003011689360000143
按列进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000144
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000145
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
Figure BDA0003011689360000142
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
Figure BDA0003011689360000143
Scramble by column to get a binary matrix after row and column scramble
Figure BDA0003011689360000144
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000145

Figure BDA0003011689360000146
Figure BDA0003011689360000146

Figure BDA0003011689360000151
Figure BDA0003011689360000151

当rule_select=3时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵

Figure BDA0003011689360000152
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure BDA0003011689360000153
按列进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000154
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000155
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
Figure BDA0003011689360000152
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
Figure BDA0003011689360000153
Scramble by column to get a binary matrix after row and column scramble
Figure BDA0003011689360000154
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000155

Figure BDA0003011689360000156
Figure BDA0003011689360000156

当rule_select=4时,则将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵

Figure BDA0003011689360000157
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000158
再将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure BDA0003011689360000161
按行进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000162
其中混沌序列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
Figure BDA0003011689360000157
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000158
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.
Figure BDA0003011689360000161
Scramble by row to get a binary matrix after row and column scrambling
Figure BDA0003011689360000162
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 },

Figure BDA0003011689360000163
Figure BDA0003011689360000163

当rule_select=5时,则将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵

Figure BDA0003011689360000164
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000165
再将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure BDA0003011689360000166
按行进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000167
其中混沌序列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
Figure BDA0003011689360000164
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000165
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.
Figure BDA0003011689360000166
Scramble by row to get a binary matrix after row and column scrambling
Figure BDA0003011689360000167
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 },

Figure BDA0003011689360000168
Figure BDA0003011689360000168

Figure BDA0003011689360000171
Figure BDA0003011689360000171

当rule_select=6时,则将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵

Figure BDA0003011689360000172
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000173
再将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure BDA0003011689360000174
按行进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000175
其中混沌序列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
Figure BDA0003011689360000172
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000173
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.
Figure BDA0003011689360000174
Scramble by row to get a binary matrix after row and column scrambling
Figure BDA0003011689360000175
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 },

Figure BDA0003011689360000176
Figure BDA0003011689360000176

当rule_select=7时,则将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵

Figure BDA0003011689360000177
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure BDA0003011689360000178
再将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure BDA0003011689360000181
按行进行置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000182
其中混沌序列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
Figure BDA0003011689360000177
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure BDA0003011689360000178
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.
Figure BDA0003011689360000181
Scramble by row to get a binary matrix after row and column scrambling
Figure BDA0003011689360000182
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 },

Figure BDA0003011689360000183
Figure BDA0003011689360000183

最后,依次将行列置乱后的二进制矩阵

Figure BDA0003011689360000184
的每列元素
Figure BDA0003011689360000185
转换成数值型数据
Figure BDA0003011689360000186
其中
Figure BDA0003011689360000187
表示为
Figure BDA0003011689360000188
从而得到数值序列
Figure BDA0003011689360000189
Finally, the binary matrix after scrambling the rows and columns in turn
Figure BDA0003011689360000184
elements of each column of
Figure BDA0003011689360000185
Convert to numeric data
Figure BDA0003011689360000186
in
Figure BDA0003011689360000187
Expressed as
Figure BDA0003011689360000188
to get the sequence of numbers
Figure BDA0003011689360000189

(4)二维码的生成(4) Generation of QR code

Figure BDA00030116893600001810
Figure BDA00030116893600001810

其中,

Figure BDA00030116893600001811
表示对某数取整且取整后的值不小于该数,in,
Figure BDA00030116893600001811
Indicates that a number is rounded and the rounded value is not less than the number,

然后,依次按如下步骤进行:Then, proceed as follows in sequence:

步骤①.判断数值序列

Figure BDA00030116893600001812
的长度
Figure BDA00030116893600001813
是否小于数值H×L,Step 1. Judging the numerical sequence
Figure BDA00030116893600001812
length
Figure BDA00030116893600001813
Is it less than the value H×L,

如果是,则在数值序列

Figure BDA00030116893600001814
的尾端增补上
Figure BDA00030116893600001815
个元素,数值大小为0且最后一个元素大小为
Figure BDA00030116893600001816
得到增补后的数值序列
Figure BDA00030116893600001817
Figure BDA00030116893600001818
If yes, then in the numeric sequence
Figure BDA00030116893600001814
added to the end of
Figure BDA00030116893600001815
elements, the value size is 0 and the last element size is
Figure BDA00030116893600001816
get the appended numeric sequence
Figure BDA00030116893600001817
which is
Figure BDA00030116893600001818

如果不是,则令增补后的数值序列

Figure BDA0003011689360000191
等于数值序列
Figure BDA0003011689360000192
Figure BDA0003011689360000193
If not, then let the appended numeric sequence
Figure BDA0003011689360000191
is equal to the sequence of numbers
Figure BDA0003011689360000192
which is
Figure BDA0003011689360000193

步骤②.从表征灰度图片的矩阵M的左上角位置开始,按行且每行从左往右,依次将增补后的数值序列

Figure BDA0003011689360000194
中元素填放入矩阵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
Figure BDA0003011689360000194
The elements are filled into the matrix M, which is expressed as follows,

Figure BDA0003011689360000195
Figure BDA0003011689360000195

步骤③.将矩阵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,

Figure BDA0003011689360000196
Figure BDA0003011689360000196

将矩阵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的长度表示为

Figure BDA0003011689360000201
数值序列P的长度为
Figure BDA0003011689360000202
(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的长度表示为
Figure BDA0003011689360000201
The length of the numerical sequence P is
Figure BDA0003011689360000202

然后,依次将数值序列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,

Figure BDA0003011689360000203
Figure BDA0003011689360000203

(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,

Figure BDA0003011689360000204
则make
Figure BDA0003011689360000204
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,

Figure BDA0003011689360000205
Figure BDA0003011689360000205

然后,由混沌映射的初值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 ,...},

Figure BDA0003011689360000206
Figure BDA0003011689360000206

最后,对混沌序列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,

Figure BDA0003011689360000211
Figure BDA0003011689360000211

若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进行行置乱,得到行置乱后的二进制矩阵

Figure BDA0003011689360000212
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{2,4,6,1,7,3,5,8},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure BDA0003011689360000213
进行列置乱,得到行列置乱后的二进制矩阵
Figure BDA0003011689360000214
其中混沌序列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
Figure BDA0003011689360000212
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
Figure BDA0003011689360000213
Perform column scrambling to get the binary matrix after row and column scrambling
Figure BDA0003011689360000214
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},

Figure BDA0003011689360000215
Figure BDA0003011689360000215

Figure BDA0003011689360000221
Figure BDA0003011689360000221

最后,依次将行列置乱后的二进制矩阵

Figure BDA0003011689360000222
的每列元素
Figure BDA0003011689360000223
转换成数值型数据
Figure BDA0003011689360000224
从而得到数值序列Finally, the binary matrix after scrambling the rows and columns in turn
Figure BDA0003011689360000222
elements of each column of
Figure BDA0003011689360000223
Convert to numeric data
Figure BDA0003011689360000224
to get the sequence of numbers

Figure BDA0003011689360000225
Figure BDA0003011689360000225

Figure BDA0003011689360000226
Figure BDA0003011689360000226

(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:

步骤①.在数值序列

Figure BDA0003011689360000227
的尾端增补上5个元素,数值大小为0且最后一个元素大小为85,得到增补后的数值序列Step ①. In the numerical sequence
Figure BDA0003011689360000227
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.

Figure BDA0003011689360000228
Figure BDA0003011689360000228

Figure BDA0003011689360000229
Figure BDA0003011689360000229

步骤②.从表征灰度图片的矩阵M的左上角位置开始,按行且每行从左往右,依次将增补后的数值序列

Figure BDA00030116893600002210
中元素填放入矩阵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
Figure BDA00030116893600002210
The elements are filled into the matrix M, where the size of the matrix M is 9 × 10, which is expressed as follows,

Figure BDA00030116893600002211
Figure BDA00030116893600002211

步骤③.将矩阵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,

Figure BDA0003011689360000231
Figure BDA0003011689360000231

随后将矩阵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

Figure BDA0003011689360000232
Figure BDA0003011689360000232

Figure BDA0003011689360000241
Figure BDA0003011689360000241

Figure BDA0003011689360000251
Figure BDA0003011689360000251

Figure BDA0003011689360000261
Figure BDA0003011689360000261

实施例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

Figure BDA0003011689360000262
Figure BDA0003011689360000262

Figure BDA0003011689360000271
Figure BDA0003011689360000271

Figure BDA0003011689360000281
Figure BDA0003011689360000281

Figure BDA0003011689360000291
Figure BDA0003011689360000291

由上述具体实施例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)

1.一种基于不同置乱规则的商品防伪二维码生成方法,其特征在于,包括如下几个步骤:1. a kind of product anti-counterfeiting two-dimensional code generation method based on different scrambling rules, is characterized in that, comprises the following steps: (1)转码(1) Transcoding 首先,将表征某件商品唯一身份信息的商品标识码A,逐个字符转换为数值型数据,得到数值序列
Figure FDA0003011689350000011
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
Figure FDA0003011689350000011
然后,依次将数值序列P中元素Pi逐个转换成8bits的二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8},并将
Figure FDA0003011689350000012
个二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8}从左往右逐列填入矩阵B中,其中
Figure FDA0003011689350000013
矩阵某行对应于各二进制序列的某位,从而得到组合二进制矩阵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
Figure FDA0003011689350000012
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
Figure FDA0003011689350000013
A row of the matrix corresponds to a bit of each binary sequence, so as to obtain the combined binary matrix B,
Figure FDA0003011689350000014
Figure FDA0003011689350000014
其中商品标识码A为GBK编码的字符,商品标识码A的长度表示为
Figure FDA0003011689350000015
数值序列P的长度为
Figure FDA0003011689350000016
组合二进制矩阵B的大小为
Figure FDA0003011689350000017
Figure FDA0003011689350000018
The commodity identification code A is a character encoded by GBK, and the length of the commodity identification code A is expressed as
Figure FDA0003011689350000015
The length of the numerical sequence P is
Figure FDA0003011689350000016
The size of the combined binary matrix B is
Figure FDA0003011689350000017
and
Figure FDA0003011689350000018
(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,
Figure FDA0003011689350000019
make
Figure FDA0003011689350000019
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)
Figure FDA00030116893500000110
Figure FDA00030116893500000110
其中,<B>表示组合二进制矩阵B中含有二进制位‘0’的个数,外部密钥满足α∈(0,1),β∈(0,1),
Figure FDA00030116893500000111
表示对某数取整且取整后的值不大于该数,
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),
Figure FDA00030116893500000111
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,
Figure FDA0003011689350000021
Figure FDA0003011689350000021
得到混沌序列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与
Figure FDA0003011689350000022
的大小,若
Figure FDA0003011689350000023
则对抽取位置n按照如下公式(5)进行调整,且令i=i+1,随后转向步骤S11,
S12. Compare i with
Figure FDA0003011689350000022
size, if
Figure FDA0003011689350000023
Then adjust the extraction position n according to the following formula (5), and let i=i+1, then turn to step S11,
Figure FDA0003011689350000024
Figure FDA0003011689350000024
Figure FDA0003011689350000025
则停止操作,从而得到混沌序列
Figure FDA0003011689350000026
like
Figure FDA0003011689350000025
Then stop the operation, so as to get the chaotic sequence
Figure FDA0003011689350000026
(3)组合二进制矩阵B的置乱(3) Scrambling of the combined binary matrix B 首先,从混沌序列
Figure FDA0003011689350000027
中第1个元素开始连续抽取8个元素,得到混沌序列Y1={Y11,Y12,...,Y17,Y18}={Y1,Y2,...,Y7,Y8},同时从混沌序列
Figure FDA0003011689350000028
中第9个元素开始连续抽取
Figure FDA0003011689350000029
个元素,得到混沌序列
Figure FDA00030116893500000210
First, from the chaotic sequence
Figure FDA0003011689350000027
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
Figure FDA0003011689350000028
The 9th element in the start of continuous extraction
Figure FDA0003011689350000029
elements, get a chaotic sequence
Figure FDA00030116893500000210
然后,按照如下公式(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,
Figure FDA00030116893500000211
Figure FDA00030116893500000211
当rule_select=0时,则将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵
Figure FDA00030116893500000212
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure FDA00030116893500000213
按列进行置乱,得到行列置乱后的二进制矩阵
Figure FDA00030116893500000214
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure FDA00030116893500000215
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
Figure FDA00030116893500000212
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
Figure FDA00030116893500000213
Scramble by column to get a binary matrix after row and column scramble
Figure FDA00030116893500000214
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure FDA00030116893500000215
Figure FDA0003011689350000031
Figure FDA0003011689350000031
当rule_select=1时,则将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵
Figure FDA0003011689350000032
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure FDA0003011689350000033
按列进行置乱,得到行列置乱后的二进制矩阵
Figure FDA0003011689350000034
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure FDA0003011689350000035
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
Figure FDA0003011689350000032
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
Figure FDA0003011689350000033
Scramble by column to get a binary matrix after row and column scramble
Figure FDA0003011689350000034
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure FDA0003011689350000035
Figure FDA0003011689350000036
Figure FDA0003011689350000036
Figure FDA0003011689350000041
Figure FDA0003011689350000041
当rule_select=2时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵
Figure FDA0003011689350000042
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure FDA0003011689350000043
按列进行置乱,得到行列置乱后的二进制矩阵
Figure FDA0003011689350000044
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure FDA0003011689350000045
When rule_select=2, the chaotic sequence Y1 is sorted in ascending order, and the combined binary matrix B is scrambled 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
Figure FDA0003011689350000042
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
Figure FDA0003011689350000043
Scramble by column to get a binary matrix after row and column scramble
Figure FDA0003011689350000044
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure FDA0003011689350000045
Figure FDA0003011689350000046
Figure FDA0003011689350000046
当rule_select=3时,则将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对组合二进制矩阵B按行进行置乱,得到行置乱后的二进制矩阵
Figure FDA0003011689350000047
其中混沌序列Y1排序前、后的位置变化置乱规则可表示为{T11,T12,...,T17,T18},再将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对行置乱后的二进制矩阵
Figure FDA0003011689350000051
按列进行置乱,得到行列置乱后的二进制矩阵
Figure FDA0003011689350000052
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure FDA0003011689350000053
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
Figure FDA0003011689350000047
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
Figure FDA0003011689350000051
Scramble by column to get a binary matrix after row and column scramble
Figure FDA0003011689350000052
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure FDA0003011689350000053
Figure FDA0003011689350000054
Figure FDA0003011689350000054
当rule_select=4时,则将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵
Figure FDA0003011689350000055
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure FDA0003011689350000056
再将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure FDA0003011689350000057
按行进行置乱,得到行列置乱后的二进制矩阵
Figure FDA0003011689350000058
其中混沌序列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
Figure FDA0003011689350000055
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure FDA0003011689350000056
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.
Figure FDA0003011689350000057
Scramble by row to get a binary matrix after row and column scrambling
Figure FDA0003011689350000058
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 },
Figure FDA0003011689350000059
Figure FDA0003011689350000059
Figure FDA0003011689350000061
Figure FDA0003011689350000061
当rule_select=5时,则将混沌序列Y2按降序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵
Figure FDA0003011689350000062
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure FDA0003011689350000063
再将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure FDA0003011689350000064
按行进行置乱,得到行列置乱后的二进制矩阵
Figure FDA0003011689350000065
其中混沌序列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 a column-scrambled binary matrix
Figure FDA0003011689350000062
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure FDA0003011689350000063
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.
Figure FDA0003011689350000064
Scramble by row to get a binary matrix after row and column scrambling
Figure FDA0003011689350000065
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 },
Figure FDA0003011689350000066
Figure FDA0003011689350000066
当rule_select=6时,则将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵
Figure FDA0003011689350000067
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure FDA0003011689350000068
再将混沌序列Y1按降序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure FDA0003011689350000071
按行进行置乱,得到行列置乱后的二进制矩阵
Figure FDA0003011689350000072
其中混沌序列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 a column-scrambled binary matrix
Figure FDA0003011689350000067
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure FDA0003011689350000068
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.
Figure FDA0003011689350000071
Scramble by row to get a binary matrix after row and column scrambling
Figure FDA0003011689350000072
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 },
Figure FDA0003011689350000073
Figure FDA0003011689350000073
当rule_select=7时,则将混沌序列Y2按升序排序,根据混沌序列Y2排序前、后的位置变化置乱规则,对组合二进制矩阵B按列进行置乱,得到列置乱后的二进制矩阵
Figure FDA0003011689350000074
其中混沌序列Y2排序前、后的位置变化置乱规则可表示为
Figure FDA0003011689350000075
再将混沌序列Y1按升序排序,根据混沌序列Y1排序前、后的位置变化置乱规则,对列置乱后的二进制矩阵
Figure FDA0003011689350000076
按行进行置乱,得到行列置乱后的二进制矩阵
Figure FDA0003011689350000077
其中混沌序列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 the column-scrambled binary matrix
Figure FDA0003011689350000074
Among them, the scrambling rules of the position change before and after the chaotic sequence Y2 can be expressed as
Figure FDA0003011689350000075
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.
Figure FDA0003011689350000076
Scramble by row to get a binary matrix after row and column scrambling
Figure FDA0003011689350000077
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 },
Figure FDA0003011689350000078
Figure FDA0003011689350000078
Figure FDA0003011689350000081
Figure FDA0003011689350000081
最后,依次将行列置乱后的二进制矩阵
Figure FDA0003011689350000082
的每列元素
Figure FDA0003011689350000083
转换成数值型数据
Figure FDA0003011689350000084
其中
Figure FDA0003011689350000085
表示为
Figure FDA0003011689350000086
从而得到数值序列
Figure FDA0003011689350000087
Finally, the binary matrix after scrambling the rows and columns in turn
Figure FDA0003011689350000082
elements of each column of
Figure FDA0003011689350000083
Convert to numeric data
Figure FDA0003011689350000084
in
Figure FDA0003011689350000085
Expressed as
Figure FDA0003011689350000086
to get the sequence of numbers
Figure FDA0003011689350000087
(4)二维码的生成(4) Generation of QR code 首先,确定灰度图片的大小,令行数为H,列数为L,其中列数
Figure FDA0003011689350000088
行数H满足如下,
First, determine the size of the grayscale image, let the number of rows be H and the number of columns be L, where the number of columns
Figure FDA0003011689350000088
The number of rows H satisfies the following,
Figure FDA0003011689350000089
Figure FDA0003011689350000089
其中,
Figure FDA00030116893500000810
表示对某数取整且取整后的值不小于该数,
in,
Figure FDA00030116893500000810
Indicates that a number is rounded and the rounded value is not less than the number,
然后,按照自定义的矩阵数据填放规则,将数值序列
Figure FDA00030116893500000811
中元素依次填放入表征灰度图片的矩阵M中,从而生成灰度图片C,其中矩阵M的大小为H×L,灰度图片C的大小为30H×30L,
Then, according to the custom matrix data filling rules, the numerical sequence is
Figure FDA00030116893500000811
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.
2.根据权利要求1所述的一种基于不同置乱规则的商品防伪二维码生成方法,其特征在于:步骤(1)中所述的将表征某件商品唯一身份信息的商品标识码A,逐个字符转换为数值型数据,是指将商品标识码A中逐个字符采用unicode2native(·)函数转换为数值型数据,即对于双字节字符的转换表示为
Figure FDA00030116893500000812
对于单字节字符的转换表示为
Figure FDA00030116893500000813
从而得到数值序列
Figure FDA00030116893500000814
2. A kind of product anti-counterfeiting two-dimensional code generation method based on different scrambling rules according to claim 1, is characterized in that: described in step (1), the product identification code A that will characterize the unique identity information of a certain product , converting character-by-character into numerical data, refers to converting each character in the product identification code A into numerical data by using the unicode2native( ) function, that is, the conversion of double-byte characters is expressed as
Figure FDA00030116893500000812
The conversion for single-byte characters is expressed as
Figure FDA00030116893500000813
to get the sequence of numbers
Figure FDA00030116893500000814
3.根据权利要求1所述的一种基于不同置乱规则的商品防伪二维码生成方法,其特征在于:步骤(1)中所述的依次将数值序列P中元素Pi逐个转换成8bits的二进制序列{PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8},是指采用dec2bin(Pi,8)函数,即[PBi1,PBi2,PBi3,PBi4,PBi5,PBi6,PBi7,PBi8]=dec2bin(Pi,8)。3. a kind of product anti-counterfeiting two-dimensional code generation method based on different scrambling rules according to claim 1 is characterized in that: described in step (1) successively converts elements P i in the numerical sequence P into 8bits one by one The binary sequence {PB i1 ,PB i2 ,PB i3 ,PB i4 ,PB i5 ,PB i6 ,PB i7 ,PB i8 } refers to the use of the dec2bin(P i ,8) function, that is [PB i1 ,PB i2 ,PB i3 , PB i4 , PB i5 , PB i6 , PB i7 , PB i8 ]=dec2bin(P i ,8). 4.根据权利要求1所述的一种基于不同置乱规则的商品防伪二维码生成方法,其特征在于:步骤(4)中所述的按照自定义的矩阵数据填放规则,将数值序列
Figure FDA0003011689350000091
中元素依次填放入表征灰度图片的矩阵M中,是指按如下三个步骤进行:
4. a kind of product anti-counterfeiting two-dimensional code generation method based on different scrambling rules according to claim 1, is characterized in that: described in step (4), according to the self-defined matrix data filling rule, the numerical sequence
Figure FDA0003011689350000091
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.判断数值序列
Figure FDA0003011689350000092
的长度
Figure FDA0003011689350000093
是否小于数值H×L,
Step 1. Judge the sequence of values
Figure FDA0003011689350000092
length
Figure FDA0003011689350000093
Is it less than the value H×L,
如果是,则在数值序列
Figure FDA0003011689350000094
的尾端增补上
Figure FDA0003011689350000095
个元素,数值大小为0且最后一个元素大小为
Figure FDA0003011689350000096
得到增补后的数值序列
Figure FDA0003011689350000097
Figure FDA0003011689350000098
If yes, then in the numeric sequence
Figure FDA0003011689350000094
added to the end of
Figure FDA0003011689350000095
elements, the value size is 0 and the last element size is
Figure FDA0003011689350000096
get the appended numeric sequence
Figure FDA0003011689350000097
which is
Figure FDA0003011689350000098
如果不是,则令增补后的数值序列
Figure FDA0003011689350000099
等于数值序列
Figure FDA00030116893500000910
Figure FDA00030116893500000911
If not, then let the appended numeric sequence
Figure FDA0003011689350000099
is equal to the sequence of numbers
Figure FDA00030116893500000910
which is
Figure FDA00030116893500000911
步骤2.从表征灰度图片的矩阵M的左上角位置开始,按行且每行从左往右,依次将增补后的数值序列
Figure FDA00030116893500000912
中元素填放入矩阵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
Figure FDA00030116893500000912
The elements are filled into the matrix M, which is expressed as follows,
Figure FDA00030116893500000913
Figure FDA00030116893500000913
步骤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,
Figure FDA00030116893500000914
Figure FDA00030116893500000914
将矩阵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.
5.根据权利要求1所述的一种基于不同置乱规则的商品防伪二维码生成方法,其特征在于:步骤(4)中所述的将商品标识码A和生成的灰度图片C进行组合,是指将生成的灰度图片C与商品标识码A上下连接的组合方式,即将商品标识码A放在生成的灰度图片C正下方。5. a kind of product anti-counterfeiting two-dimensional code generation method based on different scrambling rules according to claim 1, is characterized in that: described in step (4), carry out product identification code A and the grayscale picture C that generate|occur|produce. Combination refers to a combination method in which the generated grayscale image C and the product identification code A are connected up and down, that is, the product identification code A is placed directly below the generated grayscale image C.
CN202110378301.8A 2021-04-08 2021-04-08 Commodity anti-counterfeiting two-dimensional code generation method based on different scrambling rules Pending CN113159252A (en)

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)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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

Patent Citations (6)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
Title
盛苏英等: "基于混沌的数码防伪系统研究与实现", 《微电子学与计算机》 *

Cited By (2)

* Cited by examiner, † Cited by third party
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