Method, system, device and storage medium for generating anti-counterfeiting code from product number
By performing AES encryption and array merging operations on the product's unique number and serial number, and combining it with a full-code conversion algorithm to generate an anti-counterfeiting code, the problem of insufficient encryption strength in the existing technology is solved, and the generation of anti-counterfeiting codes with high encryption strength and difficulty in cracking is achieved.
Patent Information
- Application Number
- CN202210472506.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2042-04-29
AI Technical Summary
Existing anti-counterfeiting code encryption generation algorithms have problems such as insufficient encryption strength and low efficiency, which makes the anti-counterfeiting code easy to crack and difficult to ensure uniqueness and unforgeability.
The AES encryption algorithm is used to encrypt the product's unique number and serial number, and the anti-counterfeiting code is generated through array merging and full-code conversion algorithms. The product's unique number and serial number are used to reset the plaintext and key, and complex operations are performed on multiple arrays to generate the anti-counterfeiting code.
The encryption strength of the anti-counterfeiting code is improved, making it extremely difficult to crack and ensuring the uniqueness and unforgeability of the anti-counterfeiting code.
Smart Images

Figure CN114861237B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method, system, device and storage medium for generating an anti-counterfeiting code from a product number, and belongs to the technical field of methods for generating anti-counterfeiting codes. Background Art
[0002] The problem of product counterfeiting is a long-standing one. While many companies have made significant efforts to prevent and combat counterfeiting, achieving some success, counterfeit and inferior products continue to persist. To regulate market order and prevent counterfeit and inferior goods from impacting product prices, damaging product image, undermining product credibility, and disrupting the market, manufacturers often print anti-counterfeiting codes on their products.
[0003] At present, anti-counterfeiting code encryption generation algorithms emerge in an endless stream, but most encryption generation algorithms have problems such as insufficient encryption strength and low algorithm efficiency. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to overcome the deficiencies of the prior art and provide a method, system, device and storage medium for generating an anti-counterfeiting code from a product number, which has the characteristics of high encryption strength and is not easy to crack.
[0005] The method for generating an anti-counterfeiting code from a product number of the present invention comprises the following steps:
[0006] Step S1: Generate a unique number P for the product number according to a predetermined rule, and take a value N for the product sequence number within a predetermined length range;
[0007] Step S2: Perform AES encryption on the product number P and product serial number N according to the predetermined plaintext M1, plaintext M2, and key, and obtain the authentication code after taking the modulus algorithm;
[0008] Step S3: combining the product number, product serial number and authentication code into a plain code;
[0009] Step S4, performing a full code conversion algorithm on the plain code according to the predetermined one-dimensional array key, the two-dimensional array cv, and the 10*10 two-dimensional arrays la0, la1, la2, la3, la4, la5, la6, and la7 to obtain an anti-counterfeiting code array;
[0010] Step S5: convert the anti-counterfeiting code array into a fixed-base character string to obtain an anti-counterfeiting code.
[0011] First, the product's unique number and serial number are encrypted sequentially using the AES algorithm. The plaintext and key used in the AES encryption algorithm are reset using the product's unique number and serial number. The AES encryption result is combined with the product's unique number and serial number in an array operation to generate a plaintext. The plaintext is then subjected to a full-code conversion algorithm based on a predetermined number of arrays to generate the anti-counterfeiting code. Therefore, compared to other anti-counterfeiting code encryption generation algorithms, the generation method of the present invention has the characteristics of high encryption strength and extreme difficulty in cracking, thereby ensuring the uniqueness and unforgeability of the anti-counterfeiting code.
[0012] In step S3, the plain code is generated by performing an array merging operation on the product number array, the product sequence number array, and the authentication code.
[0013] Preferably, the AES encryption operation in step S2 includes the following steps:
[0014] Step S2-1, converting the product number P into a hexadecimal product number array, and converting the product sequence number N into a hexadecimal product sequence number array;
[0015] Step S2-2, iteratively replace the 1st, 3rd, ..., 2*Pn-1th bit data in the plaintext M1 according to the product number array to obtain plaintext M1-1;
[0016] Step S2-3, iteratively replacing the 3rd, 6th, ..., 3*Pn bits of data in the key according to the product number array to obtain a new key;
[0017] Step S2-4: Perform AES encryption based on the plaintext M1-1 and the new key to obtain a first operation value;
[0018] Step S2-5, iteratively replace the 0th, 2nd, ..., 2*Sn-2th bit data in the plaintext M2 according to the product sequence number array to obtain plaintext M2-1;
[0019] Step S2-6: Perform AES encryption on the plaintext M2-1 and the first operation value to obtain a second operation value.
[0020] It is used to reset the plaintext and key used in the AES encryption algorithm, the unique product number, and the product serial number.
[0021] Preferably, the modulo algorithm in step S2 comprises the following steps:
[0022] Step S2-7, performing a modulo 10 operation on the second operation value to obtain a third operation value;
[0023] Step S2-8, taking the 0th bit of the third operation value to obtain n1;
[0024] Step S2-9, summing the third operation value from the 1st bit to the n1+1th bit to obtain a fourth operation value;
[0025] Step S2-10, performing a modulo 10 operation on the fourth operation value to obtain n2;
[0026] Step S2-11, sum the third operation value from the n1+2th bit to the 15th bit to obtain the fifth operation value;
[0027] Step S2-12, performing a modulo 10 operation on the fifth operation value to obtain n3;
[0028] Step S2-13: Combine the n1, n2, and n3 into an array to obtain the authentication code.
[0029] Preferably, the full code conversion algorithm in step S4 includes the following steps:
[0030] Step S4-1, cyclically assign values to the one-dimensional array key bit by bit to obtain a one-dimensional array k; cyclically assign values to the plaintext bit by bit to obtain a one-dimensional array X;
[0031] Step S4-2, performing 14 iterative operations on the one-dimensional array k and the one-dimensional array X to obtain a one-dimensional array X1;
[0032] Step S4-3: Shift the one-dimensional array X1 left by 8 bits to obtain an anti-counterfeiting code array.
[0033] Preferably, a single iterative operation in the 14 iterative operations in step S4-2 includes the following steps:
[0034] Step S4-21, performing eight iterations of value assignment operations on the one-dimensional array k and the one-dimensional array X to obtain a one-dimensional array Zh;
[0035] Step S4-22, performing an 8-bit left shift operation on the one-dimensional array X, and assigning the first 8 bits of the one-dimensional array Zh to the last 8 bits of the one-dimensional array X to obtain the one-dimensional array X1;
[0036] Step S4-23: right-shift the one-dimensional array k by 1 bit to enter the next round of iteration.
[0037] The anti-counterfeiting code can be obtained by performing a full code conversion algorithm on the plain code according to a predetermined plurality of arrays.
[0038] Preferably, the eight iterations of the assignment operation include the following steps:
[0039] Step S4-211, take the data in the nth row and the 0th column of the two-dimensional array cv to obtain t1, take the data in the nth row and the 1st column of the two-dimensional array cv to obtain t2, take the data in the t1th position of the one-dimensional array X to obtain Xu, and take the data in the t2th position of the one-dimensional array X to obtain Xw;
[0040] Step S4-212, summing Xu with the n-th bit of the one-dimensional array k, and performing a modulo 10 operation on the sum of the results to obtain Gu;
[0041] Step S4-213, sum Xw with the n+8th bit of the one-dimensional array k, and perform a modulo 10 operation on the result to obtain Qu; obtain the data of the Guth row and Quth column of the two-dimensional code array la(n) to obtain Yu;
[0042] Step S4-214: sum Yu with the nth bit of the one-dimensional array X, perform modulo 10 operation on the result, and obtain YuX1; assign YuX1 to the nth bit of the one-dimensional array Zh, and enter the next round of iteration.
[0043] It is used to perform eight value assignment iterative operations on the one-dimensional array k and the one-dimensional array X to obtain a one-dimensional array Zh.
[0044] Preferably, the product number P in step S1 is Pn, which includes the numeric characters '0' to '9'; the product serial number N is Sn, which includes the numeric characters '0' to '9'.
[0045] Used to generate product number P and product sequence number N.
[0046] The system for generating anti-counterfeiting codes from product numbers of the present invention comprises a character string generation module, an authentication code generation module, a plain code generation module, an anti-counterfeiting code array generation module, and an anti-counterfeiting code generation module, and uses the above-mentioned method for generating anti-counterfeiting codes from product numbers to generate anti-counterfeiting codes;
[0047] String generation module: used to generate a unique number P for the product number according to a predetermined rule, and to take a value N for the product sequence number within a predetermined length range;
[0048] Authentication code generation module: used to perform AES encryption operation on product number P and product serial number N according to the predetermined plain text M1, plain text M2 and key, and obtain the authentication code after taking the modulus algorithm;
[0049] A plain code generation module: used to combine the product number, product serial number and authentication code into a plain code;
[0050] The anti-counterfeiting code array generation module is used to perform a full code conversion algorithm on the plain code according to the predetermined one-dimensional array key, the two-dimensional array cv, and the 10*10 two-dimensional arrays la0, la1, la2, la3, la4, la5, la6, and la7 to obtain the anti-counterfeiting code array;
[0051] The anti-counterfeiting code generating module is used to convert the anti-counterfeiting code array into a fixed-base character string to obtain the anti-counterfeiting code.
[0052] The AES algorithm is used to encrypt the product's unique number and serial number. The plaintext and key used in the AES encryption algorithm are reset using the product's unique number and serial number. The AES encryption result is combined with the product's unique number and serial number in an array operation to generate a plaintext. The plaintext is then converted to a full-code format using a predefined array of multiple arrays to generate the anti-counterfeiting code. Therefore, compared to other anti-counterfeiting code encryption generation systems, the generation system of the present invention boasts high encryption strength and is extremely difficult to crack, ensuring the uniqueness and unforgeability of the anti-counterfeiting code.
[0053] The device for generating anti-counterfeiting codes from product numbers of the present invention includes a memory and a processor.
[0054] Memory: used to store computer programs;
[0055] Processor: used to implement the steps of the above-mentioned method of generating an anti-counterfeiting code from a product number when executing the computer program.
[0056] The computer-readable storage medium of the present invention stores a computer program, and when the computer program is executed by a processor, the steps of the method for generating an anti-counterfeiting code from a product number are implemented.
[0057] Compared with the prior art, the present invention has the following beneficial effects:
[0058] The method for generating an anti-counterfeiting code from a product number of the present invention first sequentially encrypts the product's unique number and product serial number using the AES algorithm. The plaintext and key used in the AES encryption algorithm are reset using the product's unique number and product serial number. The AES encryption result is combined with the product's unique number and product serial number in an array operation to generate a plaintext. The plaintext is then subjected to a full-code conversion algorithm based on a predetermined number of arrays to obtain the anti-counterfeiting code. Therefore, compared to other anti-counterfeiting code encryption generation algorithms, the method for generating an anti-counterfeiting code from a product number of the present invention has the characteristics of high encryption strength and extreme difficulty in cracking, thereby ensuring the uniqueness and unforgeability of the anti-counterfeiting code.
[0059] The system for generating anti-counterfeiting codes from product numbers of the present invention uses the AES algorithm to encrypt the product's unique number and serial number. The plaintext and key used in the AES encryption algorithm are reset using the product's unique number and serial number. The AES encryption result is combined with the product's unique number and serial number in an array operation to generate a plaintext. The plaintext is then converted to a full-code using a predefined array to generate the anti-counterfeiting code. Therefore, compared to other systems for generating encrypted anti-counterfeiting codes, the system for generating anti-counterfeiting codes from product numbers of the present invention features high encryption strength and is extremely difficult to crack, thereby ensuring the uniqueness and unforgeability of the anti-counterfeiting code.
[0060] Compared with other anti-counterfeiting code encryption generation devices, the device for generating product number anti-counterfeiting codes of the present invention has the characteristics of high encryption strength and extremely difficult to crack when generating anti-counterfeiting codes, so as to ensure the uniqueness and non-forgeability of the anti-counterfeiting codes.
[0061] Compared with other computer-readable storage media, the method for generating an anti-counterfeiting code from a product number executed by the computer-readable storage medium of the present invention has the characteristics of high encryption strength and extreme difficulty in cracking, thereby ensuring the uniqueness and unforgeability of the anti-counterfeiting code. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 This is a flow chart of a method for generating an anti-counterfeiting code from a product number of the present invention;
[0063] Figure 2 This is a flow chart of an AES encryption algorithm in the present invention;
[0064] Figure 3 It is a flow chart of a modulo algorithm in the present invention;
[0065] Figure 4 This is a flow chart of the full code conversion algorithm in the present invention;
[0066] Figure 5 This is a schematic diagram of the rules for generating product numbers and product sequence numbers in Example 1 of the present invention;
[0067] Figure 6 This is a schematic diagram of the rules for generating product numbers and product sequence numbers in Example 2 of the present invention;
[0068] Figure 7 This is a structural diagram of a system for generating anti-counterfeiting codes from product numbers;
[0069] Figure 8 The invention discloses a structural block diagram of a device for generating an anti-counterfeiting code from a product number. DETAILED DESCRIPTION
[0070] To make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention are described in further detail below with reference to the accompanying drawings.
[0071] like Figure 1 As shown, the method for generating an anti-counterfeiting code from a product number of the present invention comprises the following steps:
[0072] Step S1: Generate a unique number P for the product number according to a predetermined rule, and take a value N for the product sequence number within a predetermined length range;
[0073] Step S2: Perform AES encryption on the product number P and product serial number N according to the predetermined plaintext M1, plaintext M2, and key, and obtain the authentication code after taking the modulus algorithm;
[0074] Step S3: combining the product number, product serial number and authentication code into a plain code M;
[0075] Step S4, performing a full code conversion algorithm on the plain code according to the predetermined one-dimensional array key, the two-dimensional array cv, and the 10*10 two-dimensional arrays la0, la1, la2, la3, la4, la5, la6, and la7 to obtain an anti-counterfeiting code array;
[0076] Step S5: convert the anti-counterfeiting code array into a fixed-base character string to obtain an anti-counterfeiting code.
[0077] First, the product's unique number and serial number are encrypted sequentially using the AES algorithm. The plaintext and key used in the AES encryption algorithm are reset using the product's unique number and serial number. The AES encryption result is combined with the product's unique number and serial number in an array operation to generate a plaintext. The plaintext is then subjected to a full-code conversion algorithm based on a predetermined number of arrays to generate the anti-counterfeiting code. Therefore, compared to other anti-counterfeiting code encryption generation algorithms, the generation method of the present invention has the characteristics of high encryption strength and extreme difficulty in cracking, thereby ensuring the uniqueness and unforgeability of the anti-counterfeiting code.
[0078] Here, the anti-counterfeiting code array is converted into a fixed-base character string. The fixed-base character string can be hexadecimal, dodecimal, octal, etc., which is not limited here.
[0079] The product number in step S1 has P digits, Pn, including numeric characters '0' to '9'; the product serial number has N digits, Sn, including numeric characters '0' to '9'.
[0080] like Figure 2 As shown, the AES encryption operation in step S2 includes the following steps:
[0081] Step S2-1, converting the product number P into a hexadecimal product number array Pu, and converting the product sequence number N into a hexadecimal product sequence number array Su;
[0082] Step S2-2, iteratively replace the 1st, 3rd, ..., 2*Pn-1th bit data in the plaintext M1 according to the product number array to obtain plaintext M1-1;
[0083] Step S2-3, iteratively replace the 3rd, 6th, ..., 3*Pn bits of data in the key according to the product number array to obtain a new key K1;
[0084] Step S2-4: Perform AES encryption on the plaintext M1-1 and the new key K1 to obtain a first operation value, namely, the key K2;
[0085] Step S2-5, iteratively replace the 0th, 2nd, ..., 2*Sn-2th bit data in the plaintext M2 according to the product sequence number array to obtain plaintext M2-1;
[0086] Step S2-6: Use the key K2 to perform AES encryption on the plaintext M2-1 to obtain the second operation value, that is, the array K3.
[0087] It is used to reset the plaintext and key used in the AES encryption algorithm, the unique product number, and the product serial number.
[0088] like Figure 3 As shown, the modulo algorithm in step S2 includes the following steps:
[0089] Step S2-7, perform a modulo 10 operation on the array K3 bit by bit to obtain the third operation value, i.e., the array K3-1;
[0090] Step S2-8, take the 0th bit of the array K3-1 to obtain n1, i.e., iFirst;
[0091] Step S2-9, sum the array K3-1 from the first position to the iFirst position to obtain the fourth operation value, i.e., K3-2;
[0092] Step S2-10, perform a modulo 10 operation on K3-2 to obtain n2, i.e., iSecond;
[0093] Step S2-11, summing the iFirst+2th to 15th bits of the array K3-1 to obtain the fifth operation value, i.e., K3-3;
[0094] Step S2-12, perform a modulo 10 operation on K3-3 to obtain n3, i.e., iThree;
[0095] Step S2-13: Combine iFirst, iSecond, and iThree into an array to obtain the authentication code R, and proceed to step S3.
[0096] Used to perform a modulo algorithm on the AES algorithm encryption result to obtain the authentication code.
[0097] like Figure 4 As shown, the full code conversion algorithm in step S4 includes the following steps:
[0098] Step S4-1, cyclically assign values to the one-dimensional array key bit by bit to obtain a one-dimensional array k; cyclically assign values to the plaintext bit by bit to obtain a one-dimensional array X;
[0099] Step S4-2, performing 14 iterative operations on the one-dimensional array k and the one-dimensional array X to obtain a one-dimensional array X1;
[0100] Step S4-3: Shift the one-dimensional array X1 left by 8 bits to obtain an anti-counterfeiting code array Z.
[0101] The single iterative operation in the 14 iterative operations in step S4-2 includes the following steps:
[0102] Step S4-21, performing eight iterations of value assignment operations on the one-dimensional array k and the one-dimensional array X to obtain a one-dimensional array Zh;
[0103] Step S4-22, performing an 8-bit left shift operation on the one-dimensional array X, and assigning the first 8 bits of the one-dimensional array Zh to the last 8 bits of the one-dimensional array X to obtain the one-dimensional array X1;
[0104] Step S4-23: right-shift the one-dimensional array k by 1 bit to enter the next round of iteration.
[0105] The anti-counterfeiting code can be obtained by performing a full code conversion algorithm on the plain code according to a predetermined plurality of arrays.
[0106] Furthermore, the nth iteration of the eight iterations of the value assignment operation comprises the following steps:
[0107] Step S4-211: Take cv[j][0] to get t1, take cv[j][1] to get t2, take X[t1] to get Xu, take X[t2] to get Xw;
[0108] Step S4-212: Take Xu + k[j] to get Xuk, and perform a modulo 10 operation on Xuk to get Gu;
[0109] Step S4-213: Take Xw+k[j+8] to obtain Xwk, perform a modulo 10 operation on Xwk to obtain Qu, and take la[j][Gu][Qu] to obtain Yu;
[0110] Step S4-214: Calculate Yu + X[j] to obtain YuX, perform a modulo 10 operation on YuX to obtain YuX1, and then calculate Zh[j] = YuX1 to proceed to the next iteration. This is used to perform eight iterations of the assignment operation on the one-dimensional array k and the one-dimensional array X to obtain the one-dimensional array Zh.
[0111] Specifically, the method for generating an anti-counterfeiting code from a product number of the present invention is described below with two specific embodiments.
[0112] Example 1
[0113] Step S1: Follow Figure 5 The predetermined rules shown generate the unique product number 00001, according to Figure 5 The predetermined length range shown takes product serial number 00000001, and then enters step S2.
[0114] Step S2: Convert the product number 00001 into a hexadecimal product number array Pu{0,0,0,0,1}, convert the product serial number 00000001 into a hexadecimal product number array Su{0,0,0,0,0,0,0,1}, and according to the predetermined plaintext M1{
[0115] 0xf6,0xF1,0xf6,0xa6,
[0116] 0x09,0xf6,0xB3,0xC9,
[0117] 0xd2,0x09,0xae,0xCA,
[0118] 0x83,0x34,0xAF,0x9E
[0119] }、Plain text M2{
[0120] 0x88,0x5a,0x30,0x8d,
[0121] 0x32,0x43,0xf6,0xa8,
[0122] 0x31,0x31,0x98,0xa2,
[0123] 0xe0,0x37,0x07,0x34
[0124] }、Key K{
[0125] 0xF1,0x34,0xa6,0x09,
[0126] 0xab,0x7E,0xF1,0xAB,
[0127] 0xd2,0x09,0xae,0xCA,
[0128] 0xC9,0xf6,0xcf,0x7E
[0129] } Perform AES encryption algorithm operations in sequence to obtain array K3{
[0130] 0x24,0x81,0x64,0xE9,
[0131] 0xEA,0xCC,0x8E,0xEB,
[0132] 0x61,0xE0,0x90,0x19,
[0133] 0xA0,0xFF,0xA8,0xAC
[0134] }.
[0135] Perform a modulo algorithm operation on the array K3 to obtain the authentication code R{6,7,5}, and proceed to step S3.
[0136] Step S3: Perform array merging operation on the product number array Pu, product sequence number array Su, and authentication code R to generate plain code M{
[0137] 0x00,0x00,0x00,0x00,
[0138] 0x01,0x00,0x00,0x00,
[0139] 0x00,0x00,0x00,0x00,
[0140] 0x01,0x06,0x07,0x05
[0141] }, then go to step S4.
[0142] Step S4: According to the predetermined one-dimensional array key{8,0,5,7,9,2,1,7,3,4,5,2,6,9,1,4}, the two-dimensional array cv{
[0143] {14,11,},
[0144] {8,15,},
[0145] {10,14,},
[0146] {11,8,},
[0147] {9,13,},
[0148] {13,10,},
[0149] {12,9,},
[0150] {15,12}}, and 10*10 two-dimensional arrays la0, la1, la2, la3, la4, la5, la6, la7, perform full code conversion operation on the plain code M, and obtain the anti-counterfeiting code array Z{
[0151] 0x06,0x02,0x06,0x07,
[0152] 0x07,0x05,0x01,0x02,
[0153] 0x06,0x05,0x08,0x01,
[0154] 0x04,0x04,0x07,0x06
[0155] }, then go to step S5.
[0156] Step S5: Convert the anti-counterfeiting code array Z into a hexadecimal or decimal character string to obtain a 16-digit anti-counterfeiting code 6267751265814476.
[0157] Example 2
[0158] Step S1: Follow Figure 6 The predetermined rules shown generate the product unique number 01, according to Figure 6 The predetermined length range shown takes product serial number 0000001, and then enters step S2.
[0159] Step S2: Convert the product number 01 into a hexadecimal product number array Pu{0,1}, convert the product serial number 0000001 into a hexadecimal product number array Su{0,0,0,0,0,0,1}, and
[0160] 0xf6,0xF1,0xf6,0xa6,
[0161] 0x09,0xf6,0xB3,0xC9,
[0162] 0xd2,0x09,0xae,0xCA,
[0163] 0x83,0x34,0xAF,0x9E
[0164] }、Plain text M2{
[0165] 0x88,0x5a,0x30,0x8d,
[0166] 0x32,0x43,0xf6,0xa8,
[0167] 0x31,0x31,0x98,0xa2,
[0168] 0xe0,0x37,0x07,0x34
[0169] }、Key K{
[0170] 0xF1,0x34,0xa6,0x09,
[0171] 0xab,0x7E,0xF1,0xAB,
[0172] 0xd2,0x09,0xae,0xCA,
[0173] 0xC9,0xf6,0xcf,0x7E
[0174] } Perform AES encryption algorithm operations in sequence to obtain array K3{
[0175] 0x0E,0x99,0x61,0x27,
[0176] 0x99,0x0B,0xF0,0x05,
[0177] 0x96,0xAE,0xC2,0x3E,
[0178] 0x2A,0x2F,0x89,0x8E
[0179] }.
[0180] Perform a modulo algorithm operation on the array K3 to obtain the authentication code R{4,3,3}, and proceed to step S3.
[0181] Step S3: Perform array merging operation on the product number array Pu, product sequence number array Su, and authentication code R to generate plain code M{
[0182] 0x00,0x01,0x00,0x00,
[0183] 0x00,0x00,0x00,0x00,
[0184] 0x01,0x04,0x03,0x03
[0185] }, then go to step S4.
[0186] Step S4: According to the predetermined one-dimensional array key{8,7,5,1,2,4,3,9,4,6,7,0}, the two-dimensional array cv{
[0187] {9,6,},
[0188] {10,7,},
[0189] {6,11,},
[0190] {11,8,},
[0191] {7,9,},
[0192] {8,10}}, and 10*10 two-dimensional arrays la0, la1, la2, la3, la4, la5, la6, la7, perform full code conversion operation on the plain code M, and obtain the anti-counterfeiting code array Z{
[0193] 0x01,0x09,0x03,0x00,
[0194] 0x03,0x02,0x01,0x05,
[0195] 0x02,0x07,0x01,0x09
[0196] }, then go to step S5.
[0197] Step S5: Convert the anti-counterfeiting code array Z into a hexadecimal or decimal character string to obtain a 12-digit anti-counterfeiting code 193032152719.
[0198] From the analysis of the above-mentioned specific embodiments 1 and 2, it can be seen that the anti-counterfeiting code generated by the method for generating an anti-counterfeiting code from a product number provided by this patent is not only related to the predetermined plaintext, key, and array, but also depends on the combination of the number of digits of the product number and the product serial number. Therefore, compared with other anti-counterfeiting code encryption generation algorithms, the method for generating an anti-counterfeiting code from a product number of the present invention has the characteristics of high encryption strength and is extremely difficult to crack, so as to ensure the uniqueness and unforgeability of the anti-counterfeiting code.
[0199] like Figure 7 As shown, the system for generating anti-counterfeiting codes from product numbers of the present invention includes a character string generation module, an authentication code generation module, a plain code generation module, an anti-counterfeiting code array generation module, and an anti-counterfeiting code generation module, and uses the above-mentioned method for generating anti-counterfeiting codes from product numbers to generate anti-counterfeiting codes;
[0200] String generation module: used to generate a unique number P for the product number according to a predetermined rule, and to take a value N for the product sequence number within a predetermined length range;
[0201] Authentication code generation module: used to perform AES encryption operation on product number P and product serial number N according to the predetermined plain text M1, plain text M2 and key, and obtain the authentication code after taking the modulus algorithm;
[0202] A plain code generation module: used to combine the product number, product serial number and authentication code into a plain code;
[0203] The anti-counterfeiting code array generation module is used to perform a full code conversion algorithm on the plain code according to the predetermined one-dimensional array key, the two-dimensional array cv, and the 10*10 two-dimensional arrays la0, la1, la2, la3, la4, la5, la6, and la7 to obtain the anti-counterfeiting code array;
[0204] The anti-counterfeiting code generating module is used to convert the anti-counterfeiting code array into a fixed-base character string to obtain the anti-counterfeiting code.
[0205] The AES algorithm is used to encrypt the product's unique number and serial number. The plaintext and key used in the AES encryption algorithm are reset using the product's unique number and serial number. The AES encryption result is combined with the product's unique number and serial number in an array operation to generate a plaintext. The plaintext is then converted to a full-code format using a predefined array of multiple arrays to generate the anti-counterfeiting code. Therefore, compared to other anti-counterfeiting code encryption generation systems, the generation system of the present invention boasts high encryption strength and is extremely difficult to crack, ensuring the uniqueness and unforgeability of the anti-counterfeiting code.
[0206] like Figure 8 As shown, the device for generating an anti-counterfeiting code for a product number of the present invention includes a memory and a processor.
[0207] Memory: used to store computer programs;
[0208] Processor: used to implement the steps of the above-mentioned method of generating an anti-counterfeiting code from a product number when executing the computer program.
[0209] The computer-readable storage medium of the present invention stores a computer program, and when the computer program is executed by a processor, the steps of the method for generating an anti-counterfeiting code from a product number are implemented.
Claims
1. A method for generating an anti-counterfeiting code from a product number, characterized in that: The steps include: Step S1: Generate a unique number P for the product number according to a predetermined rule, and take a value N for the product sequence number within a predetermined length range; Step S2: Perform AES encryption on the product number P and product serial number N according to the predetermined plaintext M1, plaintext M2, and key, and obtain the authentication code after taking the modulus algorithm; Step S3: combining the product number, product serial number and authentication code into a plain code; Step S4, performing a full code conversion algorithm on the plain code according to the predetermined one-dimensional array key, the two-dimensional array cv, and the 10*10 two-dimensional arrays la0, la1, la2, la3, la4, la5, la6, and la7 to obtain an anti-counterfeiting code array; Step S5: converting the anti-counterfeiting code array into a fixed-base character string to obtain an anti-counterfeiting code; The encryption operation includes the following steps: Step S2-1, converting the product number P into a hexadecimal product number array, and converting the product sequence number N into a hexadecimal product sequence number array; Step S2-2, iteratively replace the 1st, 3rd, ..., 2*Pn-1th bit data in the plaintext M1 according to the product number array to obtain plaintext M1-1; Step S2-3, iteratively replacing the 3rd, 6th, ..., 3*Pn bits of data in the key according to the product number array to obtain a new key; Step S2-4: Perform AES encryption based on the plaintext M1-1 and the new key to obtain a first operation value; Step S2-5, iteratively replace the 0th, 2nd, ..., 2*Sn-2th bit data in the plaintext M2 according to the product sequence number array to obtain plaintext M2-1; Step S2-6: Perform AES encryption on the plaintext M2-1 and the first operation value to obtain a second operation value; The modulo algorithm in step S2 comprises the following steps: Step S2-7, performing a modulo 10 operation on the second operation value to obtain a third operation value; Step S2-8, taking the 0th bit of the third operation value to obtain n1; Step S2-9, summing the third operation value from the 1st bit to the n1+1th bit to obtain a fourth operation value; Step S2-10, performing a modulo 10 operation on the fourth operation value to obtain n2; Step S2-11, sum the third operation value from the n1+2th bit to the 15th bit to obtain the fifth operation value; Step S2-12, performing a modulo 10 operation on the fifth operation value to obtain n3; Step S2-13, combining the n1, n2, and n3 into an array to obtain the authentication code; The full code conversion algorithm in step S4 includes the following steps: Step S4-1, cyclically assign values to the one-dimensional array key bit by bit to obtain a one-dimensional array k; cyclically assign values to the plaintext bit by bit to obtain a one-dimensional array X; Step S4-2, performing 14 iterative operations on the one-dimensional array k and the one-dimensional array X to obtain a one-dimensional array X1; Step S4-3, performing an 8-bit left shift operation on the one-dimensional array X1 to obtain an anti-counterfeiting code array; A single iterative operation in the 14 iterative operations in step S4-2 includes the following steps: Step S4-21, performing eight iterations of value assignment operations on the one-dimensional array k and the one-dimensional array X to obtain a one-dimensional array Zh; Step S4-22, performing an 8-bit left shift operation on the one-dimensional array X, and assigning the first 8 bits of the one-dimensional array Zh to the last 8 bits of the one-dimensional array X to obtain the one-dimensional array X1; Step S4-23, right-shift the one-dimensional array k by 1 bit and enter the next round of iteration; The eight iterations of the assignment operation include the following steps: Step S4-211, take the data in the nth row and the 0th column of the two-dimensional array cv to obtain t1, take the data in the nth row and the 1st column of the two-dimensional array cv to obtain t2, take the data in the t1th position of the one-dimensional array X to obtain Xu, and take the data in the t2th position of the one-dimensional array X to obtain Xw; Step S4-212, summing Xu with the n-th bit of the one-dimensional array k, and performing a modulo 10 operation on the sum of the results to obtain Gu; Step S4-213, sum Xw with the n+8th bit of the one-dimensional array k, and perform a modulo 10 operation on the result to obtain Qu; obtain the data of the Guth row and Quth column of the two-dimensional code array la(n) to obtain Yu; Step S4-214: sum Yu with the nth bit of the one-dimensional array X, perform modulo 10 operation on the result, and obtain YuX1; assign YuX1 to the nth bit of the one-dimensional array Zh, and enter the next round of iteration.
2. The method for generating an anti-counterfeiting code from a product number according to claim 1, characterized in that: The product number in step S1 has P digits, Pn, including numeric characters '0' to '9'; the product serial number has N digits, Sn, including numeric characters '0' to '9'.
3. A system for generating anti-counterfeiting codes from product numbers, characterized in that: It includes a character string generation module, an authentication code generation module, a plain code generation module, an anti-counterfeiting code array generation module, and an anti-counterfeiting code generation module, and uses the method for generating an anti-counterfeiting code from a product number according to any one of claims 1-2 to generate an anti-counterfeiting code; String generation module: used to generate a unique number P for the product number according to a predetermined rule, and to take a value N for the product sequence number within a predetermined length range; Authentication code generation module: used to perform AES encryption operation on product number P and product serial number N according to the predetermined plain text M1, plain text M2 and key, and obtain the authentication code after taking the modulus algorithm; A plain code generation module: used to combine the product number, product serial number and authentication code into a plain code; The anti-counterfeiting code array generation module is used to perform a full code conversion algorithm on the plain code according to the predetermined one-dimensional array key, the two-dimensional array cv, and the 10*10 two-dimensional arrays la0, la1, la2, la3, la4, la5, la6, and la7 to obtain the anti-counterfeiting code array; The anti-counterfeiting code generating module is used to convert the anti-counterfeiting code array into a fixed-base character string to obtain the anti-counterfeiting code.
4. A device for generating anti-counterfeiting codes from product numbers, characterized in that: including memory and processor, Memory: used to store computer programs; Processor: used to implement the steps of the method for generating an anti-counterfeiting code from a product number as described in any one of claims 1-2 when executing the computer program.
5. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for generating an anti-counterfeiting code from a product number according to any one of claims 1 to 2.
Citation Information
Patent Citations
Encryption method and system for anti-counterfeiting code
CN108337082A
Code group anti-counterfeiting technology formed by any number of plain code and secret code groups
CN110348855A