A method and system for generating form code with check digit
The method and system generate a form code with a check digit using timestamp, service, and CRC algorithms to enhance security and reliability, addressing brute force cracking and ensuring unique, reliable data storage.
Patent Information
- Application Number
- CN202110746378.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-01
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2041-07-01
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of business system security, and specifically provides a method and system for generating a form code with a check digit. Background Art
[0002] In existing business systems, the form code generation rule is generally to generate an ordered ID according to the snowflake algorithm. This method can effectively ensure the uniqueness of the ID in a distributed environment, but it also has the risk of brute force cracking. As a string in pure digital form, there is no specific distinction rule and it is not suitable as a business form system storage identifier to maintain business data. In specific business applications, in order to solve the risk of brute force cracking of the unique code generated by the snowflake algorithm, it is of great significance to consider increasing business recognition. Summary of the invention
[0003] The technical task of the present invention is to provide a method for generating a form code with a check digit that can improve the security of the business system and increase the reliability of code generation and verification flexibility while ensuring uniqueness, in response to the above-mentioned problems.
[0004] A further technical task of the present invention is to provide a form code generation system with a check digit.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] A method for generating a form code with a check digit comprises the following steps:
[0007] S1, timestamp bit generation;
[0008] S2, service bit generation;
[0009] S3. Check digit generation.
[0010] Preferably, in step S1, the timestamp bit is converted into a corresponding binary value with a thirteen-digit timestamp as the starting value, and the number of 1s is taken as the basis for generating the check bit.
[0011] Preferably, in step S1, hexadecimal is converted as the first part of the form encoding.
[0012] Taking the 2621662961908 timestamp as an example, it can be guaranteed that the timestamps generated before 2053-01-28 are all 8 bits.
[0013] Preferably, in step S2, the service bit is generated based on the thirteen-digit timestamp. After removing the first digit, the twelve-digit decimal number is retained as the starting value, which is converted into the corresponding binary value, and the number of 1s is taken as the basis for generating the check bit.
[0014] Preferably, in step S2, hexadecimal is converted as the second part of the form encoding.
[0015] Taking the 19999999999999 timestamp as an example, it can be guaranteed that the timestamps generated before 2033-05-18 are all 8 bits.
[0016] Preferably, in step S3, the check bit is generated from the timestamp bit into binary, the number of 1s is taken and the number of 1s is taken as a basis, and the remainder of thirty-six is taken and converted into hexadecimal in combination with the CRC algorithm.
[0017] Among them, the cyclic redundancy check code CRC, referred to as cyclic code, is a commonly used check code with error detection and correction capabilities. It is widely used in early communications. Cyclic redundancy check codes are often used for data verification of external storage and computer synchronous communication. Parity check codes and Hamming check codes both use parity detection as a means of error detection and correction (parity check codes do not have error correction capabilities), while cyclic redundancy check uses some mathematical operations to establish the agreed relationship between data bits and check bits.
[0018] A form code generation system with a check digit comprises a timestamp digit generation module, a service digit generation module and a check digit generation module. The timestamp digit generation module is used to generate timestamp digits, the service digit generation module is used to generate timestamp digits, and the service digit generation module is used to generate service digits.
[0019] Preferably, in the timestamp bit generation module, the timestamp bit takes the thirteen-digit timestamp as the starting value, is converted into the corresponding binary value, the number of 1s is taken as the basis for generating the check bit, and the thirty-hexadecimal is converted as the first part of the form encoding.
[0020] Preferably, in the service bit generation module, the service bit is generated based on a thirteen-digit timestamp. After removing the first digit, the twelve-digit decimal number is retained as the starting value, which is converted into a corresponding binary value. The number of 1s is taken as the basis for generating the check bit, and the thirty-hexadecimal is converted as the second part of the form code.
[0021] Preferably, in the check bit module, the check bit is generated by the timestamp bit, the number of 1s is taken as a basis, and the number of 1s is taken as a basis, combined with the CRC algorithm, the remainder of thirty-six is taken and converted into hexadecimal.
[0022] Compared with the prior art, the method for generating a form code with a check digit of the present invention has the following outstanding beneficial effects:
[0023] (1) The method for generating a form code with a check digit can improve the security of the business system. Before initiating a valid request, the request parameters can be checked by the check digit. When the system encounters a brute force cracking by exhaustive method, the number of database accesses can be effectively reduced;
[0024] (2) The business logic is simple. In the actual application process, the logic can be flexibly disassembled and combined according to the needs. The final form code generation length is fixed, which prevents the code length from mutating during the limited life cycle of the system. It can be used as a naming standard and reference for data storage and has good promotion and application value. DETAILED DESCRIPTION
[0025] The following will further describe in detail the method and system for generating a form code with a check digit according to the present invention in conjunction with embodiments.
[0026] Example
[0027] The method for generating a form code with a check digit of the present invention comprises the following steps:
[0028] S1. Timestamp bit generation.
[0029] The timestamp bit takes the current 13-digit timestamp as the starting value, and the first step is to convert it into the corresponding binary value, taking the number of 1s as the basis for generating the check digit; converting it into 36-bit as the first part of the form code. According to this generation strategy, taking the timestamp 2621662961908 as an example, it can be guaranteed that the timestamp bits generated before 2053-01-28 are all 8 bits.
[0030] The details are as follows:
[0031] S2. Service bit generation.
[0032] The service bit is based on the current 13-digit timestamp. After removing the first digit, the 12-digit decimal number is retained as the starting value. The first step is to convert it into the corresponding binary value, and take the number of 1s as the basis for generating the check digit; convert it into 36-bit as the second part of the form code. According to this generation strategy, taking the 19999999999999 timestamp as an example, it can be guaranteed that the timestamps generated before 2033-05-18 are all 8 bits.
[0033] The details are as follows:
[0034] S3. Check digit generation.
[0035] The check bit is based on the number of 1s generated by the timestamp bit and the number of 1s generated by the service bit, combined with the CRC algorithm, and the remainder of 36 is taken and converted into hexadecimal.
[0036] Among them, the cyclic redundancy check code CRC, referred to as cyclic code, is a commonly used check code with error detection and correction capabilities. It is widely used in early communications. Cyclic redundancy check codes are often used for data verification of external storage and computer synchronous communication. Parity check codes and Hamming check codes both use parity detection as a means of error detection and correction (parity check codes do not have error correction capabilities), while cyclic redundancy check uses some mathematical operations to establish the agreed relationship between data bits and check bits.
[0037] The details are as follows:
[0038] The method for generating form codes with check digits of the present invention has been put into practical use in the government affairs quick-access system. Because the system adopts the application + form division logic, the timestamp digit is used as the application code, and the service digit + check digit is used as the form code during actual use, ensuring that the forms of the same application have the same combined prefix, thereby increasing the recognition of the business.
[0039] The form code generation system with check digit of the present invention comprises a timestamp digit generation module, a service digit generation module and a check digit generation module. The timestamp digit generation module is used to generate timestamp digits, the service digit generation module is used to generate timestamp digits, and the service digit generation module is used to generate service digits.
[0040] In the timestamp bit generation module, the timestamp bit takes the thirteen-digit timestamp as the starting value, is converted into the corresponding binary value, the number of 1s is taken as the basis for generating the check bit, and the thirty-hexadecimal is converted as the first part of the form encoding.
[0041] In the service bit generation module, the service bit generation is based on the thirteen-digit timestamp. After removing the first digit, the twelve-digit decimal number is retained as the starting value, converted into the corresponding binary value, and the number of 1s is taken as the basis for generating the check bit, and converted into hexadecimal as the second part of the form code.
[0042] In the check bit module, the check bit is generated by the timestamp bit to generate binary, the number of 1s is taken and the number of 1s is taken as the basis, combined with the CRC algorithm, the remainder of thirty-six is taken and converted into thirty-six hexadecimal.
[0043] The embodiments described above are only preferred specific implementations of the present invention. Common changes and substitutions made by those skilled in the art within the scope of the technical solution of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for generating a form code with a check digit, characterized in that: The following steps are involved: S1. Generate the timestamp bit. The timestamp bit takes the 13-digit timestamp as the starting value, converts it into the corresponding binary value, takes the number of 1 as the basis for generating the check bit, and converts it into hexadecimal as the first part of the form code; S2, service bit generation, the service bit generation is based on the thirteen-digit timestamp, after removing the first digit, retaining the twelve-digit decimal number as the starting value, converting it to the corresponding binary value, taking the number of 1 as the basis for generating the check bit, and converting it to hexadecimal as the second part of the form code; S3. Check bit generation: the check bit is generated by using the timestamp bit to generate binary, taking the number of 1s and the service bit to generate binary and taking the number of 1s as the basis, combined with the CRC algorithm, taking the remainder of thirty-six and converting it into hexadecimal.
2. A form code generation system with a check digit, characterized in that: It includes a timestamp bit generation module, a service bit generation module and a check bit generation module, wherein the timestamp bit generation module is used to generate timestamp bits, the service bit generation module is used to generate service bits, and the check bit generation module is used to generate check bits; In the timestamp bit generation module, the timestamp bit takes the thirteen-digit timestamp as the starting value, is converted into the corresponding binary value, the number of 1s is taken as the basis for generating the check bit, and the thirty-sixth digit is converted as the first part of the form code; in the service bit generation module, the service bit generation is based on the thirteen-digit timestamp, after removing the first digit, the twelve-digit decimal number is retained as the starting value, converted into the corresponding binary value, the number of 1s is taken as the basis for generating the check bit, and the thirty-sixth digit is converted as the second part of the form code; in the check bit module, the check bit is generated from the timestamp bit, the number of 1s is taken and the number of 1s taken by the service bit is used as the basis for generating the binary, combined with the CRC algorithm, the remainder of thirty-six is taken and converted into thirty-sixth digits.
Citation Information
Patent Citations
Method for implementing encoding mechanism based on time stamp rule
CN104252441A
Application program test method, device and system
CN104794050A
Unique identifier of distributed system and generation method thereof
CN111353275A
Method for generating token seed and two-dimensional code, payment method and device
CN112330323A
Distributed ID generation method and device
CN112579566A
