An anti-fake encryption and decryption method based on OTP principle

By generating and decrypting ciphertext using the OTP principle, the problem of one-time codebook length and usage limit is solved, achieving flexible ciphertext length and high concurrency performance. It is suitable for traceability codes and identity recognition codes, and improves the protection capability of traceability codes.

CN117749400BActive Publication Date: 2026-11-27GUANGDONG PAOHE CHINESE HERB ELECTRONIC COMMERCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310817439.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-05
Publication Date
2026-11-27
Estimated Expiration
2043-07-05

AI Technical Summary

Technical Problem

In existing technologies, one-time password books must be the same length as the encrypted file and can only be used once. Furthermore, when the password book is illegally deciphered by a third party through brute force or traversal, it can lead to the leakage of traceability codes, affecting the traceability and security of the supply chain.

Method used

Using the OTP principle, ciphertext is generated through random ASCII code conversion, salting, exponentiation, and Base64 encoding. Plaintext is then recovered through a corresponding decryption process, achieving flexible ciphertext length and preventing unauthorized interpretation.

Benefits of technology

It achieves flexible ciphertext length, prevents unauthorized interpretation by third parties, is suitable for small or micro QR code content, supports high-concurrency encryption and decryption performance, is suitable for traceability codes and identity recognition codes, provides a globally unique solution, and improves the protection capability of traceability codes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117749400B_ABST
    Figure CN117749400B_ABST
Patent Text Reader

Abstract

The application discloses an anti-fake encryption and decryption method based on OTP principle and relates to the technical field of information security. The application is based on the encryption and decryption algorithm of the one-time password book algorithm theory, and the encryption and decryption can be performed without providing a key, the ciphertext can provide all information required for decryption, is more suitable for a scene with a requirement on the length of the ciphertext, and supports high-concurrency encryption and decryption performance close to the standard AES algorithm in the "one object one code" scene. In addition to the fact that the ciphertext cannot be cracked by force, the application also solves the problems of the excessively long OTP password book length, the storage and distribution of the OTP password book and the like in actual application. The application effectively prevents a third party from illegally reading and tracing the generation rule of the "one object one code" through exhaustive search and traversal and is more suitable for a scene with a higher anti-fake level of coding, such as a traceability code and an identity recognition code. Meanwhile, the anti-fake code is generated through three changes by a special algorithm, so that the code is globally unique and has a good protection effect on traceability codes in various industries.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information security technology, specifically to an anti-counterfeiting encryption and decryption method based on the OTP principle. Background Technology

[0002] Anti-counterfeiting encryption is an encryption technology used to protect product or information security. It aims to ensure that data is not accessed or tampered with by unauthorized persons during transmission, storage, or processing by encrypting it. Anti-counterfeiting encryption can be applied in various fields, such as anti-counterfeiting traceability, identity verification, and information security. The main goals of anti-counterfeiting encryption are to protect the confidentiality, integrity, and reliability of data. Specifically, anti-counterfeiting encryption typically includes the following aspects: Confidentiality: Anti-counterfeiting encryption uses cryptographic algorithms to convert sensitive data into unreadable ciphertext to prevent unauthorized access to the data content. Only those with the correct key or password can decrypt the ciphertext and restore it to readable plaintext. Integrity: Anti-counterfeiting encryption can ensure data integrity by adding technologies such as checksums or digital signatures. This allows detection of whether data has been tampered with during transmission or storage; if any modification or damage is found, the recipient can detect it and refuse to process it. Reliability: Anti-counterfeiting encryption uses strong encryption algorithms and security protocols to provide highly reliable security. This ensures that data is not easily vulnerable to malicious attacks, data leaks, or unauthorized access during transmission, storage, and processing.

[0003] However, in existing technologies, a random key plaintext can only be used once. For example, Chinese patent CN114844640A discloses an encryption / decryption method based on the RSA algorithm. The steps are as follows: Step 1: The licensor generates public and private keys, storing the private key and placing the public key in the business system; Step 2: The licensor encrypts the authorization information using the private key; Step 3: An authorization file is generated from the encrypted ciphertext; Step 4: The authorization file is uploaded to the business system; Step 5: The authorization file is verified and decrypted using the public key within the business system; Step 6: The authorization information within the authorization file is obtained; Step 7: Business logic control is performed based on the authorization information. This invention uses asymmetric encryption, increasing the security and immutability of the authorization file. The public-private key method reduces the risk of leakage, achieving the security and uniqueness requirements of the authorization file.

