CAES Chinese herbal medicine traceability code encryption and decryption method
Through the CAES Chinese herbal medicine traceability code encryption and decryption method, multiple encryption methods are used to generate 16-bit ciphertext, which solves the problem that the drug traceability code in the existing technology is easy to be cracked, and achieves efficient, random and difficult-to-reuse encryption protection, which is suitable for drugs. Micro data storage of traceable code.
Patent Information
- Application Number
- CN202210351250.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-02
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-04-02
AI Technical Summary
The existing drug traceability code encryption method is easily cracked by low-level keys, and the increase in ASCII coding digits leads to an increase in verification time. It cannot achieve the multiple protection mechanism of "one item, one code", is difficult to decipher in a short time, and cannot decipher the rules. Reuse.
The CAES Chinese herbal medicine traceability code encryption and decryption method is used, and multiple encryption methods such as timestamp, random number, parity judgment, ASCII conversion, ECBNoPadding and ECBPKCS5Padding are used to generate 16-bit ciphertext and print it to ensure that the encrypted information is difficult to decipher.
It achieves the 'one-time' encryption feature, increases the difficulty of decryption, ensures high randomness and salt processing, is suitable for QR code storage, and ensures the uniqueness and efficiency of encrypted data.
Smart Images

Figure CN115150066B
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of drug production management, and in particular relates to a CAES Chinese herbal medicine traceability code encryption and decryption method. Background Art
[0002] Based on the requirements for drug quality and anti-counterfeiting, it is necessary to enable effective traceability of drugs after leaving the factory. The country has introduced a 20-digit Chinese herbal medicine traceability code. The existing encryption method uses a single AES encryption algorithm or ASCII encoding technology.
[0003] The AES algorithm is popular among people due to its short key establishment time, good sensitivity, and low memory requirements. However, it is precisely because of this feature that low-order key brute force cracking becomes possible. Both standard ASCII and extended ASCII require more characters, which will increase the time for traceability verification. For this reason, we need to introduce an encryption that can guarantee the "one object, one code" feature while having multiple protection mechanisms such as "disordered", "random", and "one-time", so that even if the encrypted information is intercepted, it cannot be deciphered in a short time and the deciphering rules cannot be reused. Summary of the invention
[0004] The purpose of the present invention is to provide a CAES Chinese herbal medicine traceability code encryption and decryption method to solve the problems raised in the above background technology.
[0005] To achieve the above object, the present invention provides the following technical solution: a method for encrypting and decrypting a CAES Chinese herbal medicine traceability code, comprising the following steps:
[0006] Step S1, the pharmaceutical enterprise traceability system production line generates a 20-digit traceability code;
[0007] Step S2, encrypting the CAES code according to the traceability code to generate a code;
[0008] Step S3, then printing the encrypted code on the production line;
[0009] Step S4: After obtaining the medicine, the downstream distributor scans the code at the terminal;
[0010] Step S5: After scanning the code, the terminal will jump to the cloud service platform for verification, and then jump to the internal traceability system service of the pharmaceutical company for decoding;
[0011] Step S6: query according to the decoded traceability code and return the traceability query result.
[0012] Preferably, the specific steps of encrypting the traceability code from step S1 to step S2 are as follows:
[0013] S1201. Get the current timestamp;
[0014] S1202. Loop 8 times, use JavaMath.random random number method to obtain a random number from 0 to 12, and use the obtained random number as the subscript to obtain the corresponding character in the timestamp;
[0015] S1203. Convert the obtained 8 characters into Int type and add them;
[0016] S1204. The added value is judged to be odd or even. If it is an odd number, the 8 characters are displayed in positive order, and if it is an even number, they are displayed in reverse order;
[0017] S1205. Convert the 8-bit characters into corresponding ASCII codes, and finally obtain a 16-bit string, which we name as key A;
[0018] S1206. The first 4 digits of the fixed 20-digit traceability code are truncated and named as the traceability prefix, and the remaining 16-digit string is named as the encrypted plaintext A, and the two are saved separately;
[0019] S1207. Split the 16-bit encrypted plaintext A into 4 equal parts;
[0020] S1208. Loop twice to randomly obtain 2 of the 4 equal parts and merge them to form a new 8-bit character;
[0021] S1209. Name the newly formed 8-bit character as a mini key, and copy and merge the mini key to eventually form a 16-bit character named key B;
[0022] S1210. Use key B to perform AES ECBNoPadding encryption on encrypted plaintext A to obtain ciphertext A;
[0023] S1211. Encrypt the mini key with key A using ECBPKCS5Padding of AES to obtain ciphertext B;
[0024] S1212. Concatenate ciphertext A and ciphertext B to obtain the final ciphertext, and return the ciphertext.
[0025] Preferably, the specific operation method of step S5 is to first split the ciphertext, and then perform the reverse operation according to the specific operation flow from step S1 to step S2.
[0026] Preferably, the segmentation of ciphertext A and ciphertext B is determined based on their respective encrypted lengths and is performed by subscript.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] 1) The “one-time” feature ensures that the encrypted data complies with the “one object, one code” constraint;
[0029] 2) The algorithm uses multiple encryption methods, including parity judgment, ASCII conversion, ECBNoPadding and ECBPKCS5Padding, which greatly increases the difficulty of decryption;
[0030] 3) Timestamp, UUID key generation and parity determination all achieve high randomness and salt processing features;
[0031] 4) The length of the encrypted characters is within 75 characters, which is suitable for storing trace data such as QR codes;
[0032] 5) The encryption and decryption algorithms are efficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a flowchart of the present invention;
[0034] Figure 2 This is a flowchart of the encryption process of the first part of the present invention;
[0035] Figure 3 This is a flowchart of the encryption process of the second part of the present invention;
[0036] Figure 4 This is a flowchart of the encryption process of the third part of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. Example
[0038] See also Figure 1-4 The present invention provides a technical solution: a CAES Chinese herbal medicine traceability code encryption and decryption method, comprising the following steps:
[0039] Step S1, the pharmaceutical enterprise traceability system production line generates a 20-digit traceability code;
[0040] Step S2, encrypting the CAES code according to the traceability code to generate a code;
[0041] Step S3, then printing the encrypted code on the production line;
[0042] Step S4: After obtaining the medicine, the downstream distributor scans the code at the terminal;
[0043] Step S5: After scanning the code, the terminal will jump to the cloud service platform for verification, and then jump to the internal traceability system service of the pharmaceutical company for decoding;
[0044] Step S6: query according to the decoded traceability code and return the traceability query result.
[0045] Preferably, the specific steps of encrypting the traceability code from step S1 to step S2 are as follows:
[0046] S1201. Get the current timestamp;
[0047] S1202. Loop 8 times, use JavaMath.random random number method to obtain a random number from 0 to 12, and use the obtained random number as the subscript to obtain the corresponding character in the timestamp;
[0048] S1203. Convert the obtained 8 characters into Int type and add them;
[0049] S1204. The added value is judged to be odd or even. If it is an odd number, the 8 characters are displayed in positive order, and if it is an even number, they are displayed in reverse order;
[0050] S1205. Convert the 8-bit characters into corresponding ASCII codes, and finally obtain a 16-bit string, which we name as key A;
[0051] S1206. The first 4 digits of the fixed 20-digit traceability code are truncated and named as the traceability prefix, and the remaining 16-digit string is named as the encrypted plaintext A, and the two are saved separately;
[0052] S1207. Split the 16-bit encrypted plaintext A into 4 equal parts;
[0053] S1208. Loop twice to randomly obtain 2 of the 4 equal parts and merge them to form a new 8-bit character;
[0054] S1209. Name the newly formed 8-bit character as a mini key, and copy and merge the mini key to eventually form a 16-bit character named key B;
[0055] S1210. Use key B to perform AES ECBNoPadding encryption on encrypted plaintext A to obtain ciphertext A;
[0056] S1211. Encrypt the mini key with key A using ECBPKCS5Padding of AES to obtain ciphertext B;
[0057] S1212. Concatenate ciphertext A and ciphertext B to obtain the final ciphertext, and return the ciphertext.
[0058] Preferably, the specific operation method of step S5 is to first split the ciphertext, and then perform the reverse operation according to the specific operation flow from step S1 to step S2.
[0059] Preferably, the segmentation of ciphertext A and ciphertext B is determined based on their respective encrypted lengths and is performed by subscript.
[0060] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. The CAES Chinese herbal medicine traceability code encryption and decryption method is characterized by: The following steps are involved: Steps S1-S2: The pharmaceutical enterprise traceability system production line generates a 20-digit traceability code, and CAES encryption is performed based on the traceability code to generate a code. The specific steps for encrypting the traceability code are as follows: S1201. Get the current timestamp; S1202. Loop 8 times, use JavaMath.random random number method to obtain a random number from 0 to 12, and use the obtained random number as the subscript to obtain the corresponding character in the timestamp; S1203. Convert the obtained 8 characters into Int type and add them; S1204. The added value is judged to be odd or even. If it is an odd number, the 8 characters are displayed in positive order, and if it is an even number, they are displayed in reverse order; S1205. Convert the 8-bit characters into corresponding ASCII codes, and finally obtain a 16-bit string, which we name as key A; S1206. The first 4 digits of the fixed 20-digit traceability code are truncated and named as the traceability prefix, and the remaining 16-digit string is named as the encrypted plaintext A, and the two are saved separately; S1207. Split the 16-bit encrypted plaintext A into 4 equal parts; S1208. Loop twice to randomly obtain 2 of the 4 equal parts and merge them to form a new 8-bit character; S1209. Name the newly formed 8-bit character as a mini key, and copy and merge the mini key to eventually form a 16-bit character named key B; S1210. Use key B to perform AES ECBNoPadding encryption on encrypted plaintext A to obtain ciphertext A; S1211. Encrypt the mini key with key A using ECBPKCS5Padding of AES to obtain ciphertext B; S1212. Concatenate ciphertext A and ciphertext B to obtain the final ciphertext, and return the ciphertext; Step S3, then the encrypted code is printed on the production line; Step S4: After obtaining the medicine, the downstream distributor scans the code at the terminal; Step S5: After scanning the code, the terminal will jump to the cloud service platform for verification, and then jump to the internal traceability system service of the pharmaceutical company for decoding; Step S6: query according to the decoded traceability code and return the traceability query result.
2. The CAES Chinese herbal medicine traceability code encryption and decryption method according to claim 1, characterized in that: Features: The specific operation method of step S5 is to first split the ciphertext, and then perform the reverse operation according to the specific operation flow from step S1 to step S2.
3. The CAES Chinese herbal medicine traceability code encryption and decryption method according to claim 2 is characterized in that: Features: The division of ciphertext A and ciphertext B is determined based on their respective encrypted lengths and is performed by subscript.
4. The CAES Chinese herbal medicine traceability code encryption and decryption method according to claim 1, characterized in that: Features: The code sprayed in step S3 is a two-dimensional code.
Citation Information
Patent Citations
Multiple key checking, inspection and forgery prevention source forming method and forgery prevention label
CN105046504A
2-dimensional-bar-code-based merchandise anti-counterfeiting tracing system
CN107038594A
Ginseng code assignment and identification method thereof
CN108665286A
A product traceability and anti-counterfeiting system and method based on a two-dimensional code
CN109816401A
Multi-dimensional AES symmetric encryption and decryption method
CN111211891A
