A service code generation and verification method
Patent Information
- Application Number
- CN202210394013.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-14
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2042-04-14
AI Technical Summary
[0005]本发明的目的在于提供一种业务编码生成及校验方法,用于解决采用传统加密算法对业务编码进行加密时,业务人员难以判断业务编码中的业务含义,导致管理不方便的问题
[0005]本发明的目的在于提供一种业务编码生成及校验方法,用于解决采用传统加密算法对业务编码进行加密时,业务人员难以判断业务编码中的业务含义,导致管理不方便的问题。
Smart Images

Figure CN116961886B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for generating and verifying business codes, belonging to the field of data transmission encryption technology. Background Technology
[0002] In the construction of information systems, it is usually necessary to assign business codes to major business activities, and all subsequent activities must be carried out based on these business codes. Business codes should have a specific business meaning when generated, so that they can be checked and verified when business personnel input them to ensure their correctness. Because business codes are long and prone to input errors, and an incorrect business code can prevent subsequent business activities from proceeding, requiring business personnel to sift through a large number of codes to find the incorrect one, the workload is substantial. Therefore, business codes should have a self-validation function to quickly and accurately verify their accuracy during input.
[0003] In addition to having a specific business meaning, business codes also contain some sensitive data, which requires additional encryption protection. While encrypting business codes using traditional encryption techniques yields secure ciphertext, it's difficult to preserve the original code's format. This makes it hard for business personnel to interpret the business meaning within the ciphertext, leading to inconvenient management and operations.
[0004] Therefore, using traditional block cipher algorithms for encryption may lead to changes in data types, requiring modifications to the database or application to adapt to these changes and meet the application requirements of the encrypted data, resulting in high costs. Thus, there is an urgent need for a simple, easy-to-use, and low-cost method for generating business codes to encrypt sensitive data in business codes and provide self-verification functionality. Summary of the Invention
[0005] The purpose of this invention is to provide a method for generating and verifying business codes, which solves the problem that when business codes are encrypted using traditional encryption algorithms, business personnel have difficulty in judging the business meaning in the business codes, leading to inconvenience in management.
[0006] To achieve the above objectives, the present invention provides a business code generation method, comprising the following steps:
[0007] S1. Obtain the ontology code of the business code to be generated. The ontology code includes public code and sensitive code. Public code is the code segment that does not need to be encrypted, and sensitive code is the code segment that needs to be encrypted.
[0008] S2. For the ontology code obtained in step S1, calculate the sum of the sensitive code and the set offset to obtain the encrypted code. Concatenate the public code and the encrypted code to obtain a new ontology code. The set offset satisfies the following condition: the sum of the sensitive code and the set offset should be less than the maximum value of the current number of bits of the sensitive code.
[0009] S3. Encrypt the new ontology code obtained in step S2 to obtain the ciphertext corresponding to the new ontology code.
[0010] S4. Based on the ciphertext obtained in step S3, process the characters in the odd-numbered positions and / or even-numbered positions in the ciphertext to generate a verification code.
[0011] S5. Merge the new body code obtained in step S2 with the check code obtained in step S4 to generate the business code.
[0012] This invention, based on dividing the business code to be generated into public and sensitive codes, uses a summation method to encrypt the sensitive code by setting an offset, resulting in an encrypted code. A simple calculation method is then used to encrypt the data requiring encryption, hiding the sensitive data. The public and encrypted codes are concatenated to obtain a new body code, which is then encrypted to obtain ciphertext. A checksum is generated from the ciphertext, and the new body code and checksum are merged to generate the business code. Therefore, business personnel can glean certain business meaning from the business code without directly accessing sensitive data information, thus facilitating management while ensuring data security.
[0013] Furthermore, in the above method, in step S3, the MD5 message digest algorithm is used for encryption.
[0014] A specific encryption method is provided: the MD5 message digest algorithm, which is used to encrypt the new ontology code, making it easy to implement.
[0015] Furthermore, in the above method, the method for generating the check code in step S4 is as follows: sum the characters in the odd-numbered positions of the ciphertext to obtain the sum of the odd-numbered positions, take the modulus of the sum of the odd-numbered positions according to a randomly selected prime number, and use the obtained modulus value as the check code.
[0016] Furthermore, in the above method, the method for generating the check code in step S4 is as follows: sum the characters in the even-numbered positions of the ciphertext to obtain the sum of the even-numbered positions, take the modulus of the sum of the even-numbered positions based on a randomly selected prime number, and use the obtained modulus value as the check code.
[0017] The sum is calculated using only odd or even bits of characters in the ciphertext, and then modulo is taken from a randomly selected prime number. The modulo value is used as the check code, making the calculation simple.
[0018] Furthermore, in the above method, the method for generating the check code in step S4 is as follows: sum the characters in the odd-numbered positions of the ciphertext to obtain the odd-numbered position summation result, sum the characters in the even-numbered positions of the ciphertext to obtain the even-numbered position summation result, calculate the sum value based on the odd-numbered position summation result and the even-numbered position summation result, take the modulus of the sum value based on a randomly selected prime number, and use the obtained modulus value as the check code.
[0019] The sum of the characters in the odd and even positions of the ciphertext is calculated, and then the modulus is taken from a randomly selected prime number. The modulus value is used as the check code, which is a simple calculation.
[0020] Furthermore, in the above method, the sum is calculated as follows: the sum of odd-numbered digits is multiplied by a first set coefficient to obtain a first product, the sum of even-numbered digits is multiplied by a second set coefficient to obtain a second product, and the sum of the first product and the second product is taken as the sum; the first set coefficient and the second set coefficient are both randomly selected integers and are different.
[0021] When calculating the sum, multiplying the sum of odd-numbered digits and the sum of even-numbered digits by a set coefficient can enhance the security of the check code.
[0022] Furthermore, in the above method, when generating a business code each time, a fixed randomly selected integer is used as a first set coefficient to calculate the first product, and another fixed randomly selected integer is used as a second set coefficient to calculate the second product.
[0023] Each time a business code is generated, the same first set coefficient is used to calculate the first product when calculating the sum value, and the same second set coefficient is used to calculate the second product, resulting in a small data storage volume.
[0024] Furthermore, in the above method, each time a business code is generated, an integer is randomly selected as a first set coefficient to calculate a first product, and another integer is randomly selected as a second set coefficient to calculate a second product.
[0025] Each time a business code is generated, a different first set coefficient is used to calculate the first product when calculating the sum value, and a different second set coefficient is used to calculate the second product. The verification code calculated in this way has a higher level of security.
[0026] This invention also provides a service code verification method, wherein the service code to be verified is obtained using the above-described service code generation method, and the service code to be verified includes a body code to be verified and a verification code; the service code verification method includes the following steps:
[0027] S1. Using the method of encrypting the ontology code when generating the business code to be verified, encrypt the ontology code to be verified to obtain the ciphertext corresponding to the ontology code to be verified.
[0028] S2. For the ciphertext obtained in step S1, generate a verification code using the method of generating a verification code when generating a business code to be verified.
[0029] S3. If the verification code generated in step S2 is the same as the verification code of the service code to be verified, then the service code to be verified is correct; otherwise, the service code to be verified is incorrect.
[0030] When verifying the business code, a verification code is generated based on the body code in the business code, using the same method used when the business code was generated. Then, the verification code is compared with the verification code built into the business code. If they are the same, the business code is correct; otherwise, it is incorrect. This implements the self-verification function of the business code. Attached Figure Description
[0031] Figure 1 This is a flowchart of the business code generation method in an embodiment of the business code generation method of the present invention;
[0032] Figure 2 This is a flowchart of the business code verification method in an embodiment of the present invention. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0034] This invention, based on dividing the business code to be generated into public and sensitive codes, uses a summation method to encrypt the sensitive code by setting an offset, resulting in an encrypted code. A simple calculation method is then used to encrypt the data requiring encryption, hiding the sensitive data. The public and encrypted codes are then concatenated to obtain a new body code, which is then encrypted to obtain ciphertext. A checksum is generated from the ciphertext, and the new body code and checksum are merged to generate the business code. Therefore, business personnel can glean certain business meaning from the business code without directly accessing sensitive data information, thus facilitating management while ensuring data security.
[0035] Taking a budget information system as an example, the business code generation method and business code verification method of the present invention will be described. The budget information system includes a budget generation module and a budget entry module. In the practical application of this budget information system, it is necessary to generate budget business codes that represent budget business information for use in subsequent budget, project, and contract business processes. The budget business codes are required to reflect certain business meanings, have self-verification functions, and be simple and easy to use.
[0036] Example of a business code generation method:
[0037] like Figure 1 As shown, the business code generation method of the present invention includes the following steps when generating budget business codes:
[0038] 1) Based on pre-defined business coding rules, the ontology code of the budget business code is generated in the budget generation module. In this embodiment, the ontology code of the budget business code to be generated is "WL2021080001". This ontology code will be used as an example to illustrate the present invention.
[0039] The body code "WL2021080001" consists of a 12-digit combination of numbers and letters, which can be divided into three parts according to business meaning. The first part "WL" is the department prefix code used to represent the department. The second part "202108" is the date prefix code used to represent the date. The third part "0001" is the maximum sequence number used to represent the number of times the current department generates a budget under the current date.
[0040] For the budget business code in this embodiment, "WL202108" is the public code segment that does not need encryption, and "0001" is the code segment that needs encryption. For other business codes to be generated, they can also be divided into public code segments that do not need encryption and sensitive code segments that need encryption.
[0041] In this embodiment, the date prefix code uses a combination of year and month. As another implementation method, the budget can also be managed by quarter, in which case the date prefix code can use a combination of year and quarter.
[0042] In this embodiment, the maximum sequence number has 4 digits. When using this invention, the number of digits in the maximum sequence number can be increased or decreased according to the actual situation. "0001" is used as the initial number of the maximum sequence number. Each time a budget is generated, 1 is added to the maximum sequence number.
[0043] 2) The budget generation module performs an offset overlay process on the ontology code. A set offset is added to the sensitive coding segment to obtain an encrypted coding segment. This encrypted coding segment is then concatenated with the public coding segment to obtain a new ontology code. The set offset should be selected according to the following principle: the value obtained by adding the set offset to the maximum sequence number should be less than the maximum value of the current digits of the maximum sequence number. Alternatively, the set offset can be selected based on the current digits of the maximum sequence number, with the set offset being one digit less than the current digits of the maximum sequence number.
[0044] In this embodiment, the current number of digits of the maximum sequence number is 4, and the maximum value of the current number of digits is 9999. The offset is set to 128. After performing the superposition offset processing on the body code "WL2021080001", the new body code is "WL2021080129".
[0045] 3) The budget generation module uses an encryption algorithm to encrypt the new ontology code, obtaining the ciphertext corresponding to the new ontology code.
[0046] When generating different business codes, for different body codes, using other encryption algorithms, such as the DES (Data Encryption Standard) symmetric encryption algorithm, may generate the same ciphertext, while using the MD5 message-digest algorithm can obtain a unique ciphertext. Therefore, in this embodiment, the encryption algorithm uses the common MD5 message-digest algorithm to encrypt, which can obtain a 32-bit unique ciphertext: "a36f0091c5e8eac736361ee470c09dff".
[0047] 4) The budget generation module processes the ciphertext corresponding to the new ontology code to generate a checksum. The methods for generating the checksum include the following four:
[0048] Method 1: Summate the ASCII values of the characters in the odd-numbered positions of the ciphertext. The result of summing the odd-numbered positions is represented as: oddSum = 453. The budget generation module obtains a randomly selected prime number n, and takes the modulo of the sum of the odd-numbered positions using this prime number n. The modulo value is then used as the checksum.
[0049] Method 2: Summate the ASCII values of the characters in the even-numbered positions of the ciphertext. The result of summing the even-numbered positions is represented as: evenSum = 302. The budget generation module obtains a randomly selected prime number n, and takes the modulo of the sum of the even-numbered positions using this prime number n, obtaining the modulo value as the checksum.
[0050] Method 3: Sum the ASCII values of characters in odd-numbered positions of the ciphertext, and also sum the ASCII values of characters in even-numbered positions of the ciphertext.
[0051] The sum of odd-numbered digits is represented as: oddSum = 453.
[0052] The sum of even-numbered digits is represented as: evenSum = 302.
[0053] The budget generation module calculates the sum of oddSum and evenSum, and obtains a randomly selected prime number n. It then uses this prime number n to take the modulo of the sum of oddSum and evenSum, and uses the modulo value as the check code.
[0054] Method 4: Sum the ASCII values of characters in odd-numbered positions of the ciphertext, and also sum the ASCII values of characters in even-numbered positions of the ciphertext.
[0055] The sum of odd-numbered digits is represented as: oddSum = 453.
[0056] The sum of even-numbered digits is represented as: evenSum = 302.
[0057] The budget generation module obtains two randomly selected distinct positive integers as set coefficients w1 and w2, calculates the product of oddSum and w1, and also calculates the product of evenSum and w2, thus calculating the total sum. Then, the budget generation module obtains a randomly selected prime number n, and uses this prime number n to take the modulo of the total sum, obtaining the modulo value as a check code.
[0058] This invention uses two pre-selected, unique, and distinct positive integers as pre-defined coefficients for calculation each time a business code is generated. The budget generation module then stores these pre-defined coefficients in a database for use during business code verification.
[0059] In another implementation, the present invention may randomly select different positive integers as preset coefficients for calculation each time a business code is generated. In this case, when the budget generation module generates the final business code, it associates the business code with the preset coefficients and stores them in the database for use during business code verification.
[0060] In this embodiment, the same set of set coefficients is used for calculation each time a service code is generated, and the set coefficients are randomly selected integers between 2 and 99. The set coefficients are: w1 = 3, w2 = 77. The sum is expressed as: sum = oddSum × 3 + evenSum × 77 = 24613.
[0061] Similar to setting coefficients, this invention can use a pre-randomized two-digit prime number for calculation each time a business code is generated. The budget generation module then stores this prime number in a database for use during business code verification.
[0062] In another implementation, the present invention may randomly select different two-digit prime numbers for calculation each time a business code is generated. In this case, when the budget generation module generates the final business code, it will also associate the business code with the prime number and store it in the database for use during business code verification.
[0063] In this embodiment, the randomly selected prime number n is 97. The result obtained by taking the modulo is: checkNum = 24613 mod 97 = 72.
[0064] 5) The budget generation module combines the new ontology code obtained in step 2) with the check code obtained in step 5) to generate the final business code.
[0065] In this embodiment, the final budget business code is represented as: WL202108012972.
[0066] Example of a business code verification method:
[0067] Taking the budget business code generated in the embodiment of the business code generation method as an example, the business code verification method of the present invention will be described. When a business operator enters a budget business code in the budget entry module, such as... Figure 2 As shown, the business code verification method of the present invention includes the following steps:
[0068] 1. For the business code to be verified, including the body code and the verification code, the budget entry module uses the method of encrypting the body code when generating the business code to encrypt the body code to be verified, thus obtaining the ciphertext corresponding to the body code to be verified.
[0069] 2. Based on the ciphertext obtained in step 1, calculate the verification code according to the method used to generate the verification code when generating the business code to be verified.
[0070] If the method for reviewing the verification code when generating the business code to be verified is Method 1, then the same method is used to calculate the result obtained by summing the odd-numbered digits. Then, the budget entry module selects the random prime number n used when generating the business code to be verified from the database, takes the modulo of the result obtained by summing the odd-numbered digits, and obtains the verification code.
[0071] If the method for reviewing the verification code when generating the business code to be verified is Method 2, then the same method is used to calculate the result obtained by summing the even-numbered digits. Then, the budget entry module selects the random prime number n used when generating the business code to be verified from the database, takes the modulo of the result obtained by summing the even-numbered digits, and obtains the verification code.
[0072] If the method for reviewing the verification code when generating the business code to be verified is Method 3, then the same method is used to calculate the result of summing the odd-numbered digits and the result of summing the even-numbered digits, and then the total value is calculated. Then, the budget entry module selects the random prime number n used when generating the business code to be verified from the database, takes the modulo of the total value, and obtains the verification code.
[0073] If the method for reviewing the verification code when generating the business code to be verified is Method 4, then the set coefficients are extracted from the database, and the sum is calculated. If two unique and different positive integers are pre-selected randomly as set coefficients for calculation each time a business code is generated, then the budget entry module also extracts these two set coefficients for calculation. If different positive integers are randomly selected as set coefficients for calculation each time a business code is generated, then the budget entry module extracts a set of set coefficients corresponding to the business code to be verified from the database for calculation. Then, the budget entry module selects the random prime number n used when generating the business code from the database, takes the modulo of the sum, and obtains the verification code.
[0074] If the same randomly selected prime number is used for calculation each time a business code is generated, the budget entry module will also extract this prime number for calculation. If different randomly selected prime numbers are used for calculation each time a business code is generated, the budget entry module will extract the corresponding prime number for the business code to be verified from the database for calculation.
[0075] 3. Compare the verification code obtained in step 2 with the verification code of the service code to be verified in step 1. If they are the same, it means that the service code to be verified is correct and the verification passes; if they are different, it means that the service code to be verified is incorrect and the verification fails.
[0076] When a business user enters a budget business code into the budget entry module, such as WL2021081129, the module calculates a verification code of 59, which is different from the verification code of 72 for that budget business code. This indicates that the budget business code is incorrect and the verification fails.
[0077] The business code generation and verification method of the present invention encrypts only the sensitive information in the business code, while retaining some of the business information in the business code. This not only enables the self-verification function of the business code, ensuring the integrity, consistency and security of information transmission, but also makes it convenient for business personnel to view and use.
Claims
1. A method for generating business codes, characterized in that, Includes the following steps: S1. Obtain the ontology code of the business code to be generated. The ontology code includes public code and sensitive code. Public code is the code segment that does not need to be encrypted, and sensitive code is the code segment that needs to be encrypted. S2. For the ontology code obtained in step S1, calculate the sum of the sensitive code and the set offset to obtain the encrypted code. Concatenate the public code and the encrypted code to obtain a new ontology code. The set offset satisfies the following condition: the sum of the sensitive code and the set offset should be less than the maximum value of the current number of bits of the sensitive code. S3. Encrypt the new ontology code obtained in step S2 using the MD5 message digest algorithm to obtain the ciphertext corresponding to the new ontology code. S4. Based on the ciphertext obtained in step S3, process the characters in the odd-numbered positions and / or even-numbered positions in the ciphertext to generate a verification code. S5. Merge the new body code obtained in step S2 with the check code obtained in step S4 to generate the business code. The processing of the characters in step S4 includes summing the ASCII values of only the odd-numbered characters in the ciphertext, summing the ASCII values of only the even-numbered characters in the ciphertext, and summing the ASCII values of both the odd-numbered and even-numbered characters in the ciphertext.
2. The business code generation method according to claim 1, characterized in that, The publicly available codes include department prefix codes and date prefix codes.
3. The business code generation method according to claim 1, characterized in that, The method for generating the check code in step S4 is as follows: sum the characters in the odd-numbered positions of the ciphertext to obtain the sum of the odd-numbered positions, take the modulus of the sum of the odd-numbered positions based on a randomly selected prime number, and use the obtained modulus value as the check code.
4. The business code generation method according to claim 1, characterized in that, The method for generating the check code in step S4 is as follows: sum the characters in the even-numbered positions of the ciphertext to obtain the sum of the even-numbered positions, take the modulus of the sum of the even-numbered positions based on a randomly selected prime number, and use the obtained modulus value as the check code.
5. The business code generation method according to claim 1, characterized in that, The method for generating the check code in step S4 is as follows: sum the characters in the odd-numbered positions of the ciphertext to obtain the odd-numbered position sum result, sum the characters in the even-numbered positions of the ciphertext to obtain the even-numbered position sum result, calculate the total sum based on the odd-numbered position sum result and the even-numbered position sum result, take the modulus of the total sum value based on a randomly selected prime number, and use the obtained modulus value as the check code.
6. The business code generation method according to claim 5, characterized in that, The sum is calculated as follows: multiply the sum of the odd-numbered digits by a first set coefficient to obtain the first product, multiply the sum of the even-numbered digits by a second set coefficient to obtain the second product, and use the sum of the first product and the second product as the total sum. The first set coefficient and the second set coefficient are both randomly selected integers and are different.
7. The business code generation method according to claim 6, characterized in that, Each time a business code is generated, a fixed, randomly selected integer is used as the first set coefficient to calculate the first product, and another fixed, randomly selected integer is used as the second set coefficient to calculate the second product.
8. The business code generation method according to claim 6, characterized in that, Each time a business code is generated, an integer is randomly selected as the first set coefficient to calculate the first product, and another integer is randomly selected as the second set coefficient to calculate the second product.
9. A business code verification method, characterized in that, The service code to be verified is obtained using the service code generation method according to any one of claims 1-8, and the service code to be verified includes a body code to be verified and a verification code; the service code verification method includes the following steps: S1. Using the method of encrypting the ontology code when generating the business code to be verified, the ontology code to be verified is encrypted to obtain the ciphertext corresponding to the ontology code to be verified. S2. For the ciphertext obtained in step S1, generate a verification code using the method of generating a verification code when generating a business code to be verified. S3. If the verification code generated in step S2 is the same as the verification code of the service code to be verified, then the service code to be verified is correct; otherwise, the service code to be verified is incorrect.
Citation Information
Patent Citations
Sensitive information management control method and apparatus
CN105468990A
Segmented anti-false coding method
CN1444132A