[0004] While the aforementioned schemes offer advantages, one-time password books present several challenges in practice. Theoretically, this type of password is unbreakable due to its use of a random key to compose plaintext, and it is used only once. However, practical issues include: the one-time password book must be randomly generated, at least the same length as the encrypted file, the encrypted text can only be used once, and it must be carefully kept secret from unrelated individuals. Furthermore, regarding traceability codes, if the password book is illegally deciphered by a third party through brute force or traversal, the traceability code can be leaked. Traceability codes play a crucial role in the supply chain, tracking the production, transportation, and distribution of products. They verify product authenticity and traceability. By illegally deciphering the password book, attackers can generate legitimate counterfeit traceability codes, rendering anti-counterfeiting measures ineffective and compromising the traceability and security of the supply chain. Therefore, an anti-counterfeiting encryption / decryption method based on the OTP principle is urgently needed to address these issues. Summary of the Invention

[0005] The purpose of this invention is to solve the problems in the prior art where the one-time encryption codebook must be randomly generated, must be at least the same length as the encrypted file, the text used for encryption can only be used once, and when the codebook is illegally deciphered by a third party through exhaustive search, traversal or other methods, it will lead to the leakage of the traceability code.

[0006] To achieve the above objectives, the present invention provides the following technical solution: This invention provides an anti-counterfeiting encryption method based on the OTP principle, characterized in that the method includes: Random number acquisition: The random number range of the ASCII code is between lowercase letters a and z, i.e., 97 to 122. A random number is acquired from the closed interval of 97 to 122. The plaintext string to be encrypted is converted into an ASCII code array. The values ​​of the ASCII code array are added together to obtain the maximum value Max. A random value is generated in the range [0, Max] as the power factor. The random ASCII code is escaped to obtain the plaintext letter t; The plaintext letter t is concatenated with the power factor to obtain the pre-parameter; The power factor is salted by adding the random ASCII code to the power factor to obtain the salted factor. The ASCII code array is traversed and plaintext is transcoded to obtain character numbers, and the salting factor is used to subtract the ASCII code of each character to obtain a new integer array; Each number in the new integer array is exponentially operated on using a salt factor and then decremented to obtain an encrypted byte array; The encrypted byte group is decoded and concatenated with the preceding parameters to obtain the final ciphertext.

[0007] The present invention is further configured such that: the encrypted byte group is decoded and then encoded using Base64 to obtain a ciphertext string; The ciphertext string is concatenated with the preceding parameters to obtain the final ciphertext. The present invention also provides an anti-counterfeiting and decryption method based on the OTP principle, characterized in that the method includes: checking whether the keyword "@" exists after the final ciphertext is transmitted; When the keyword "@" is present, the final ciphertext is split to obtain the pre-parameters and the ciphertext string; The preceding parameters are extracted and converted to obtain ASCII codes; The extracted pre-parameters, excluding the first letter, are used as exponents; The ciphertext string is decoded to obtain an encrypted byte array; Each byte in the encrypted byte array is exponentially operated on, a salt factor is used, and the array is decremented to obtain the decrypted byte array. Each byte in the decrypted byte array is added to the ASCII code of its first letter to obtain the plaintext byte array; The plaintext byte array is converted into a string, which is the decrypted plaintext.

[0008] The present invention is further configured such that: after the final ciphertext is input, if the keyword "@" is present, the decryption is returned and a failure message is displayed; The present invention is further configured such that the extraction and conversion of the pre-parameters are performed according to the generation rules; The present invention is further configured such that: the ciphertext string is also Base64 decoded to obtain an encrypted byte array; The present invention is further configured such that: the decrementing process uses the decrementing value of the salt factor to perform an exponentiation operation on each byte of the complemented byte array.

