Id encoding method, and decoding method and device for encoded character string of ID
By combining ID with timestamps, data compression and verification value generation are solved, and the problem of ID susceptibility to traversal attacks and lack of validity management is achieved, and efficient ID encoding and secure transmission are achieved.
Patent Information
- Application Number
- CN202311813820.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-26
- Publication Date
- 2025-06-27
AI Technical Summary
In the prior art, IDs are prone to traversal attacks, lack of validity management, and easy to disclose business data.
By obtaining the current time stamp and ID of the system, converting it into binary, then compressing and splicing data, generating intermediate encoding, and converting it into an encoded string represented by character through verification value generation and character replacement table.
Effectively defend against traversal attacks, realize the effective period of ID management, reduce the amount of data of ID during transmission, improve system performance, and ensure the overall security of the system.
Smart Images

Figure CN120223089A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to computer information processing technology, and particularly to a coding method for an ID, a coding device therefor, a decoding method for a coded character of the ID, and a decoding device therefor. Background Art
[0002] When developing an external API interface, in the prior art, generally, after directly retrieving a resource ID (mostly a database primary key) from a database, it is directly returned to the calling party, and the calling party uses this ID to obtain resource detail information.
[0003] The above processing solutions in the prior art have the following problems:
[0004] Prone to traversal attacks: IDs are generally auto-incrementing integers. When these IDs are exposed externally, there is a problem of being vulnerable to traversal attacks, enabling attackers to predict and abuse the IDs generated by the system, thus threatening the security of the system;
[0005] Lack of validity period management: The ID returned to the calling party is the same as that in the database. After obtaining the ID, an attacker can perform replay attacks without limitation, increasing the risk of system resources being exposed; and
[0006] Prone to leakage of business data: By analyzing the daily ID increment value, the daily business volume of the system can be roughly analyzed. Summary of the Invention
[0007] In order to solve the above problems in the prior art, the present invention aims to provide a coding method for an ID, a coding device therefor, a decoding method for a coded character of the ID, and a decoding device therefor, which can effectively defend against traversal attacks.
[0008] The ID coding method according to one aspect of the present invention includes:
[0009] A first conversion step of obtaining the current system timestamp and an ID, and respectively converting the timestamp and the ID into a binary timestamp and a binary ID;
[0010] A data compression step of performing data compression and splicing on the binary timestamp and the binary ID to obtain a first intermediate code;
[0011] A check value generation step of performing a check operation based on the first intermediate code to obtain a check value and splicing the check value with the first intermediate code to obtain a second intermediate code;
[0012] A second conversion step of converting the second intermediate code into a decimal third intermediate code; and
[0013] A character replacement step, replacing the third intermediate code in decimal with a coded string represented by characters using a character replacement table, wherein the corresponding relationship between decimal numbers and characters is preset in the character replacement table.
[0014] Optionally, the data compression step includes:
[0015] For the binary timestamp and the binary ID, remove the bits with the highest bit being 0 respectively to obtain the valid bits of the timestamp and the valid bits of the ID;
[0016] Calculate the effective bit difference between the valid bits of the timestamp and the valid bits of the ID and convert the effective bit difference into binary to obtain the effective bit difference value;
[0017] Add a sign bit for identifying the effective bit difference value, wherein when the effective bit difference value is greater than or equal to 0, the sign bit is 0, and when it is less than 0, the sign bit is 1;
[0018] Add a fixed value of one bit; and
[0019] Concatenate the fixed value, the sign bit, the effective bit difference value, the valid bits of the timestamp and the valid bits of the ID to obtain the first intermediate code.
[0020] Optionally, convert the effective bit difference into 6-bit binary.
[0021] Optionally, the check value generation step includes:
[0022] Group the first intermediate code into groups of 6 bits each;
[0023] Perform exclusive OR processing cyclically with the first group as the base to obtain the check value; and
[0024] Concatenate the check value after the first intermediate code to obtain the second intermediate code.
[0025] Optionally, in the second conversion step, group the second intermediate code into groups of 6 bits each and convert it into a third intermediate code in decimal.
[0026] A decoding method for the coded string of the ID according to one aspect of the present invention includes:
[0027] A character replacement step, replacing the coded string with a first intermediate code in decimal using a character replacement table, wherein the corresponding relationship between decimal numbers and characters is preset in the character replacement table;
[0028] A first conversion step, converting the first intermediate code in decimal into a second intermediate code in binary;
[0029] Check value step, extracting a check value from the second intermediate code in binary and performing a check based on the check value;
[0030] Data decompression step, extracting a binary timestamp and a binary ID after removing the check value from the second intermediate code;
[0031] Second conversion step, converting the binary timestamp and the binary ID into decimal to obtain a timestamp and an ID.
[0032] Optionally, in the first conversion step, each digit of the decimal first intermediate code is converted into binary in groups of 6 bits and concatenated together to obtain the second intermediate code.
[0033] Optionally, the check value step includes:
[0034] Extracting the lowest 6 bits from the second intermediate code in binary as the check value, and the other bits as the value to be checked;
[0035] Grouping the value to be checked in groups of 6 bits each and performing exclusive OR processing cyclically with the first group as the base to obtain a calculated check value; and
[0036] Comparing the calculated check value with the extracted check value. If the two are inconsistent, it indicates that the data has been tampered with and the decoding fails.
[0037] Optionally, the data decompression step includes:
[0038] Obtaining effective bit difference information from the second intermediate code;
[0039] Calculating an effective bit difference based on the effective bit difference information;
[0040] Based on the effective bit difference and the total length of the data effective bits, calculating the effective bit length of the timestamp and the effective bit length of the ID; and
[0041] Obtaining the binary timestamp and the binary ID based on the effective bit length of the timestamp and the effective bit length of the ID.
[0042] The ID encoding device according to one aspect of the present invention includes:
[0043] A first conversion module, configured to obtain the system current timestamp and ID and convert the timestamp and ID into a binary timestamp and a binary ID respectively;
[0044] A data compression module, configured to perform data compression on the binary timestamp and the binary ID and concatenate them to obtain a first intermediate code;
[0045] A check value generation module, configured to perform a check operation based on the first intermediate code to obtain a check value and splice the check value with the first intermediate code to obtain a second intermediate code;
[0046] A second conversion module, configured to convert the second intermediate code into a third intermediate code in decimal; and
[0047] A character replacement module, configured to replace the third intermediate code in decimal with a coded string represented by characters by using a character replacement table, wherein a corresponding relationship between decimal numbers and characters is preset in the character replacement table.
[0048] Optionally, the data compression module performs the following operations:
[0049] Remove the bits with the highest bit being 0 from the binary timestamp and the binary ID respectively to obtain the valid bits of the timestamp and the valid bits of the ID;
[0050] Calculate the effective bit difference between the valid bits of the timestamp and the valid bits of the ID and convert the effective bit difference into binary to obtain an effective bit difference value;
[0051] Add a sign bit for identifying the effective bit difference value, wherein when the effective bit difference value is greater than or equal to 0, the sign bit is 0, and when it is less than 0, the sign bit is 1;
[0052] Add a fixed value of one bit; and
[0053] Splice the fixed value, the sign bit, the effective bit difference value, the valid bits of the timestamp and the valid bits of the ID to obtain the first intermediate code.
[0054] Optionally, in the data compression module, convert the effective bit difference into 6-bit binary.
[0055] Optionally, the check value generation module performs the following operations:
[0056] Group the first intermediate code into groups of 6 bits each;
[0057] Perform exclusive OR processing cyclically with the first group as the base to obtain the check value; and
[0058] Splice the check value after the first intermediate code to obtain the second intermediate code.
[0059] Optionally, in the second conversion module, group the second intermediate code into groups of 6 bits each and convert it into a third intermediate code in decimal.
[0060] A decoding device for the coded string of the ID according to one aspect of the present invention includes:
[0061] A character replacement module for replacing the encoded string of the ID with a first intermediate code of decimal numbers using a character replacement table, wherein the corresponding relationship between decimal numbers and characters is preset in the character replacement table;
[0062] A first conversion module for converting the first intermediate code of decimal numbers into a second intermediate code of binary numbers;
[0063] A verification module for extracting a verification value from the second intermediate code of binary numbers and performing verification based on the verification value;
[0064] A data decompression module for extracting a binary timestamp and a binary ID from the second intermediate code after removing the verification value;
[0065] A second conversion module for converting the binary timestamp and the binary ID into decimal numbers to obtain the timestamp and the ID.
[0066] Optionally, in the first conversion module, each digit of the first intermediate code of decimal numbers is converted into a 6-bit group of binary numbers and concatenated together to obtain the second intermediate code.
[0067] Optionally, the following operations are performed in the verification module:
[0068] Extract the lowest 6 bits from the second intermediate code of binary numbers as the verification value, and the other bits are the values to be verified;
[0069] Group the values to be verified with every 6 bits as a group and perform exclusive OR processing cyclically with the first group as the base to obtain the calculated verification value; and
[0070] Compare the calculated verification value with the extracted verification value. If the two are inconsistent, it indicates that the data has been tampered with and the decoding fails.
[0071] Optionally, the following operations are performed in the data decompression module:
[0072] Obtain the effective bit difference information from the second intermediate code;
[0073] Calculate the effective bit difference according to the effective bit difference information;
[0074] Based on the effective bit difference and the total length of the data effective bits, calculate the effective bit length of the timestamp and the effective bit length of the ID; and
[0075] Obtain the binary timestamp and the binary ID based on the effective bit length of the timestamp and the effective bit length of the ID.
[0076] A computer-readable medium according to one aspect of the present invention, on which a computer program is stored, characterized in that when the computer program is executed by a processor, it is the encoding method of the ID or the decoding method of the encoded string of the ID.
[0077] A computer device according to one aspect of the present invention, comprising a storage module, a processor, and a computer program stored on the storage module and executable on the processor, wherein when the processor executes the computer program, it implements the encoding method of the ID or the decoding method of the encoded string of the ID. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] From the following detailed description in conjunction with the accompanying drawings, the above and other objects and advantages of the present application will become more fully apparent, wherein like or similar elements are denoted by the same reference numerals.
[0079] Figure 1 FIG. is a schematic diagram showing a character replacement table according to an embodiment of the present invention.
[0080] Figure 2 FIG. is a schematic diagram showing an encoding method of an ID according to an embodiment of the present invention.
[0081] Figure 3 FIG. is a schematic diagram showing a decoding method of an encoded character of an ID according to an embodiment of the present invention.
[0082] Figure 4 FIG. is a block diagram showing the structure of an ID encoding device according to an embodiment of the present invention.
[0083] Figure 5 FIG. is a block diagram showing the structure of a decoding device for an encoded character of an ID according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0084] Some of the following described are some of the multiple embodiments of the present invention, aiming to provide a basic understanding of the present invention. It is not intended to identify the key or decisive elements of the present invention or to limit the scope to be protected.
[0085] For the sake of brevity and illustrative purposes, the principles of the present invention are mainly described herein with reference to its exemplary embodiments. However, those skilled in the art will readily recognize that the same principles can be equivalently applied to all types of ID encoding methods and their encoding devices, as well as ID encoded character decoding methods and their decoding devices, and these same principles can be implemented therein, and any such variations do not depart from the true spirit and scope of this patent application.
[0086] Moreover, in the following description, reference is made to the accompanying drawings, which illustrate specific exemplary embodiments. Electrical, mechanical, logical and structural changes may be made to these embodiments without departing from the spirit and scope of the present invention. In addition, although the features of the present invention are disclosed in conjunction with only one of several implementations / embodiments, this feature may be combined with one or more other features of other implementations / embodiments as may be desirable and / or advantageous for any given or identifiable function. Therefore, the following description should not be regarded as limiting, and the scope of the present invention is defined by the appended claims and their equivalents.
[0087] Terms such as “having” and “including” indicate that in addition to the units (modules) and steps directly and explicitly stated in the specification and claims, the technical solution of the present invention does not exclude the situation where it has other units (modules) and steps that are not directly or explicitly stated.
[0088] Before explaining the ID encoding method and decoding method of the present invention, related technical terms are first explained.
[0089] (1) ID: An integer, generally used to identify the system resource number.
[0090] (2) Data replacement: Replace one character with another according to certain rules.
[0091] (3) Exclusive OR: It is a mathematical operator, called exclusive OR in English, abbreviated as xor, and is used in logical operations. The mathematical symbol of exclusive OR is “⊕” and the computer symbol is “xor”.
[0092] (4) Binary: It is a number system widely used in computing technology. Binary data is a number represented by two digits, 0 and 1.
[0093] (5) Compression: A mechanism that uses a specific algorithm to reduce the size of storage memory occupied by a string.
[0094] (6) BCC check: Each byte of data (usually every two hexadecimal characters) is XORed to obtain a check value to prevent the data from being considered tampered with.
[0095] Next, the ID encoding method according to the embodiment of the present invention is described.
[0096] First, the ID encoding method and decoding method of the embodiment of the present invention involve character replacement. Here, a character replacement table containing 64 different characters needs to be prepared in advance. Figure 1 Schematic diagram of a character replacement table according to an embodiment of the present invention. Figure 1It shows different replacement characters corresponding to 0 to 63 respectively.
[0097] Figure 2 It is a schematic diagram of the ID coding method representing an embodiment of the present invention.
[0098] Such as Figure 2 As shown, the ID coding method of an embodiment of the present invention includes the following steps:
[0099] (1) Obtain the system current timestamp and ID. For example, the timestamp is: 1701331036838; the ID is: 12345678;
[0100] (2) Convert the timestamp and ID into their corresponding binary.
[0101] (3) Data compression: First, remove the bits with the highest bit being 0 respectively to obtain their valid bits (in most cases, there are many 0s in the high bits, which can effectively compress the length of the number):
[0102] Timestamp: 11000110000011111001110110110101010100110
[0103] ID: 101111000110000101001110,
[0104] Then, calculate the difference in the lengths of the valid bits respectively. For example, the timestamp length is 41 bits, the ID valid bit length is 24 bits, and the effective length difference is 17. Since the maximum length difference is 64, only 6 bits are needed to store it. Therefore, it is converted into 6-bit binary 010001, which is denoted as "effective bit difference" here.
[0105] Next, add a "sign bit" in the high bit to identify the difference in the lengths of the valid bits. When the difference is greater than or equal to 0, fill it with 0, and when it is less than 0, fill it with 1. Therefore, the binary value with the sign bit added is 0010001.
[0106] Furthermore, add a "fixed value" in the high bit. Here, the value is 1 (used to identify the position of the effective bit difference record during decoding), and the obtained value is 10010001.
[0107] Finally, splice the fixed value, sign bit, effective bit difference, valid bits of the timestamp, and valid bits of the ID to obtain: 00110000011111001110110110101010100110101111000110000101001110;
[0109] (4) Fill 0 in the high bit to ensure that the total number of binary bits is a multiple of 6. Therefore, the obtained value is: 000001001000111000110000011111001110110110101010100110101111000110000101001110;
[0111] (5) Generate the BCC check value: To prevent the data from being considered modified, take every 6 bits as a group, and perform exclusive OR processing in a loop with the first group as the base. The obtained value is used as the check value and filled in the lowest bit. According to the above example, the check value after exclusive OR processing is 001000, and the value obtained after filling is: 000001001000111000110000011111001110110110101010100110101111000110000101001110001000;
[0113] (6) Group every 6 bits as a group and convert it into a decimal value. The obtained value is: 18564831145442384765148
[0115] (7) Combine with the character replacement table for replacement: Search for the numbers obtained in the above steps Figure 1 in the shown character replacement table and replace them with the corresponding characters. For example, 1 corresponds to the character 9, 8 corresponds to the character i, 56 corresponds to the character 6, and so on…, and then concatenate them to obtain the final ID coding string:
[0116] 9i6konGsI734ni
[0117] (8) End the process.
[0118] As described above, the ID coding method according to an embodiment of the present invention encodes an integer ID into a coding string by adopting technologies such as combining a time stamp, data replacement, data verification, and data compression. This coding string has functions such as anti-traversal, anti-tampering, compressibility, and timeliness, and thus can resist traversal attacks and protect system security.
[0119] Moreover, the time stamp is carried in the encoded ID, which can manage the validity period, ensure that the ID used by the system is valid within a reasonable time, and reduce the risks of retention and abuse.
[0120] Further, when the ID range to be encoded is from 1 to 2^64, the length of the encoded string is at most 24 characters (the characters that the encoded string may contain are: "numbers", "letters", "-", "_"). Since there are at most 24 characters, through such a digital compression technology, the data volume of the ID during transmission can be reduced, the system performance can be improved, and it can be ensured that the system still operates efficiently in resource-constrained environments.
[0121] Furthermore, by adopting security measures of data verification, it can be ensured that the generated ID is not easily tampered with or exploited during transmission, and the overall security of the system is maintained.
[0122] Figure 3 It is a schematic diagram showing the decoding method of the encoded characters of the ID according to an embodiment of the present invention.
[0123] As Figure 3 shown, the decoding method of the encoded characters of the ID according to an embodiment of the present invention includes the following steps:
[0124] (1) Perform replacement in combination with the character replacement table: The string to be decoded is 9i6konGsI734ni. Combining with Figure 1 the character replacement table shown, obtain the position values of each character in the replacement table. For example, the subscript of 9 in the replacement table is 1, the subscript of i in the replacement table is 8, the subscript position of 6 in the replacement table is 56, and so on..., and the obtained result is 18564831145442384765148;
[0125] (2) Convert each number obtained in the previous step into a 6-bit binary number and splice them together. The obtained value is: 000001001000111000110000011111001110110110101010100110101111000110000101001110001000;
[0126] (3) The lowest 6 bits in the binary number obtained in the previous step are the verification values, that is: 001000, and the other bits are the values to be verified, that is: 000001001000111000110000011111001110110110101010100110101111000110000101001110.
[0127] Group the values to be verified by every 6 bits and perform BCC cyclically to obtain the calculated verification value. Compare the newly calculated verification value with the verification value obtained in the encoding. If they are inconsistent, it indicates that the data has been tampered with and the decoding fails;
[0128] (4) Obtain the valid bit difference information. Starting from the highest bit, find the first 1, and then continuously take the next 7 bits. The value obtained is the valid bit difference information, that is: 0010001. The subsequent data is the actual data, that is: 11000110000011111001110110110101010100110101111000110000101001110,
[0129] (5) Calculate the valid bit difference. Judge the first bit of the valid bit difference information. If it is 0, it indicates that the valid bit difference is positive. If it is 1, it means the valid bit difference is negative. The last six bits are converted to decimal, and combined with the sign bit to obtain the valid bit difference value, that is: 17;
[0130] (6) Calculate the values of the timestamp and ID. According to the total length of the valid bits of the data (65) and the difference in the length of the valid bits (17), the lengths of the valid bits occupied by the timestamp and ID can be calculated, that is: The length of the valid bits of the timestamp is: (total length of valid bits + difference in length of valid bits) / 2, that is: (17 + 65) / 2 = 41. The length of the ID is: total length of valid bits - length of valid bits of the timestamp, that is: 65 - 41 = 24. Therefore, according to their respective lengths of valid bits, the binary data corresponding to the timestamp can be obtained as 11000110000011111001110110110101010100110, and the binary data corresponding to the ID is: 101111000110000101001110;
[0131] (7) After converting the binary to decimal, the timestamp is: 1701331036838, and the ID is: 12345678;
[0132] (8) End the process.
[0133] Figure 4 It is a structural block diagram of an ID encoding device showing an embodiment of the present invention.
[0134] As Figure 4 shown, an ID encoding device 100 according to an embodiment of the present invention includes:
[0135] A first conversion module 110, configured to obtain the current system timestamp and ID and to convert the timestamp and ID into a binary timestamp and a binary ID respectively;
[0136] A data compression module 120, configured to compress and splice the binary timestamp and the binary ID to obtain a first intermediate code;
[0137] A check value generation module 130 is configured to perform a check operation based on the first intermediate encoding to obtain a check value and splice the check value with the first intermediate encoding to obtain a second intermediate encoding;
[0138] A second conversion module 140 is configured to convert the second intermediate encoding into a third intermediate encoding in decimal; and
[0139] A character replacement module 150 is configured to replace the third intermediate encoding in decimal with an encoded character string represented by characters by using a character replacement table, wherein a corresponding relationship between decimal digits and characters is preset in the character replacement table.
[0140] Wherein, the data compression module 120 performs the following operations:
[0141] For the binary timestamp and the binary ID, remove the bits with the highest bit being 0 respectively to obtain the valid bits of the timestamp and the valid bits of the ID;
[0142] Calculate the effective bit difference between the valid bits of the timestamp and the valid bits of the ID and convert the effective bit difference into binary to obtain an effective bit difference value;
[0143] Add a sign bit for identifying the effective bit difference value, wherein when the effective bit difference value is greater than or equal to 0, the sign bit is 0, and when it is less than 0, the sign bit is 1;
[0144] Add a fixed value of one bit; and
[0145] Splice the fixed value, the sign bit, the effective bit difference value, the valid bits of the timestamp and the valid bits of the ID to obtain the first intermediate encoding.
[0146] In the data compression module 120, convert the effective bit difference into a 6-bit binary.
[0147] The check value generation module 130 performs the following operations:
[0148] Group the first intermediate encoding into groups of 6 bits each;
[0149] Perform an exclusive OR operation in a loop with the first group as the base to obtain the check value; and
[0150] Splice the check value after the first intermediate encoding to obtain the second intermediate encoding.
[0151] In the second conversion module 150, group the second intermediate encoding into groups of 6 bits each and convert it into a third intermediate encoding in decimal.
[0152] Figure 5It is a structural block diagram of a decoding device for encoded characters representing the ID of an embodiment of the present invention.
[0153] As Figure 5 shown, the decoding device 200 for the encoded string of the ID of an embodiment of the present invention includes:
[0154] A character replacement module 210, configured to replace the encoded string of the ID with a first intermediate code of a decimal number by using a character replacement table, wherein the corresponding relationship between the decimal number and the character is preset in the character replacement table;
[0155] A first conversion module 220, configured to convert the first intermediate code of the decimal number into a second intermediate code of a binary number;
[0156] A verification module 230, configured to extract a verification value from the second intermediate code of the binary number and perform verification based on the verification value;
[0157] A data decompression module 240, configured to extract a binary timestamp and a binary ID from the second intermediate code after removing the verification value; and
[0158] A second conversion module 250, configured to convert the binary timestamp and the binary ID into decimal numbers to obtain the timestamp and the ID.
[0159] In the first conversion module 220, each digit of the first intermediate code of the decimal number is converted into a 6-bit group of binary numbers and spliced together to obtain the second intermediate code.
[0160] The following operations are performed in the verification module 230:
[0161] Extract the lowest 6 bits from the second intermediate code of the binary number as the verification value, and the other bits are the values to be verified;
[0162] Group the values to be verified with every 6 bits as a group and perform exclusive OR processing cyclically with the first group as the base to obtain the calculated verification value; and
[0163] Compare the calculated verification value with the extracted verification value. If the two are inconsistent, it indicates that the data has been tampered with and the decoding fails.
[0164] The following operations are performed by the data decompression module 240:
[0165] Obtain the effective bit difference information from the second intermediate code;
[0166] Calculate the effective bit difference according to the effective bit difference information;
[0167] Based on the effective bit difference and the total length of the data valid bits, calculate the effective bit length of the timestamp and the effective bit length of the ID; and
[0168] Obtain the binary timestamp and the binary ID based on the effective bit length of the timestamp and the effective bit length of the ID.
[0169] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Those skilled in the art can think of other feasible changes or substitutions according to the technical scope disclosed in the present application, and such changes or substitutions are all covered by the protection scope of the present application. Without conflict, the implementation manners of the present application and the features in the implementation manners can also be combined with each other. The protection scope of the present application shall be subject to the records of the claims.
Claims
1. A coding method for an ID, characterized in that, Including: A first conversion step of obtaining the current system timestamp and ID, and converting the timestamp and ID into a binary timestamp and a binary ID respectively; A data compression step of performing data compression on the binary timestamp and the binary ID and concatenating them to obtain a first intermediate code; A check value generation step of performing a check operation based on the first intermediate code to obtain a check value and concatenating the check value with the first intermediate code to obtain a second intermediate code; A second conversion step of converting the second intermediate code into a decimal third intermediate code; And A character replacement step of replacing the decimal third intermediate code with a character representation coding string using a character replacement table, wherein the corresponding relationship between decimal numbers and characters is preset in the character replacement table.
2. The ID coding method according to claim 1, characterized in that The data compression step includes: Removing the bits with the highest bit being 0 from the binary timestamp and the binary ID respectively to obtain the valid bits of the timestamp and the valid bits of the ID; Calculating the effective bit difference between the valid bits of the timestamp and the valid bits of the ID and converting the effective bit difference into binary to obtain an effective bit difference value; Adding a sign bit for identifying the effective bit difference value, wherein when the effective bit difference value is greater than or equal to 0, the sign bit is 0, and when it is less than 0, the sign bit is 1; Adding a fixed value of one bit; and Concatenating the fixed value, the sign bit, the effective bit difference value, the valid bits of the timestamp and the valid bits of the ID to obtain the first intermediate code.
3. The ID coding method according to claim 2, characterized in that Converting the effective bit difference into 6-bit binary.
4. The ID coding method according to claim 3, characterized in that The check value generation step includes: Grouping the first intermediate code into groups of 6 bits each; Performing an exclusive OR operation in a loop with the first group as the base to obtain the check value; and Concatenating the check value after the first intermediate code to obtain the second intermediate code.
5. The ID coding method according to claim 4, characterized in that In the second conversion step, grouping the second intermediate code into groups of 6 bits each and converting it into a decimal third intermediate code.
6. A decoding method for an encoded string of an ID, characterized in that, Including: A character replacement step of replacing the coding string with a first intermediate code of decimal numbers using a character replacement table, wherein the corresponding relationship between decimal numbers and characters is preset in the character replacement table; A first conversion step of converting the decimal first intermediate code into a binary second intermediate code; A check value step of extracting a check value from the binary second intermediate code and performing a check based on the check value; A data decompression step of extracting a binary timestamp and a binary ID from the second intermediate code after removing the check value; A second conversion step of converting the binary timestamp and the binary ID into decimal to obtain the timestamp and the ID.
7. The ID coding string decoding method according to claim 6, characterized in that In the first conversion step, each digit of the first intermediate code in decimal is converted into binary in groups of 6 bits and concatenated together to obtain the second intermediate code.
8. The decoding method of the ID encoding string according to claim 7, characterized in that, The check value step includes: Extracting the lowest 6 bits from the second intermediate code in binary as the check value, and the other bits as the value to be checked; Taking the value to be checked as a group every 6 bits and performing exclusive OR processing cyclically with the first group as the base to obtain the calculated check value; and Comparing the calculated check value and the extracted check value. If the two are inconsistent, it indicates that the data has been tampered with and the decoding fails.
9. The decoding method of the ID encoding string according to claim 8, characterized in that, The data decompression step includes: Obtaining the effective bit difference information from the second intermediate code; Calculating the effective bit difference according to the effective bit difference information; Based on the effective bit difference and the total length of the data effective bits, calculating the effective bit length of the timestamp and the effective bit length of the ID; and Obtaining the binary timestamp and the binary ID based on the effective bit length of the timestamp and the effective bit length of the ID.
10. An encoding device for an ID, characterized in that, Includes: A first conversion module, configured to obtain the current system timestamp and ID and convert the timestamp and ID into binary timestamp and binary ID respectively; A data compression module, configured to perform data compression on the binary timestamp and the binary ID and concatenate them to obtain the first intermediate code; A check value generation module, configured to perform a check operation based on the first intermediate code to obtain a check value and concatenate the check value with the first intermediate code to obtain the second intermediate code; A second conversion module, configured to convert the second intermediate code into a third intermediate code in decimal; And A character replacement module, configured to replace the third intermediate code in decimal with an encoded string represented by characters by using a character replacement table, wherein the corresponding relationship between decimal numbers and characters is preset in the character replacement table.
11. The ID encoding device according to claim 10, characterized in that, The data compression module performs the following actions: For the binary timestamp and the binary ID, respectively removing the bits with the highest bit being 0 to obtain the effective bits of the timestamp and the effective bits of the ID; Calculating the effective bit difference between the effective bits of the timestamp and the effective bits of the ID and converting the effective bit difference into binary to obtain the effective bit difference value; Adding one bit for identifying the sign bit of the effective bit difference value, wherein when the effective bit difference value is greater than or equal to 0, the sign bit is 0, and when it is less than 0, the sign bit is 1; Adding a fixed value of one bit; And Concatenating the fixed value, the sign bit, the effective bit difference value, the effective bits of the timestamp and the effective bits of the ID to obtain the first intermediate code.
12. The ID encoding device according to claim 11, characterized in that, In the data compression module, converting the effective bit difference into 6-bit binary.
13. The ID encoding device according to claim 12, characterized in that, The check value generation module performs the following actions: Group the first intermediate code into groups of 6 bits each; Perform exclusive OR processing on the first group as the base in a loop to obtain the check value; And Concatenate the check value after the first intermediate code to obtain the second intermediate code.
14. The ID encoding device according to claim 13, wherein In the second conversion module, the second intermediate code is grouped into groups of 6 bits each and converted into a decimal third intermediate code.
15. A decoding device for an encoded string of an ID, characterized in that, It includes: A character replacement module for replacing the ID encoding string with a character replacement table into a decimal first intermediate code, wherein the corresponding relationship between decimal numbers and characters is preset in the character replacement table; A first conversion module for converting the decimal first intermediate code into a binary second intermediate code; A check module for extracting a check value from the binary second intermediate code and performing a check based on the check value; A data decompression module for extracting a binary timestamp and a binary ID after removing the check value from the second intermediate code; A second conversion module for converting the binary timestamp and the binary ID into decimal numbers to obtain the timestamp and the ID.
16. The ID encoding string decoding device according to claim 15, wherein In the first conversion module, each digit of the decimal first intermediate code is converted into a 6-bit group of binary and concatenated together to obtain the second intermediate code.
17. The ID encoding string decoding device according to claim 16, wherein The following actions are performed in the check module: Extract the lowest 6 bits from the binary second intermediate code as the check value, and the other bits are the values to be checked; Group the values to be checked into groups of 6 bits each and perform exclusive OR processing on the first group as the base in a loop to obtain the calculated check value; And Compare the calculated check value with the extracted check value. If the two are inconsistent, it indicates that the data has been tampered with and the decoding fails.
18. The ID encoding string decoding device according to claim 17, wherein The data decompression module performs the following actions: Obtain the effective bit difference information from the second intermediate code; Calculate the effective bit difference according to the effective bit difference information; Based on the effective bit difference and the total length of the data effective bits, calculate the effective bit length of the timestamp and the effective bit length of the ID; And Obtain the binary timestamp and the binary ID based on the effective bit length of the timestamp and the effective bit length of the ID.
19. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the ID encoding method according to any one of claims 1 to 5 or the ID encoding string decoding method according to any one of claims 6 to 9.
20. A computer device, including a storage module, a processor, and a computer program stored on the storage module and executable on the processor, wherein When the processor executes the computer program, it implements the ID encoding method according to any one of claims 1 to 5 or the ID encoding string decoding method according to any one of claims 6 to 9.