Verification code generation method, device, electronic device and computer storage medium
By splicing the predicted value in the preprocessing splicing table with the CRC check code of the second part of the data, the problem of high computational complexity in splicing CRC check code in the existing technology is solved, and an efficient and low-cost CRC check is achieved. Code splicing.
Patent Information
- Application Number
- CN202010216411.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-25
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2040-03-25
AI Technical Summary
When generating the overall CRC check code, the prior art fails to effectively utilize the CRC check code of the known second part of data, resulting in high computational complexity and poor performance.
Through the pre-set preprocessing splicing table, the predicted value corresponding to the CRC check code of the first part of the data is determined, and spliced with the CRC check code of the second part of the data to generate the spliced CRC check code.
The CRC check code of the second part of the data is effectively utilized, reducing the computational complexity, improving performance, and realizing splicing without considering the specific CRC check code value.
Smart Images

Figure CN113448764B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a verification code generation method, device, electronic device and computer storage medium. Background Art
[0002] CRC (Cyclic Redundancy Check) is a hash function that generates a short fixed-bit check code based on data such as online data packets or computer files. It is mainly used to detect or verify errors that may occur after data transmission or storage.
[0003] In the scenario of using CRC to generate checksums for error verification, there is a situation where two parts of data are known, the first part of the data is N bytes of non-fixed byte data, and the second part of the data is fixed bytes such as 4096 bytes of data and its corresponding CRC checksum, and the CRC checksum of the entire N+4096 bytes of data needs to be calculated. In this scenario, CRC checksum splicing is required.
[0004] Currently, one solution for realizing the CRC check code concatenation of the two parts of data in the above situation is: using the CRC check code of the first part of data as an initial value, and recalculating the CRC check code of the second part of data.
[0005] However, this splicing method does not effectively utilize the known CRC check code of the second part of the data, increases the computational complexity of the splicing CRC check code, has a high computational cost, and has poor performance. Summary of the invention
[0006] In view of this, an embodiment of the present invention provides a verification code generation solution to at least partially solve the above problem.
[0007] According to a first aspect of an embodiment of the present invention, a check code generation method is provided, comprising: obtaining a first cyclic redundancy check code of a first portion of data to be spliced with a check code; determining a prediction value corresponding to the first cyclic redundancy check code from a preset preprocessing splicing table, wherein the length of the preprocessing splicing table is the same as the length of a second cyclic redundancy check code of a second portion of data to be spliced with a check code, and the preprocessing splicing table stores prediction values obtained by enumerating cyclic redundancy check codes; and generating a spliced cyclic redundancy check code according to the length based on the determined prediction value and the second cyclic redundancy check code.
[0008] According to a second aspect of an embodiment of the present invention, a check code generating device is provided, comprising: an acquisition module, used to acquire a first cyclic redundancy check code of a first part of data to be spliced with a check code; a determination module, used to determine a prediction value corresponding to the first cyclic redundancy check code from a preset preprocessing splicing table, wherein the length of the preprocessing splicing table is the same as the length of the second cyclic redundancy check code of the second part of data to be spliced with the check code, and the preprocessing splicing table stores the prediction value obtained by enumerating the cyclic redundancy check code; and a generation module, used to generate a spliced cyclic redundancy check code according to the length based on the determined prediction value and the second cyclic redundancy check code.
[0009] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the verification code generation method described in the first aspect.
[0010] According to a fourth aspect of an embodiment of the present invention, there is provided a computer storage medium on which a computer program is stored. When the program is executed by a processor, the verification code generation method as described in the first aspect is implemented.
[0011] According to the verification code generation scheme provided by the embodiment of the present invention, a pre-processing splicing table is pre-set in the system. On the one hand, the length of the pre-processing splicing table is the same as the length of the second CRC verification code to be spliced with the verification code, which is convenient for splicing with the second CRC verification code; on the other hand, the pre-processing splicing table stores the predicted values obtained by enumerating the CRC verification code, that is, the predicted values in the pre-processing splicing table can include all possible CRC verification codes. Therefore, no matter what kind of first CRC verification code, the corresponding predicted value can be found in the pre-processing splicing table, and then it can be directly spliced with the second CRC verification code to be spliced to generate a total CRC verification code corresponding to the first part of the data and the second part of the data. Therefore, the scheme provided by the embodiment of the present invention effectively utilizes the CRC verification code of the second part of the data to be spliced, can realize the CRC verification code splicing at low cost and high efficiency, and is simple to implement, reducing the computational complexity. In addition, the splicing of the first CRC verification code and the second CRC verification code without considering the specific CRC verification code value is realized. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0013] Figure 1A This is a flowchart of a verification code generation method according to Embodiment 1 of the present invention;
[0014] Figure 1B for Figure 1A A schematic diagram of an example scenario in the illustrated embodiment;
[0015] Figure 2A This is a flowchart of a verification code generation method according to Embodiment 2 of the present invention;
[0016] Figure 2B for Figure 2A A schematic diagram of grouping of a preprocessing splicing table in the illustrated embodiment;
[0017] Figure 3 is a structural block diagram of a verification code generating device according to Embodiment 3 of the present invention;
[0018] Figure 4 is a structural block diagram of a verification code generating device according to Embodiment 4 of the present invention;
[0019] Figure 5 FIG. 4 is a schematic diagram of the structure of an electronic device according to Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0020] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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. All other embodiments obtained by ordinary technicians in the field based on the embodiments in the embodiments of the present invention should fall within the scope of protection of the embodiments of the present invention.
[0021] The specific implementation of the embodiment of the present invention is further described below in conjunction with the accompanying drawings of the embodiment of the present invention.
[0022] Embodiment 1
[0023] Reference Figure 1A , shows a flow chart of the steps of a verification code generation method according to embodiment 1 of the present invention.
[0024] The verification code generation method of this embodiment includes the following steps:
[0025] Step S102: Obtain a first CRC check code of a first portion of data to be spliced with check codes.
[0026] As mentioned above, the solution provided by the embodiment of the present invention is applicable to the case where the first part of the data is non-fixed byte data of N bytes, and the second part of the data is fixed byte or non-fixed byte data, wherein the first part of the data corresponds to a first CRC check code, and the second part of the data corresponds to a second CRC check code. Based on this, it is necessary to calculate the overall CRC check code of the first part of the data and the second part of the data by splicing the CRC check codes.
[0027] When the second part of the data is fixed bytes, there is no need to set multiple preprocessing splicing tables; when the second part of the data is non-fixed bytes, it is necessary to set different multiple preprocessing splicing tables according to the lengths of multiple different CRC check codes.
[0028] Step S104: determining a prediction value corresponding to the first cyclic redundancy check code from a preset preprocessing concatenation table.
[0029] The length of the preprocessing splicing table is the same as the length of the second CRC check code of the second part of the data to be spliced with the check code, and the preprocessing splicing table stores the predicted value obtained by enumerating the CRC check code.
[0030] The length of the preprocessing splicing table is set to be the same as the length of the second CRC check code to be spliced with the check code, so that it can be directly spliced with the second CRC check code without further processing related to the data length, which greatly improves the check code splicing speed and efficiency. On the other hand, the predicted value in the preprocessing splicing table is obtained by enumerating the CRC check code, which can almost cover all possible CRC check code values. Therefore, no matter what the first part of the data is, its first CRC check code can be found in the preprocessing splicing table, that is, the preprocessing splicing table can be applied to most of the data and has strong compatibility.
[0031] Step S106: Generate a concatenated CRC check code according to the determined predicted value and the second CRC check code according to the length.
[0032] After the predicted value corresponding to the first CRC check code is determined from the preprocessing splicing table, the check code splicing can be performed, and the spliced CRC check code is generated based on the predicted value and the second CRC check code of the second part of the data. Since the length of the preprocessing splicing table is the same as the length of the second CRC check code, the spliced CRC check code can be generated according to the length, and the length of the spliced CRC check code is the same as the length of the preprocessing splicing table or the length of the second CRC check code.
[0033] An example of a scenario of the above process is as follows Figure 1B As shown, Figure 1B In the example, it is assumed that the two parts of the received data need to be combined and stored at the cloud server, where the first part of the data has a 32-bit first CRC check code (shown as CRC1 in the figure), and the 32-bit first CRC check code is divided into 8 groups, each with 4 bits. It is also assumed that the predicted value in the preprocessing splicing table is also stored in 4 bits, because the preprocessing splicing table is generated by enumerating CRC check codes, and each group corresponds to 2 4 That is, 16 prediction values. Based on this, the prediction value in the preprocessing splicing table is determined according to the check code value of each group in the first CRC check code. Figure 1B The above r1, r2...r8 are respectively shown as r1, r2...r8 corresponding to 8 groups of CRC1. The above r1, r2...r8 are spliced with the second CRC check code corresponding to the second part of the data (shown as CRC2 in the figure), that is, an XOR operation is performed to generate a CRC check code corresponding to the first part of the data and the second part of the data as a whole. Figure 1B Indicated as CRC_TOTAL.
[0034] Through this embodiment, a preprocessing splicing table is pre-set in the system. On the one hand, the length of the preprocessing splicing table is the same as the length of the second CRC check code to be spliced with the check code, which is convenient for splicing with the second CRC check code; on the other hand, the preprocessing splicing table stores the predicted values obtained by enumerating the CRC check code, that is, the predicted values in the preprocessing splicing table can include all possible CRC check codes. Therefore, no matter what kind of first CRC check code, the corresponding predicted value can be found in the preprocessing splicing table, and then it can be directly spliced with the second CRC check code to be spliced to generate a total CRC check code corresponding to the first part of the data and the second part of the data. Therefore, the solution provided by this embodiment effectively utilizes the CRC check code of the second part of the data to be spliced, can realize the CRC check code splicing at low cost and high efficiency, and is simple to implement, reducing the computational complexity. In addition, the splicing of the first CRC check code and the second CRC check code without considering the specific CRC check code value is realized.
[0035] The verification code generation method of this embodiment can be executed by any appropriate electronic device with data processing capability, including but not limited to: a server, a mobile terminal (such as a mobile phone, a PAD, etc.) and a PC, etc.
[0036] Embodiment 2
[0037] Reference Figure 2A , shows a flow chart of the steps of a verification code generation method according to embodiment 2 of the present invention.
[0038] In this embodiment, the second part of data is data with a fixed length, that is, the second part of data has bytes of a fixed length as an example to illustrate the method for generating a check code in the embodiment of the present invention. However, those skilled in the art should understand that the generation of a check code for the case of non-fixed-length second part of data can refer to this embodiment.
[0039] The verification code generation method of this embodiment includes the following steps:
[0040] Step S202: Generate a preprocessing splicing table.
[0041] When the second part of the data is fixed-length data, if the storage space is sufficient, a preprocessing splicing table can be used. As mentioned above, the preprocessing splicing table is used to store the predicted value obtained by enumerating the CRC check code, and the length of the preprocessing splicing table is the same as the length of the second CRC check code of the second part of the data to be spliced with the check code.
[0042] In a feasible manner, the preprocessing splicing table can be divided into a preset number of groups according to the length of the preprocessing splicing table; for each group, a cyclic redundancy calculation is performed according to the enumeration value of the current group, and the cyclic redundancy calculation result is stored corresponding to the current group; and the preprocessing splicing table is generated according to the cyclic redundancy calculation results of each group. In this way, the prediction value of each group in the preprocessing splicing table can be quickly generated.
[0043] Since the length of the preprocessing splicing table is the same as the length of the second CRC check code, in practical applications, whether the grouping is based on the length of the preprocessing splicing table or the length of the second CRC check code, the two can be kept consistent. It should be noted that the number of groups is related to the efficiency of the subsequent query of the first CRC check code in the table. Therefore, the specific number of groups can be set by those skilled in the art according to actual needs, and the number of groups is greater than or equal to 1.
[0044] For example, Figure 2B As shown, assuming that the length of the preprocessing concatenation table is 32 bits, if it is divided into 8 groups, each group is 4 bits, then each group has 2 4 That is, the 16 enumerated prediction values range from 0000 to 1111 in binary. Correspondingly, when determining the prediction value corresponding to the first CRC check code, the possible query times range from 1 to 16. Of course, if a more efficient query strategy (such as binary search) is used, the query times will be further reduced. If it is divided into 4 groups, each group is 8 bits, then each group has 2 8If the prediction value is divided into 16 groups, each with 2 bits, the query consumption will increase accordingly; if it is divided into 16 groups, each with 2 bits, although the number of queries for each group will be reduced, it will take up a lot of storage space. Therefore, in practical applications, those skilled in the art can reasonably set the number of groups based on the principle of space and time balance.
[0045] For each enumeration value in each group, CRC calculation is performed according to the generation algorithm of the first CRC check code and the second CRC check code to obtain the corresponding calculation result (also the CRC check code), and then each calculation result is stored in the current group.
[0046] Optionally, in a feasible manner, for each group, performing cyclic redundancy calculation according to the enumeration value of the current group may include: for the current group, enumerating the value of the current group, and setting the values of other groups except the current group to 0, to obtain the enumeration value corresponding to the current group; performing cyclic redundancy calculation on the enumeration value. In this way, the values of other groups will not affect the prediction value calculation of the current group, so that the prediction values of the corresponding groups can be quickly generated.
[0047] When generating the preprocessing splicing table, the preprocessing splicing table can be divided into N groups (such as 8 groups) according to the length len (which can also be considered as the length of the second CRC check code, such as 32 bits), and the number of bits in each group is M, N*M=len. In the case of crc32c as an example, 32 bits can be divided into 8 groups, each with 4 bits. Process each group in turn, enumerate all possible values of each group, and set the values at other positions except this group to 0. Use this value as the initial value of the crc32c algorithm. For example, for the first enumeration value of the first group, such as 0000, calculate the CRC check code of all 0 data with a length of len and store it in the corresponding position of the preprocessing splicing table. Calculate all kinds of values of N groups according to the enumeration to generate a preprocessing splicing table.
[0048] It should be noted that the specific generation code of the above preprocessing splicing table is only an example. In practical applications, those skilled in the art can generate the final preprocessing splicing table according to the actual language, platform, etc., and can make appropriate changes.
[0049] After the preprocessing splicing table is generated, in subsequent use, the first CRC check code may adopt the same grouping as the preprocessing splicing table to perform prediction value search and determination.
[0050] Step S204: Obtain a first CRC check code of a first portion of data to be spliced with check codes.
[0051] Those skilled in the art may adopt any appropriate method to obtain the first CRC check code of the first part of data.
[0052] Step S206: Determine a prediction value corresponding to the first CRC check code from a preset preprocessing concatenation table.
[0053] As mentioned above, after the grouping of the preprocessing splicing table is determined, the first CRC check code can use the same grouping.
[0054] In a feasible manner, this step can be implemented as follows: obtaining the grouping information of the first CRC check code; and determining the prediction values corresponding to the groups indicated by the grouping information from the preprocessing concatenation table. Thus, the prediction values corresponding to the first CRC check code can be quickly searched and determined.
[0055] For example, the first and second CRC check codes are both generated using the crc32c algorithm. Similarly, the predicted value in the preprocessing splicing table is also generated using the crc32c algorithm for the enumerated value. Assuming that the binary bit value of the first group of the first CRC check code is 1111, based on its group information and bit value information, the r[0]
[15] element in the preprocessing splicing table is searched (when 0 is the starting sequence number, the first group is the 0th group, and the binary 1111 corresponds to the decimal 15), and it can be determined that the predicted value in the preprocessing splicing table corresponding to the first group of the first CRC check code is 0x00000000 (hexadecimal). Similar processing is performed on other groups of the first CRC check code to determine their predicted values in the preprocessing splicing table.
[0056] Step S208: Generate a concatenated CRC check code according to the determined predicted value and the second CRC check code according to the length.
[0057] For example, an XOR operation is performed on the predicted value and the second CRC check code, and a spliced cyclic redundancy check code is generated according to the length of the preprocessing splicing table or the length of the second CRC check code.
[0058] Taking the first CRC check code as 32 bits, divided into 8 groups, each group of 4 bits as an example, set the corresponding prediction values of the 8 groups in the pre-processing splicing table to be r1-r8 respectively, then, r1-r8 and the second CRC check code are XORed, and the splicing of the first CRC check code and the second CRC check code can be realized. The spliced CRC check code, such as CRC_TOTAL, is the overall CRC check code of the first part of the data and the second part of the data. Its implementation can refer to the above embodiment 1. Figure 1B .
[0059] In the case where the second data portion is fixed-length data, the above process achieves the effect of quickly splicing the CRC check code of the fixed-length data. Figure 1BIn the present invention, splicing crc32c check code only requires 8 table lookup operations and 8 XOR operations, which greatly improves the splicing speed and efficiency of CRC check code.
[0060] Through this embodiment, a preprocessing splicing table is pre-set in the system. On the one hand, the length of the preprocessing splicing table is the same as the length of the second CRC check code to be spliced with the check code, which is convenient for splicing with the second CRC check code; on the other hand, the preprocessing splicing table stores the predicted values obtained by enumerating the CRC check code, that is, the predicted values in the preprocessing splicing table can include all possible CRC check codes. Therefore, no matter what kind of first CRC check code, the corresponding predicted value can be found in the preprocessing splicing table, and then it can be directly spliced with the second CRC check code to be spliced to generate a total CRC check code corresponding to the first part of the data and the second part of the data. Therefore, the solution provided by this embodiment effectively utilizes the CRC check code of the second part of the data to be spliced, can realize the CRC check code splicing at low cost and high efficiency, and is simple to implement, reducing the computational complexity. In addition, the splicing of the first CRC check code and the second CRC check code without considering the specific CRC check code value is realized.
[0061] The verification code generation method of this embodiment can be executed by any appropriate electronic device with data processing capability, including but not limited to: a server, a mobile terminal (such as a mobile phone, a PAD, etc.) and a PC, etc.
[0062] Embodiment 3
[0063] Reference Figure 3 , shows a structural block diagram of a verification code generating device according to embodiment 3 of the present invention.
[0064] The check code generation device of this embodiment includes: an acquisition module 302, used to obtain a first CRC check code of a first part of data to be spliced with a check code; a determination module 304, used to determine a predicted value corresponding to the first CRC check code from a preset preprocessing splicing table, wherein the length of the preprocessing splicing table is the same as the length of the second CRC check code of the second part of data to be spliced with the check code, and the preprocessing splicing table stores the predicted value obtained by enumerating the CRC check code; a generation module 306, used to generate a spliced CRC check code according to the length based on the determined predicted value and the second CRC check code.
[0065] The verification code generation device of this embodiment is used to implement the corresponding verification code generation method in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here. In addition, the functional implementation of each module in the verification code generation device of this embodiment can refer to the description of the corresponding part in the aforementioned method embodiments, which will not be repeated here.
[0066] Embodiment 4
[0067] Reference Figure 4 , shows a structural block diagram of a verification code generating device according to Embodiment 4 of the present invention.
[0068] The check code generation device of this embodiment includes: an acquisition module 402, which is used to obtain a first CRC check code of a first part of data to be spliced with a check code; a determination module 404, which is used to determine a predicted value corresponding to the first CRC check code from a preset preprocessing splicing table, wherein the length of the preprocessing splicing table is the same as the length of the second CRC check code of the second part of data to be spliced with the check code, and the preprocessing splicing table stores the predicted value obtained by enumerating the CRC check code; a generation module 406, which is used to generate a spliced CRC check code according to the length based on the determined predicted value and the second CRC check code.
[0069] Optionally, the second portion of data is data with a fixed length.
[0070] Optionally, the determination module 404 is configured to obtain grouping information of the first CRC check code; and determine prediction values corresponding to the groups indicated by the grouping information from the preprocessing concatenation table.
[0071] Optionally, the generating module 406 is used to perform an XOR operation on the predicted value and the second CRC check code to generate a concatenated CRC check code according to the length.
[0072] Optionally, the verification code generation device of this embodiment further includes: a splicing table module 408, which is used to generate a pre-processing splicing table before the acquisition module 402 acquires the first CRC verification code of the first part of data to be spliced with the verification code.
[0073] Optionally, the splicing table module 408 is used to divide the preprocessing splicing table into a preset number of groups according to the length of the preprocessing splicing table; for each group, perform cyclic redundancy calculation according to the enumeration value of the current group, and store the cyclic redundancy calculation result corresponding to the current group; generate a preprocessing splicing table according to the cyclic redundancy calculation results of each group.
[0074] Optionally, when performing cyclic redundancy calculation for each group according to the enumeration value of the current group, the concatenation table module 408: for the current group, enumerates the value of the current group, and sets the values of other groups except the current group to 0 to obtain the enumeration value corresponding to the current group; and performs cyclic redundancy calculation on the enumeration value.
[0075] The verification code generation device of this embodiment is used to implement the corresponding verification code generation method in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here. In addition, the functional implementation of each module in the verification code generation device of this embodiment can refer to the description of the corresponding part in the aforementioned method embodiments, which will not be repeated here.
[0076] Embodiment 5
[0077] Reference Figure 5 , shows a schematic diagram of the structure of an electronic device according to Embodiment 5 of the present invention. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.
[0078] like Figure 5 As shown, the electronic device may include: a processor (processor) 502 , a communication interface (Communications Interface) 504 , a memory (memory) 506 , and a communication bus 508 .
[0079] in:
[0080] The processor 502 , the communication interface 504 , and the memory 506 communicate with each other via a communication bus 508 .
[0081] The communication interface 504 is used to communicate with other electronic devices or servers.
[0082] The processor 502 is used to execute the program 510, and specifically can execute the relevant steps in the above-mentioned verification code generation method embodiment.
[0083] Specifically, the program 510 may include program codes, which include computer operation instructions.
[0084] The processor 52 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or may be processors of different types, such as one or more CPUs and one or more ASICs.
[0085] The memory 506 is used to store the program 510. The memory 506 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0086] Program 510 can be specifically used to enable processor 502 to perform the following operations: obtain a first CRC check code of a first part of data to be spliced with a check code; determine a predicted value corresponding to the first CRC check code from a preset preprocessing splicing table, wherein the length of the preprocessing splicing table is the same as the length of a second CRC check code of a second part of data to be spliced with a check code, and the preprocessing splicing table stores predicted values obtained by enumerating CRC check codes; based on the determined predicted value and the second CRC check code, generate a spliced CRC check code according to the length.
[0087] In an optional implementation, the second portion of data is data with a fixed length.
[0088] In an optional embodiment, the program 510 is also used to enable the processor 502 to obtain the grouping information of the first CRC check code when determining the predicted value corresponding to the first CRC check code from a preset preprocessing splicing table; and determine the predicted values corresponding to the groups indicated by the grouping information from the preprocessing splicing table.
[0089] In an optional embodiment, the program 510 is also used to enable the processor 502 to perform an XOR operation on the predicted value and the second CRC check code when generating a spliced CRC check code according to the length based on the determined predicted value and the second CRC check code, so as to generate a spliced CRC check code according to the length.
[0090] In an optional implementation, the program 510 is further configured to enable the processor 502 to generate a preprocessing splicing table before obtaining the first CRC check code of the first portion of data to be spliced with the check code.
[0091] In an optional embodiment, the program 510 is also used to enable the processor 502 to divide the preprocessing splicing table into a preset number of groups according to the length of the preprocessing splicing table when generating the preprocessing splicing table; for each group, perform cyclic redundancy calculation according to the enumeration value of the current group, and store the cyclic redundancy calculation result corresponding to the current group; and generate a preprocessing splicing table based on the cyclic redundancy calculation results of each group.
[0092] In an optional embodiment, the program 510 is also used to enable the processor 502 to enumerate the value of the current group for the current group and set the values of other groups except the current group to 0 when performing cyclic redundancy calculation for each group according to the enumeration value of the current group, so as to obtain the enumeration value corresponding to the current group; and perform cyclic redundancy calculation on the enumeration value.
[0093] The specific implementation of each step in program 510 can refer to the corresponding description of the corresponding steps and units in the above-mentioned verification code generation method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above-mentioned method embodiment, which will not be repeated here.
[0094] Through the electronic device of this embodiment, a preprocessing splicing table is pre-set in the system. On the one hand, the length of the preprocessing splicing table is the same as the length of the second CRC check code to be spliced with the check code, which is convenient for splicing with the second CRC check code; on the other hand, the preprocessing splicing table stores the predicted values obtained by enumerating the CRC check code, that is, the predicted values in the preprocessing splicing table can include all possible CRC check codes. Therefore, no matter what kind of first CRC check code, the corresponding predicted value can be found in the preprocessing splicing table, and then it can be directly spliced with the second CRC check code to be spliced to generate a total CRC check code corresponding to the first part of the data and the second part of the data. Therefore, the solution provided by this embodiment effectively utilizes the CRC check code of the second part of the data to be spliced, can realize the CRC check code splicing at low cost and high efficiency, and is simple to implement, reducing the computational complexity. In addition, the splicing of the first CRC check code and the second CRC check code without considering the specific CRC check code value is realized.
[0095] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present invention can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present invention.
[0096] The above-mentioned method according to the embodiment of the present invention can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a special-purpose processor or programmable or special-purpose hardware (such as an ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the verification code generation method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the verification code generation method shown here, the execution of the code converts the general-purpose computer into a special-purpose computer for executing the verification code generation method shown here.
[0097] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present invention.
[0098] The above implementation methods are only used to illustrate the embodiments of the present invention, and are not limitations of the embodiments of the present invention. Ordinary technicians in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the embodiments of the present invention. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present invention. The patent protection scope of the embodiments of the present invention should be defined by the claims.
Claims
1. A verification code generation method, comprising: Obtain a first cyclic redundancy check code of a first portion of data to be spliced with check codes; Determine a prediction value corresponding to the first cyclic redundancy check code from a preset preprocessing splicing table, wherein the length of the preprocessing splicing table is the same as the length of the second cyclic redundancy check code of the second part of the data to be spliced with the check code, and the preprocessing splicing table stores the prediction value obtained by enumerating the cyclic redundancy check code; the preprocessing splicing table is divided into a preset number of groups according to the length of the preprocessing splicing table; for each group, perform cyclic redundancy calculation according to the enumeration value of the current group, and store the cyclic redundancy calculation result corresponding to the current group; obtained according to the cyclic redundancy calculation results of each group; The step of determining a predicted value corresponding to the first cyclic redundancy check code from a preset preprocessing concatenation table includes: Obtaining group information of the first cyclic redundancy check code; Determine, from the preprocessing concatenation table, prediction values corresponding to the groups indicated by the grouping information; Generate a concatenated cyclic redundancy check code according to the determined predicted value and the second cyclic redundancy check code according to the length; The step of generating a concatenated cyclic redundancy check code according to the length based on the determined prediction value and the second cyclic redundancy check code comprises: An XOR operation is performed on the predicted value and the second cyclic redundancy check code to generate a concatenated cyclic redundancy check code according to the length.
2. The method according to claim 1, wherein: The second part of data is data with a fixed length.
3. The method according to claim 2, wherein: Before obtaining the first cyclic redundancy check code of the first part of data to be spliced with check codes, the method further includes: Generate the preprocessing splicing table.
4. The method according to claim 3, wherein: The generating of the preprocessing splicing table comprises: According to the length of the preprocessing splicing table, the preprocessing splicing table is divided into a preset number of groups; For each group, perform cyclic redundancy calculation according to the enumeration value of the current group, and store the cyclic redundancy calculation result corresponding to the current group; The pre-processing splicing table is generated according to the cyclic redundancy calculation results of each group.
5. The method according to claim 4, wherein: The cyclic redundancy calculation is performed for each group according to the enumeration value of the current group, including: For the current group, enumerate the values of the current group, and set the values of other groups except the current group to 0 to obtain the enumeration value corresponding to the current group; A cyclic redundancy calculation is performed on the enumeration value.
6. A verification code generating device, comprising: An acquisition module, used for acquiring a first cyclic redundancy check code of a first part of data to be spliced with check codes; A determination module, configured to determine a prediction value corresponding to the first cyclic redundancy check code from a preset preprocessing splicing table, wherein the length of the preprocessing splicing table is the same as the length of the second cyclic redundancy check code of the second part of data to be spliced with the check code, and the preprocessing splicing table stores the prediction value obtained by enumerating the cyclic redundancy check code; the preprocessing splicing table is divided into a preset number of groups according to the length of the preprocessing splicing table; for each group, a cyclic redundancy calculation is performed according to the enumeration value of the current group, and the cyclic redundancy calculation result is stored corresponding to the current group; obtained according to the cyclic redundancy calculation results of each group; The step of determining a predicted value corresponding to the first cyclic redundancy check code from a preset preprocessing concatenation table includes: Obtaining group information of the first cyclic redundancy check code; Determine, from the preprocessing concatenation table, prediction values corresponding to the groups indicated by the grouping information; A generating module, configured to generate a concatenated cyclic redundancy check code according to the determined predicted value and the second cyclic redundancy check code and according to the length; The step of generating a concatenated cyclic redundancy check code according to the length based on the determined prediction value and the second cyclic redundancy check code comprises: An XOR operation is performed on the predicted value and the second cyclic redundancy check code to generate a concatenated cyclic redundancy check code according to the length.
7. An electronic device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the verification code generation method according to any one of claims 1 to 5.
8. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the verification code generation method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method for detecting data consistency of set top box built-in flash chip
CN104091616A
Polarization decoding method based on subsection CRC
CN105337696A