[0009] Compared with known public technologies, the technical solution provided by this invention has the following beneficial effects: This invention's encryption and decryption algorithm, based on the theory of one-time passwordbooks, allows for encryption without providing a key. The ciphertext provides all the information needed for decryption, making it more suitable for scenarios with requirements on ciphertext length, such as small or micro QR code content. In "one item, one code" scenarios, it supports high-concurrency encryption and decryption performance approaching that of the standard AES algorithm. Besides preventing brute-force attacks on the ciphertext, it also solves the practical problems of excessively long OTP passwordbooks, passwordbook storage, and distribution. Effectively prevents third parties from illegally deciphering the "one item, one code" generation rules of the traceability code through exhaustive search and traversal. It is more suitable for scenarios with high anti-counterfeiting levels of coding, such as traceability codes and identity recognition codes. At the same time, the anti-counterfeiting code is generated by a special algorithm through triple transformation, so it has a globally unique solution. It has a good protective effect on traceability codes in various industries. It solves the problems of existing technologies, such as the encryption one-time password book must be randomly generated, must be at least the same length as the encrypted file, and the text used for encryption can only be used once. Furthermore, when the password book is illegally deciphered by third parties through exhaustive search and traversal, it will lead to the leakage of the traceability code. Attached Figure Description

[0010] Figure 1 This is a flowchart of an anti-counterfeiting encryption method based on the OTP principle according to the present invention; Figure 2 This is a flowchart of an anti-counterfeiting and decryption method based on the OTP principle of the present invention; Figure 3 This invention provides an anti-counterfeiting encryption method based on the OTP principle, which uses a formula diagram to convert plaintext strings to ASCII. Figure 4 This invention provides a method for anti-counterfeiting encryption and decryption based on the OTP principle, which uses a formula for subtracting ASCII codes. Figure 5 This is a diagram of the exponentiation formula for an anti-counterfeiting encryption method based on the OTP principle of the present invention; Figure 6 This is a diagram of the exponentiation formula for an anti-counterfeiting and decryption method based on the OTP principle of the present invention. Figure 7 This is a diagram showing the inverse formula after subtraction of a counterfeit-proof decryption method based on the OTP principle according to the present invention. Figure 8 This is a configuration diagram of the stress test thread pool for an anti-counterfeiting encryption / decryption method based on the OTP principle according to the present invention; Figure 9 This is a stress test result diagram of an anti-counterfeiting encryption and decryption method based on the OTP principle of the present invention; Figure 10 This is a graph showing the number of transactions per second for an anti-counterfeiting encryption and decryption method based on the OTP principle of the present invention. Figure 11 This is a response time distribution diagram of an anti-counterfeiting encryption and decryption method based on the OTP principle of the present invention. Detailed Implementation

[0011] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0012] Please see Figure 1 This invention provides a technical solution: an anti-counterfeiting encryption method based on the OTP principle, characterized by comprising the following steps: Step 1. First, obtain a random number of ASCII codes between the lowercase letters a and z. The ASCII code for the lowercase letter a is 97, and the ASCII code for the lowercase letter z is 122. That is, a random number in the closed interval between 97 and 122. Here, let's say the random number we get is 116. Step 2. Convert the plaintext string to ASCII code, such as... Figure 3 .

