Background
Counterfeit products are often not fresh, and it is necessary to take action to maintain the rights of the manufacturer and the consumer. Counterfeit products pose a serious threat to various industries, particularly luxuries such as pharmaceuticals, agricultural products, automotive parts, computer software, and expensive perfumes, cosmetics, jewelry, watches, and famous costumes. The geneva international business estimates that worldwide annual sales of counterfeit products amount to $ 6,500 billion. Counterfeit drugs and wine products are particularly problematic, not only are they counterfeits, but the actions made by counterfeiters seriously jeopardize the rights and interests of consumers: the counterfeit of the medicine delays or even aggravates the illness; the things of fake wine harm to people are more frequent, the reputation of merchants and the confidence of consumers are stricken heavily, and the good establishment of economic and social orders is greatly damaged. Therefore, numerous anti-counterfeiting means are created, such as: special packaging, designing complex icons, providing a thumbnail, etc. However, these measures often result in insufficient anti-counterfeiting performance due to lack of technology, and are easy for counterfeiters to drill blanks. With the progress of the times, the anti-counterfeiting technology has great breakthrough. Such as chip technology, biotechnology, etc., but the practical operability for many fields is not great due to the characteristics of high cost, rather limited inquiry terminal, etc. Since the digital anti-counterfeiting technology is brought to the market in the middle of the 90 th century, the digital anti-counterfeiting technology is unprecedented.
The digital anti-counterfeiting combines the characteristics of anti-counterfeiting printing and digital encryption technology, one-time use authority, randomness of generated passwords, invisibility and the like, so that the anti-counterfeiting of commodities is unprecedentedly guaranteed, meanwhile, the authenticity of products can be inquired in multiple ways, and the rampant of counterfeit and shoddy products can be effectively inhibited. Meanwhile, the chaotic signal is used as a natural password and is introduced into the generation process of the commodity anti-counterfeiting code, so that the safety is higher. Under the condition, by utilizing the chaotic cipher technology, a layered encrypted commodity anti-counterfeiting code generation method is provided to generate a commodity anti-counterfeiting code with uniqueness and non-forgeability, so that the method has good practical application and popularization values.
Disclosure of Invention
The purpose of the invention is as follows: the invention aims to solve the defects in the prior art and provides a layered encrypted commodity anti-counterfeiting code generation method, which utilizes chaotic mapping to generate a chaotic signal sequence, sequentially carries out row-column scrambling and row-column scrambling on a binary matrix formed by converting commodity identification codes and combining high-low order arrangement layers, and carries out layering, grouping and recombination operations on elements in the scrambled binary matrix so as to generate a commodity anti-counterfeiting number, and then combines and generates a commodity anti-counterfeiting code, so that the layered encrypted commodity anti-counterfeiting code generation method is simple and feasible, has strong safety and is not easy to crack, and the generated commodity anti-counterfeiting code has uniqueness and non-counterfeiting property.
The technical scheme is as follows: a layered encrypted commodity anti-counterfeiting code generation method is characterized by comprising the following steps:
(1) transcoding
Firstly, a commodity identification code A representing unique identity information of a certain commodity is converted into numerical data [ P ] symbol by symboli1,Pi2]To obtain a high-order numerical sequence P1 ═ { P ═ P11,P21,...,Pi1,....,PL1And a low order value sequence P2 ═ P12,P22,...,Pi2,....,PL2},
Then, the high-order numerical sequence P1 is element by element Pi1Conversion into a binary sequence of 8bits PB1i1,PB1i2,PB1i3,PB1i4,PB1i5,PB1i6,PB1i7,PB1i8And dividing the binary data into 8 layers according to the high-low order arrangement of the binary data to obtain corresponding 8 high-order binary layered sequences, which are expressed as { PB 1}11,PB121,...,PB1i1,...,PB1(L-1)1,PB1L1}、{PB112,PB122,...,PB1i2,...,PB1(L-1)2,PB1L2}、{PB113,PB123,...,PB1i3,...,PB1(L-1)3,PB1L3}、{PB114,PB124,...,PB1i4,...,PB1(L-1)4,PB1L4}、{PB115,PB125,...,PB1i5,...,PB1(L-1)5,PB1L5}、{PB116,PB126,...,PB1i6,...,PB1(L-1)6,PB1L6}、{PB117,PB127,...,PB1i7,...,PB1(L-1)7,PB1L7}、{PB118,PB128,...,PB1i8,...,PB1(L-1)8,PB1L8},
At the same time, the low-order bit value sequence P2 is element by element Pi2Conversion into a binary sequence of 8bits PB2i1,PB2i2,PB2i3,PB2i4,PB2i5,PB2i6,PB2i7,PB2i8And dividing the binary data into 8 layers according to the high-low order arrangement of the binary data to obtain corresponding 8 low order binary layered sequences, which are expressed as { PB 2}11,PB221,...,PB2i1,...,PB2(L-1)1,PB2L1}、{PB212,PB222,...,PB2i2,...,PB2(L-1)2,PB2L2}、{PB213,PB223,...,PB2i3,...,PB2(L-1)3,PB2L3}、{PB214,PB224,...,PB2i4,...,PB2(L-1)4,PB2L4}、{PB215,PB225,...,PB2i5,...,PB2(L-1)5,PB2L5}、{PB216,PB226,...,PB2i6,...,PB2(L-1)6,PB2L6}、{PB217,PB227,...,PB2i7,...,PB2(L-1)7,PB2L7}、{PB218,PB228,...,PB1i8,...,PB2(L-1)8,PB2L8},
Finally, the 6 th to 8 th high order binary hierarchical sequences and the 4 th to 8 th low order binary hierarchical sequences are taken to be combined to form a binary matrix PB, which is expressed as follows,
the commodity identification code A comprises Chinese punctuation marks in a GB2312 character set and double-byte coded Chinese characters in the GB2312 character set, the length of the commodity identification code A is represented as L, the lengths of numerical value sequences P1 and P2 are both L, the lengths of 8 high-order binary hierarchical sequences and 8 low-order binary hierarchical sequences are both L, and the size of a binary matrix PB is 8 xL;
(2) scrambling of binary matrix PB
First, a binary sequence { PB1 obtained by converting a high-order numerical sequence P1, a low-order numerical sequence P2 and element-by-element thereofi1,PB1i2,...,PB1i8}、{PB2i1,PB2i2,…,PB2i8And respectively calculating an initial value x of the Logistic chaotic mapping according to the following formulas (1) to (5) to obtain the external keys alpha and beta1A sum parameter mu, an extraction start position m, and an extraction interval number n1、n2,
x1=0.000001+mod(α-kp1,0.999999), (1)
μ=β+mod(kp1,4-β), (2)
Wherein the content of the first and second substances,<PB1i1,...,PB1i5>=bin2dec([PB1i1,...,PB1i5]),<PB1i6,PB1i7,PB1i8>=bin2dec([PB1i6,PB1i7,PB1i8]),<PB2i1,PB2i2,PB2i3>=bin2dec([PB2i1,PB2i2,PB2i3]),<PB2i4,...,PB2i8>=bin2dec([PB2i4,...,PB2i8]) The external key satisfies α ∈ (0,1), β ∈ (3.57,4),
then, the initial value x mapped by chaos1And an external key mu, iterating the Logistic chaotic mapping shown in the following formula (6), wherein k represents iteration times (k is 1, 2), xk+1Represents the chaotic signal obtained by the k-th iteration,
xk+1=μ×xk×(1-xk) (6)
obtaining a chaotic signal sequence X ═ X1,x2,., spaced by n from the m-th element in the sequence X1Taking 1 element as an element to form a chaotic signal sequence with the length of L X1 ═ X11,X12,...,X1LN at intervals of m from the m-th element in the sequence X2Taking 1 element as an element to form a chaotic signal sequence with the length of 8, namely X2 ═ X21,X22,...,X28},
Finally, the chaotic signal sequence X1 is sorted in a descending order, and the binary matrix PB is scrambled according to the position change scrambling rule before and after the chaotic signal sequence X1 is sorted, so that a binary matrix after column scrambling is obtained
Then the chaotic signal sequence X2 is sorted according to the descending order, the binary matrix after the column scrambling is carried out according to the position change scrambling rule before and after the chaotic signal sequence X2 is sorted
Scrambling according to rows to obtain a scrambled binary matrix
As shown below, the following description is given,
(3) binary matrix after scrambling
Layering, grouping, reassembling of
First, the binary matrix after scrambling is aligned
Layering by rows to obtain corresponding 8 binary layered sequences, represented as
Then, 1 element is sequentially extracted from the 8 binary hierarchical sequences in parallel in the forward direction for grouping to obtain grouped binary hierarchical sequences, which are represented as BF1{1}, BF1{2},. 9, BF1{ i },. BF1{ L }, and BF2{1}, BF2{2},. 9, BF2{ i },. BF2{ L }, wherein,
next, each of the grouped binary hierarchical sequences BF1{ i } and BF2{ i }, where i is 1,2, 3.
Let tmp1{ i } -, dec2bin (bin2dec ([ PB 1) ]
i1,PB1
i2,PB1
i3,PB1
i4,PB1
i5]) +2, 5), the most significant of the binary hierarchical sequence BF1{ i } after groupingThe preamble is preceded by a binary sequence tmp1{ i }, denoted as
Wherein the bin2dec (-) function represents the conversion of the binary sequence into the numerical data, and the dec2bin (-) function represents the conversion of the numerical data into the binary sequence,
meanwhile, tmp2{ i } - { PB 2} is given
i1,PB2
i2,PB2
i3The forefront of the grouped binary hierarchical sequence BF2{ i } is added with a binary sequence tmp2{ i } which is represented as
Thereby obtaining a binary recombination sequence represented by
And
finally, each binary recombination sequence is sequenced using the bin2dec (-) function
Conversion into numerical data
Simultaneously sequentially recombining each binary recombination sequence
Conversion into numerical data
Wherein i is 1,2, 3.., L, resulting in a sequence of values
And
(4) transcoding
Sequence of values
And
and combining the corresponding elements in sequence, converting numerical values and Chinese characters to obtain a Chinese character sequence C, namely the commodity anti-counterfeiting number, wherein the length of the Chinese character sequence C is L, and combining the commodity identification code A and the commodity anti-counterfeiting number to generate the commodity anti-counterfeiting code.
Further, in the layered encryption commodity anti-counterfeiting code generation method, the commodity identification code A representing the unique identity information of a certain commodity in the step (1) is converted into numerical data [ P ] symbol by symboli1,Pi2]It is to convert symbols in the commodity identification code A into numerical data by adopting unicode2native () function, namely [ P ]i1,Pi2]=unicode2native(Ai) So as to obtain a high-order numerical value sequence P1 ═ { P ═ P11,P21,...,Pi1,....,PL1And a low order value sequence P2 ═ P12,P22,...,Pi2,....,PL2}。
Furthermore, in the layered encryption commodity anti-counterfeiting code generation method, the numerical value sequence in the step (4)
And
corresponding elements are combined in sequence and the conversion between numerical values and Chinese characters is carried out, which means that numerical value sequences are combined
And
each corresponding element in (a) is combined, i.e.
And the following operations are sequentially carried out, and a Chinese character sequence C ═ 2 is set],
If it is not
Adding 1 Chinese space symbol to the Chinese character sequence C, i.e. C ═ C, native2unidoce ([161, 161)])]Wherein the Chinese space symbol can be native2unidoce ([161, 161)]) Show, at the same time order
If it is not
Adding 1 Chinese symbol' to the Chinese character sequence C, i.e. C ═ C, native2 unidococce ([161,164])]Wherein the Chinese symbol 'cna' can use native2unicode ([161,164)]) Show, at the same time order
If it is not
Then add 1 Chinese symbol' to the Kanji sequence C, i.e. C ═ C, native2unicode ([163,172 ]])]Wherein the Chinese symbol' available native2 unidocene ([163,172)]) Show, at the same time order
If it is not
And is
Adding 1 Chinese symbol to the Chinese character sequence C', i.e. C ═ C, native2unicode ([161, 162)])]Wherein the Chinese symbols 'and' available native2unidoce ([161, 162)]) Show, at the same time order
Then using native2unicode (·) function to convert numerical data
Converted into Chinese characters and added to the Chinese character sequence C, i.e.
The steps are cycled until the numerical value sequence
And
the last 1 corresponding element in (i.e. 1)
Thereby obtaining the Chinese character sequence C, namely the commodity anti-counterfeiting number.
Further, in the method for generating the layered encrypted anti-counterfeiting code for the commodity, the commodity identification code A and the anti-counterfeiting number are combined to generate the anti-counterfeiting code in the step (4), which means that the commodity identification code A and the anti-counterfeiting number are directly connected in sequence, or directly connected in reverse order, or connected in spaced insertion order.
Has the advantages that: the chaos signal sequence is generated by utilizing chaos mapping, the binary matrix formed by converting the commodity identification code and arranging and combining the high and low order is sequentially subjected to line and row scrambling, elements in the scrambled binary matrix are subjected to layering, grouping and recombination operations, so that the commodity anti-counterfeiting number is generated, and then the commodity anti-counterfeiting code is generated by combination, so that the method for generating the commodity anti-counterfeiting code by the layered encryption is simple and feasible, has strong safety and is not easy to crack, and the generated commodity anti-counterfeiting code has uniqueness and non-counterfeiting property.
Detailed Description
As shown in fig. 1, a method for generating a layered encrypted merchandise anti-counterfeit code includes the following steps:
(1) transcoding
Firstly, a commodity identification code A representing the unique identity information of a certain commodity is converted into numerical data, namely [ P ] by adopting a unicode2native () function one by one symboli1,Pi2]=unicode2native(Ai) To obtain a high-order numerical sequence P1 ═ { P ═ P11,P21,...,Pi1,....,PL1And a low order value sequence P2 ═ P12,P22,...,Pi2,....,PL2},
Then, the high-order numerical sequence P1 is element by element Pi1Conversion into a binary sequence of 8bits PB1i1,PB1i2,PB1i3,PB1i4,PB1i5,PB1i6,PB1i7,PB1i8And dividing the binary data into 8 layers according to the high-low order arrangement of the binary data to obtain corresponding 8 high-order binary layered sequences, which are expressed as { PB 1}11,PB121,...,PB1i1,...,PB1(L-1)1,PB1L1}、{PB112,PB122,...,PB1i2,...,PB1(L-1)2,PB1L2}、{PB113,PB123,...,PB1i3,...,PB1(L-1)3,PB1L3}、{PB114,PB124,...,PB1i4,...,PB1(L-1)4,PB1L4}、{PB115,PB125,...,PB1i5,...,PB1(L-1)5,PB1L5}、{PB116,PB126,...,PB1i6,...,PB1(L-1)6,PB1L6}、{PB117,PB127,...,PB1i7,...,PB1(L-1)7,PB1L7}、{PB118,PB128,...,PB1i8,...,PB1(L-1)8,PB1L8},
At the same time, the low-order bit value sequence P2 is element by element Pi2Conversion into a binary sequence of 8bits PB2i1,PB2i2,PB2i3,PB2i4,PB2i5,PB2i6,PB2i7,PB2i8And dividing the binary data into 8 layers according to the high-low order arrangement of the binary data to obtain corresponding 8 low order binary layered sequences, which are expressed as { PB 2}11,PB221,...,PB2i1,...,PB2(L-1)1,PB2L1}、{PB212,PB222,...,PB2i2,...,PB2(L-1)2,PB2L2}、{PB213,PB223,...,PB2i3,...,PB2(L-1)3,PB2L3}、{PB214,PB224,...,PB2i4,...,PB2(L-1)4,PB2L4}、{PB215,PB225,...,PB2i5,...,PB2(L-1)5,PB2L5}、{PB216,PB226,...,PB2i6,...,PB2(L-1)6,PB2L6}、{PB217,PB227,...,PB2i7,...,PB2(L-1)7,PB2L7}、{PB218,PB228,...,PB1i8,...,PB2(L-1)8,PB2L8},
Finally, the 6 th to 8 th high order binary hierarchical sequences and the 4 th to 8 th low order binary hierarchical sequences are taken to be combined to form a binary matrix PB, which is expressed as follows,
the commodity identification code A comprises Chinese punctuation marks in a GB2312 character set and double-byte coded Chinese characters in the GB2312 character set, the length of the commodity identification code A is represented as L, the lengths of numerical value sequences P1 and P2 are both L, the lengths of 8 high-order binary hierarchical sequences and 8 low-order binary hierarchical sequences are both L, and the size of a binary matrix PB is 8 xL;
(2) scrambling of binary matrix PB
First, a binary sequence { PB1 obtained by converting a high-order numerical sequence P1, a low-order numerical sequence P2 and element-by-element thereofi1,PB1i2,...,PB1i8}、{PB2i1,PB2i2,…,PB2i8And respectively calculating an initial value x of the Logistic chaotic mapping according to the following formula1A sum parameter mu, an extraction start position m, and an extraction interval number n1、n2,
x1=0.000001+mod(α-kp1,0.999999),
μ=β+mod(kp1,4-β),
Wherein the content of the first and second substances,<PB1i1,...,PB1i5>=bin2dec([PB1i1,...,PB1i5]),<PB1i6,PB1i7,PB1i8>=bin2dec([PB1i6,PB1i7,PB1i8]),<PB2i1,PB2i2,PB2i3>=bin2dec([PB2i1,PB2i2,PB2i3]),<PB2i4,...,PB2i8>=bin2dec([PB2i4,...,PB2i8]) The external key satisfies α ∈ (0,1), β ∈ (3.57,4),
then, the initial value x mapped by chaos1And an external key mu, and iterating the Logistic chaotic mapping shown in the following formula, wherein k represents iteration times (k is 1,2, and.) and xk+1Represents the chaotic signal obtained by the k-th iteration,
xk+1=μ×xk×(1-xk)
obtaining a chaotic signal sequence X ═ X1,x2,., spaced by n from the m-th element in the sequence X1Taking 1 element as an element to form a chaotic signal sequence with the length of L X1 ═ X11,X12,...,X1LN at intervals of m from the m-th element in the sequence X2Taking 1 element as an element to form a chaotic signal sequence with the length of 8, namely X2 ═ X21,X22,...,X28},
Finally, the chaotic signal sequence X1 is sorted in a descending order, and the binary matrix PB is scrambled according to the position change scrambling rule before and after the chaotic signal sequence X1 is sorted, so that a binary matrix after column scrambling is obtained
Then the chaotic signal sequence X2 is sorted according to the descending order, the binary matrix after the column scrambling is carried out according to the position change scrambling rule before and after the chaotic signal sequence X2 is sorted
Scrambling according to rows to obtain a scrambled binary matrix
As shown below, the following description is given,
(3) binary matrix after scrambling
Layering, grouping, reassembling of
First, the binary matrix after scrambling is aligned
Layering by rows to obtain corresponding 8 binary layered sequences, represented as
Then, 1 element is sequentially extracted from the 8 binary hierarchical sequences in parallel in the forward direction for grouping to obtain grouped binary hierarchical sequences, which are represented as BF1{1}, BF1{2},..,. BF1{ i },. BF1{ L }, and BF2{1}, BF2{2},..,. BF2{ i },. BF2{ L }, wherein the grouped binary hierarchical sequences are expressed as BF1{1}, BF1{2},..,
next, each of the grouped binary hierarchical sequences BF1{ i } and BF2{ i }, where i is 1,2, 3.
Let tmp1{ i } -, dec2bin (bin2dec ([ PB 1) ]
i1,PB1
i2,PB1
i3,PB1
i4,PB1
i5]) +2, 5), the forefront of the grouped binary hierarchical sequence BF1{ i } is added with the binary sequence tmp1{ i }, denoted as
Wherein the bin2dec (-) function represents the conversion of the binary sequence into the numerical data, and the dec2bin (-) function represents the conversion of the numerical data into the binary sequence,
meanwhile, tmp2{ i } - { PB 2} is given
i1,PB2
i2,PB2
i3The forefront of the grouped binary hierarchical sequence BF2{ i } is added with a binary sequence tmp2{ i } which is represented as
Thereby obtaining a binary recombination sequence represented by
And
finally, each binary recombination sequence is sequenced using the bin2dec (-) function
Conversion into numerical data
Simultaneously sequentially recombining each binary recombination sequence
Conversion into numerical data
Wherein i is 1,2, 3.., L, resulting in a sequence of values
And
(4) transcoding
Sequence of values
And
corresponding elements are combined in sequence and the conversion between numerical values and Chinese characters is carried out, namely numerical value sequence
And
each corresponding element in (1) is combined to representIs composed of
And the following operations are sequentially carried out, and a Chinese character sequence C ═ 2 is set],
If it is not
Adding 1 Chinese space symbol to the Chinese character sequence C, i.e. C ═ C, native2unidoce ([161, 161)])]Wherein the Chinese space symbol can be native2unidoce ([161, 161)]) Show, at the same time order
If it is not
Adding 1 Chinese symbol' to the Chinese character sequence C, i.e. C ═ C, native2 unidococce ([161,164])]Wherein the Chinese symbol 'cna' can use native2unicode ([161,164)]) Show, at the same time order
If it is not
Then add 1 Chinese symbol' to the Kanji sequence C, i.e. C ═ C, native2unicode ([163,172 ]])]Wherein the Chinese symbol' available native2 unidocene ([163,172)]) Show, at the same time order
If it is not
And is
Then add 1 Chinese symbol 'and', i.e. C ═ C, native2unicode ([161, 162)])]Wherein the Chinese symbols 'and' available native2unidoce ([161, 162)]) Show, at the same time order
Then using native2unicode (·) function to convert numerical data
Converted into Chinese characters and added to the Chinese character sequence C, i.e.
The steps are cycled until the numerical value sequence
And
the last 1 corresponding element in (i.e. 1)
And then combining the commodity identification code A and the commodity anti-counterfeiting number in a combination mode of direct sequential connection, direct reverse sequential connection or interval insertion sequential connection, thereby generating the commodity anti-counterfeiting code.
The invention is further illustrated by the following specific examples:
example 1
The method for generating the commodity anti-counterfeiting code by hierarchical encryption comprises the following steps:
(1) firstly, a product identification code A which represents the unique identity information of a certain product is converted into numerical data one by one according to a product production date 2020-02-01 production line 12 serial number 123456 to obtain a high-order value sequence P1 ═ 189,203,202,163,163,188,205,161,161,215,185,203,161,163,163,201,198,161,201,178,200,198,163,163,163,163,163,163,163,163,163,163,161,201,178,207,163,163,208,193,186,163,163,163,163,163,163 and a low-order value sequence P2 ═ 173,213,161,163,163,175,197,193,193,211,171,190,161,192,192,204,183,161,250,250,213,218,178,176,178,176,173,176,178,173,176,177,161,250,250,223,177,178,242,208,197,177,178,179,180,181,182.
Then, the high-order bit value sequence P1 is converted into binary sequences of 8bits one by one, and is divided into 8 layers according to the high-order and low-order bit arrangement of binary data, so as to obtain 8 high-order binary hierarchical sequences, which are {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1}, {0,1,1,0,0,0,1,0, 1,0,1,0,0,0,0,0,0,0,0,0,0,0, 1,0,0,1,1,1,0,1,1, 1,1,1,1,1,1,1,1,1,0,1,0,1,1, 1,1,0,0,1,1,1,1,1,1,1}, {1,0,0,0,0, 0,0,1,1,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0,0,0,0,0,0,1,0, 0,0,0,0,0}, {1,0,0,0,0, 0,1,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0, 0}, {0,1,1,1,1,0,0,0,0, 0,1,0,1,1,1,1,1,1,1,1,1,1,1,0, 1,0,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1},
meanwhile, the low-order bit value sequence P2 is converted into a binary sequence of 8bits element by element, and is divided into 8 layers according to the high-order and low-order bit arrangement of binary data, so as to obtain 8 low-order binary hierarchical sequences, which are {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1}, {0,1,0,0,0,0,0,0, 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,0,0,0,0,0,0,0,1,0,1, 1,1,0,0,0,1,1,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1, 1}, {0,1,0,0,0,0,0,0,0,1, 1,0,0,1,0,1,1,1,1,1,1, 0,1,1,0,1,0,1,1,1, 1,1,1,1,0,0,0,0,1,0, 0,1,0,0,0,0,0,1, 1,1,0,0,0,0,0,0,0,0,0, 0}, {1,1,0,0,0,1, 0,0,0,0,0,1,0,0,1,0,0, 1,1,0,0,0,1,0,0,0,0,0, 0,0,0,0,0,0,1,0,0, 1,1,1}, {0,0,1,1, 0,0,0,0,1,0,1,1,0, 0,0,1,0,1,0,0,1, 0,1,1,1,1,0,0,0,1,1,1, 1,0,1,1,0,1,0,1,0,0,0,0,0,1,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1,0,1,0,1,0},
finally, the 6 th to 8 th high order binary hierarchical sequences and the 4 th to 8 th low order binary hierarchical sequences are taken to be combined to form a binary matrix PB, which is expressed as follows,
the length of the Chinese character commodity identification code A is L-47, the length of each of the numerical value sequences P1 and P2 is L-47, the length of each of the 8 high-order binary hierarchical sequences and the 8 low-order binary hierarchical sequences is L-47, and the size of the binary matrix PB is 8 multiplied by L-8 multiplied by 47;
(2) scrambling of binary matrix PB
First, a binary sequence { PB1 obtained by converting a high-order numerical sequence P1, a low-order numerical sequence P2 and element-by-element thereofi1,PB1i2,...,PB1i8}、{PB2i1,PB2i2,…,PB2i80.12345 and 3.75 external keys alpha and beta, respectively calculating to obtain initial values x of the Logistic chaotic map according to the following formulas1A sum parameter mu, an extraction start position m, and an extraction interval number n1、n2,
x1=0.000001+mod(0.12345-0.007699460349288,0.999999)=0.115751539650712,
μ=3.75+mod(0.007699460349288,4-3.75)=3.757699460349288,
Then, the initial value x mapped by chaos10.115751539650712 and 3.757699460349288 of an external key mu, iterating the Logistic chaotic mapping to obtain a chaotic signal sequence X { X ═ X }1,x2,., taking 1 element from the 557th element in the sequence X at intervals of 28 elements in turn to form a chaotic signal sequence X1 with the length of 47 ═ X11,X12,...,X147And simultaneously, 1 element is taken out at 31 elements in sequence from the 557 th element in the sequence X to form a chaotic signal sequence X2 with the length of 8 ═ X21,X22,...,X28},
Finally, the chaotic signal sequence X1 is sorted in a descending order, and the binary matrix PB is scrambled according to the position change scrambling rule before and after the chaotic signal sequence X1 is sorted, so that a binary matrix after column scrambling is obtained
Then the chaotic signal sequence X2 is sorted according to the descending order, the binary matrix after the column scrambling is carried out according to the position change scrambling rule before and after the chaotic signal sequence X2 is sorted
Scrambling according to rows to obtain a scrambled binary matrix
As shown below, the following description is given,
(3) binary moments after scrambling
Layering, grouping, reassembling of
First, the binary matrix after scrambling is aligned
Layering by rows to obtain corresponding 8 binary layered sequences, represented as
Then, 1 element is sequentially extracted in parallel from the 8 binary hierarchical sequences in the forward direction, and the binary hierarchical sequences are grouped, and expressed as BF1{1} {1,1,0}, BF1{2} {0, 0}, …, BF1{23} {0,1,0}, …, BF1{46} {1,0,0}, BF1{47} {1,0,1}, BF2{1} {1,0,1,0,0}, BF2{2}, 0,0,1,1,1}, …, BF2{23} {0,0,1,0,0}, …, BF2{46} {0,0,1,0,0}, BF 56 {47}, 1,0,0,0,1,1, 0}, and BF2{47}, 1,0,0,0,1, 1}, 0}, and 1}, which are grouped in parallel to obtain a grouped binary hierarchical sequence.
Next, each of the grouped binary hierarchical sequences BF1{ i } and BF2{ i }, where i is 1,2, 3.
Let tmp1{ i } -, dec2bin (bin2dec ([ PB 1) ]
i1,PB1
i2,PB1
i3,PB1
i4,PB1
i5]) +2, 5), the forefront of the grouped binary hierarchical sequence BF1{ i } is added with the binary sequence tmp1{ i }, denoted as
Meanwhile, tmp2{ i } - { PB 2} is given
i1,PB2
i2,PB2
i3The forefront of the grouped binary hierarchical sequence BF2{ i } is added with a binary sequence tmp2{ i } which is represented as
Thereby obtaining a binary recombination sequence represented by
And
finally, each binary recombination sequence is sequenced using the bin2dec (-) function
Conversion into numerical data
Simultaneously sequentially recombining each binary recombination sequence
Conversion into numerical data
Thereby obtaining a numerical sequence
And
(4)sequence of values
And
the corresponding elements are combined in sequence and the numerical values and the Chinese characters are converted to obtain a commodity anti-counterfeiting code, namely' green top primary green bottom green boy material to milling meditation bordoides success and oblique morbid graulis baumi disease stir-frying the green top green house young boy flower bud hillock paint and the specific green top green house young boy flower bud revolve and the specific green house young Dong flower bud horse paint and the specific green house young boy flower bud tomato pig bud hillock paint, the commodity identification code A and the commodity anti-counterfeiting code are combined in a combination mode of direct sequence connection, direct reverse sequence connection or interval insertion sequence connection, the generated commodity anti-counterfeiting codes are respectively as follows,
direct sequential connection: "Jiangsu # # group x sub company @ commercial production date 2020-02-01 production line 12 serial No. 123456 not terminal nor,
direct reverse order connection: "when the vegetal Dong Yang Geng horse ding Zhongyou paint hillock sparging Tung house tasted the vegetal Dong Tung and the diseased money and the grazing Du slope of the vegetal Tung Di Huang milling to the Tung Di Yun not Yao 654321 line produces the 10-20-0202-day product, the vegetal Shang Yang X collection # # Sujiang province),
interval insertion connection: "Yun Chi Yun Cheng Yun Zhi # primary collection not Do Jia XmaZi to milling Dai Yao @ Tibi @ Di @ success maker product oblique Du gracilaria production wedge period confronted 2 pineapple 0 money 2 disease 0 stir-frying-Dong 0 tip 2 taste-0 house 1 Dong Fang and hillock paint production line Zhi 1 bank and 2 Ling 2 Tung 4 Tung 6 as 2 Ding sequence horse list revolve 1 Dong 4 Tung 6.
Example 2
According to the method for generating the layered encrypted commodity anti-counterfeiting code, the commodity identification code character string A of a certain commodity and the commodity anti-counterfeiting code generation steps are similar to those of the specific embodiment 1, and only a certain external secret key slightly changes: 0.12345000000001; or β 3.74999999999999, the generation of the commercial anti-counterfeiting code is shown in table 1. As can be seen from the following table: even if the external key slightly changes, the generated commodity anti-counterfeiting number and the commodity anti-counterfeiting code greatly change, so that the method for generating the commodity anti-counterfeiting code by hierarchical encryption has key sensitivity.
TABLE 1 Generation result of merchandise anti-counterfeit code when external secret key is slightly changed
Example 3
According to the above-mentioned commodity anti-counterfeit code generation method of layered encryption, the steps of generating the external secret key and the commodity anti-counterfeit code thereof are similar to those of the specific embodiment 1, only the commodity identification code character string A of a certain commodity has slight change 'Gang Suzhou # # group x a subsidiary company @ commodity production date 2020-02-01 production line 12 serial number 123456'; or "Jiangsu province # # group x son company @ brand product production date 2020-12-01 production line 12 serial No. 123456"; or "Jiangsu province # # group x son company @ commercial production date 2020-02-01 production line 12 serial number 123459", the production results of the commercial anti-counterfeiting code are shown in Table 2. As can be seen from the following table: once the commodity identification code character string representing the unique identification information of a certain commodity slightly changes, the generated commodity anti-counterfeiting number and the commodity anti-counterfeiting code can greatly change, so that the layered encrypted commodity anti-counterfeiting code generation method provided by the patent has sensitivity to the commodity identification information (namely the commodity identification code character string).
TABLE 2 Generation result of commodity anti-counterfeit code when commodity identification code is slightly changed
It can be seen from the above specific embodiments 2 and 3 that the anti-counterfeit code generated by the method for generating a layered encrypted anti-counterfeit code for a commodity provided by the present patent is not only closely related to an external secret key, but also depends on a commodity identification code character string representing unique identity information of a certain commodity, so that the method for generating a layered encrypted anti-counterfeit code for a commodity provided by the present patent has strong security, can better resist known/selected plaintext attacks, is not easy to crack, and ensures that the generated anti-counterfeit code for a commodity has "uniqueness" and "non-forgeability".
Although the present invention has been described with reference to a preferred embodiment, it should be understood that various changes, substitutions and alterations can be made herein without departing from the spirit and scope of the invention as defined by the appended claims.