[0013] Step 3. Obtain an integer array: [76,88,89,89,82,65,49,66,56,48,49,65,55,57,70,48,49,57,54,51]; Step 4. Add the values ​​in the above integer array and use this as the maximum value, abbreviated as Max, and 0 as the minimum value. Obtain a random value within the closed interval [0, Max]. Here, the random value obtained is 978, so the power factor is 978. Step 5. Next, escape the random ASCII code (116) to obtain the plaintext letter t; Step 6. Concatenate the plaintext letter t with the power factor to obtain the pre-parameter t978@; Step 7. Next, salt the power factor. This requires adding the random ASCII code to the power factor to obtain the salt factor 1094. This is the first transformation. Step 8. Iterate through the character array after converting plaintext to ASCII and subtract the ASCII code of each character using a random ASCII code, such as... Figure 4As shown, random ASCII codes (116) are used to subtract each character code from the integer array [76,88,89,89,82,65,49,66,56,48,49,65,55,57,70,48,49,57,54,51] to obtain a new integer array [40,28,27,27,34,51,67,50,60,68,67,51,61,59,46,68,67,59,62,65]. Instead of directly encrypting, the new string content is obtained by using "complements". This is the second transformation. Step 9. Iterate through the new integer array, exponentiating each number using a salt factor of 1094. During the exponentiation, decrement the 1094 value by 1 for each encountered byte. For example... Figure 5 As shown, the encrypted byte array [110,89,95,88,96,114,3,13,2,121,127,8,7,2,22,115,117,14,10,114] will be obtained. Here, the salt factor is decremented and each byte of the complemented byte array is exponentially operated on. This is the third transformation. Step 10. The encrypted byte array was then base64 encoded to obtain the ciphertext string bllfWGByAw0CeX8IBwIWc3UOCnI=; Step 11. Concatenate the ciphertext string with the preceding parameters to obtain the final ciphertext t978@bllfWGByAw0CeX8IBwIWc3UOCnI=.

[0014] Please see Figure 2 This invention provides an anti-counterfeiting and decryption method based on the OTP principle, characterized by the following steps: Step 1. First, send the ciphertext t978@bllfWGByAw0CeX8IBwIWc3UOCnI=; Step 2. Check if the keyword "@" exists. If it exists, proceed; otherwise, return a decryption failure message. Step 3. If the keyword "@" is present, split the "@" to obtain two parts: "prefix parameters" and "ciphertext string". Step 4. According to the generation rules, the first character of the pre-parameter is a random letter. By conversion, the corresponding ASCII code can be obtained. The first letter here is t, so the corresponding ASCII code is (116). Step 5. The characters in the preamble, excluding the first letter, are power factors, which are 978 in this case; Step 6. Add the power factor and the ASCII code of the first letter to obtain the salting factor 1094; Step 7. Decrypt the ciphertext string using base64 to obtain the encrypted byte array, which is [110,89,95,88,96,114,3,13,2,121,127,8,7,2,22,115,117,14,10,114]; Step 8. Iterate through the encrypted byte array, exponentiating each number using the salt factor 1094. Similar to the encryption algorithm, decrement the salt factor by 1 when iterating through each byte. Figure 6 As shown: The decrypted byte array is obtained as [40,28,27,27,34,51,67,50,60,68,67,51,61,59,46,68,67,59,62,65]; Step 9. Then, convert the first letter of each byte in the decrypted byte array to its ASCII code (116). Since each byte is also obtained by subtracting its ASCII code during encryption, the conversion from ciphertext to plaintext is also done by subtracting the ASCII code to obtain the plaintext byte array, as shown in Figure 7. The final plaintext byte array is [76,88,89,89,82,65,49,66,56,48,49,65,55,57,70,48,49,57,54,51]. Step 10. Then convert the plaintext byte array into a string, which is the corresponding plaintext.

[0015] Comparison of POTP and AES load testing performance

[0016] Table 1: Load Testing Server Configuration

[0017] Table 2: JMeter load testing configuration

[0018] The current load test does not involve I / O read / write operations; it's purely CPU computation and memory information interaction. Therefore, the number of tests will be unlimited, resulting in a longer load test period. The purpose is to compare the performance of two algorithms, using the standard AES encryption / decryption algorithm as a benchmark to compare the performance of the self-developed POTP algorithm. The JMeter thread pool configuration is as follows... Figure 8 As shown.

[0019] After 91 minutes of load testing, the total number of test cases executed was 22,406,436. The errors in the "Error%" column are due to socket interruptions caused by the interruption of the load test operation and should be ignored (no errors occurred before the load test was interrupted).

[0020] like Figure 9As shown, the load test examples are POTP encryption, POTP decryption, AES encryption, and AES decryption. Their TPS is consistently around 1014 per second. The curves for transactions per second are shown below. Figure 10 As shown.

[0021] like Figure 11 As shown, in terms of response time, most responses can be completed within 300ms (including network transmission loss and the loss of opening and closing requests, etc.).

[0022] Therefore, it can be concluded that the performance of POTP's self-developed algorithm is no different from that of the standard AES encryption and decryption algorithm, and meets the requirements for production use.

[0023] The specific encryption process of a one-time codebook is as follows: First, you need a one-time codebook to encrypt the file. Then, mix the letters in the one-time codebook with the letters in the encrypted file according to a pre-agreed rule. One way to mix them is to assign numbers to the letters (e.g., in English, A to Z are assigned to 0 to 25 in sequence). Then, add the numbers represented by the letters in the one-time codebook to the corresponding numbers in the encrypted file, and divide by the number of letters in the language to get the remainder. Assuming the number of letters is n (e.g., 26 in English), if any of the resulting numbers is less than zero, add n to that number. This completes the encryption.

[0024] This invention is an encryption and decryption algorithm based on the theory of one-time codebook. For encryption and decryption, no key is required for encryption. The ciphertext can provide all the information needed for decryption. It is more suitable for scenarios with requirements on ciphertext length, such as small or micro QR code content. As can be seen from Tables 1 and 2 and the data comparison, in the "one item, one code" scenario, it supports high-concurrency encryption and decryption performance close to the standard AES algorithm.

[0025] Besides preventing brute-force attacks on the encrypted code, this invention also solves practical problems such as excessively long OTP codebooks, codebook storage, and distribution. This invention effectively prevents third parties from illegally interpreting the "one item, one code" generation rules of the traceability code through exhaustive search or traversal. It is more suitable for scenarios with high anti-counterfeiting levels, such as traceability codes and identity verification codes. Furthermore, the anti-counterfeiting code is generated through a special algorithm with three transformations, ensuring a globally unique solution and providing excellent protection for traceability codes across various industries.

[0026] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for preventing counterfeiting and encrypting based on the OTP principle, characterized in that, The method includes: Random number generation: The range of random ASCII codes is between lowercase letters a and z, i.e., 97 to 122. A random number is obtained from the closed interval of 97 to 122 and used as the random ASCII code. The plaintext string to be encrypted is converted into an ASCII code array. The values ​​of the ASCII code array are added together to obtain the maximum value Max. A random value is generated in the range [0, Max] as the power factor. The random ASCII code is escaped to obtain the plaintext letter t; The plaintext letter t is concatenated with the power factor to obtain the pre-parameter; The power factor is salted by adding the random ASCII code to the power factor to obtain the salted factor. The ASCII code array is traversed and plaintext is transcoded to obtain character numbers, and the salting factor is used to subtract the ASCII code of each character to obtain a new integer array; Each number in the new integer array is exponentially raised using a decreasing salt factor to obtain an encrypted byte array; The encrypted byte array is Base64 encoded to obtain a ciphertext string, and the ciphertext string is concatenated with the preceding parameters to obtain the final ciphertext.

2. A method for anti-counterfeiting and decryption based on the OTP principle, characterized in that, The method includes: After the final ciphertext to be decrypted is passed in, check if the keyword "@" exists; When the keyword "@" is present, the final ciphertext is split to obtain the pre-parameters and the ciphertext string; The preceding parameters are extracted and converted to obtain ASCII codes; The extracted pre-parameters, excluding the first letter, are used as exponents; The ciphertext string is decoded using Base64 to obtain an encrypted byte array; Each byte in the encrypted byte array is exponentially operated on using a decreasing salt factor to obtain the decrypted byte array; Each byte in the decrypted byte array is added to the ASCII code of its first letter to obtain the plaintext byte array; The plaintext byte array is converted into a string, which is the decrypted plaintext.

3. The anti-counterfeiting and decryption method based on the OTP principle according to claim 2, characterized in that: If the keyword "@" is not present in the final ciphertext, a decryption failure message will be returned.

4. The anti-counterfeiting and decryption method based on the OTP principle according to claim 2, characterized in that: The extraction and transformation of the pre-parameters are performed according to the generation rules.

Citation Information

Patent Citations

  • Generating random pass-phrases using word-level recurrent neural networks

    US20200251118A1

  • Random position cipher encryption using scrambled ascii strings

    US20220417000A1