Digital code encryption and decryption method, server and storage medium

By rearranging and reorganizing the code displacement strategy of the to-be-encrypted digital codes on the server side, the encrypted digital codes are generated, which solves the server CPU consumption and performance problems caused by the existing encryption and decryption methods, and achieves efficient encryption and decryption operations, which is suitable for multiple servers. environment.

CN112422491BActive Publication Date: 2024-09-20SHANGHAI HODE INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010382846.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-08
Publication Date
2024-09-20
Estimated Expiration
2040-05-08

AI Technical Summary

Technical Problem

Existing encryption and decryption methods will cause excessive server CPU consumption during frequent operations, affecting throughput and performance. They do not meet the market demand for multiple servers to process requests, and the encryption process increases memory and bandwidth consumption.

Method used

By obtaining the digital code to be encrypted and the preset coding displacement strategy, they are arranged and reorganized to generate an encrypted digital code, and encryption and decryption operations are performed on the server side. Only the displacement operation is performed on the server side without adding bytes, thus simplifying the decryption process.

Benefits of technology

It improves server performance, reduces CPU and memory consumption, avoids additional bandwidth consumption in data transmission, and simplifies decryption steps, making it suitable for multiple server environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112422491B
    Figure CN112422491B
Patent Text Reader

Abstract

The present invention relates to a digital code encryption and decryption method, a server and a storage medium, and belongs to the field of Internet technology. The digital code encryption and decryption method comprises: obtaining a digital code to be encrypted; obtaining a preset code displacement strategy, and arranging and reorganizing the digital code to be encrypted according to the code displacement strategy to generate an encrypted digital code; and sending the encrypted digital code to a client. The embodiment of the present invention can avoid adding redundant bytes, and can improve the performance of the overall service when encryption and decryption operations are frequently performed, that is, when the server throughput is large. Moreover, the encryption and decryption operations of the process are only solved by the server, and have no substantial impact on the client. Even if the server changes the encryption and decryption policy rules, the client does not need to make corresponding adjustments, which is convenient for future upgrades of the encryption and decryption scheme, and can reduce a lot of trouble for the network server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, in particular to the field of digital encryption technology, and specifically refers to a digitally encoded encryption and decryption method, a server and a storage medium. Background Art

[0002] With the rapid development of the Internet, a large amount of data is transmitted between the server and the client, and the security of this data is very important. For example, in daily applications, the front-end and back-end often use unique ID identification numbers as parameters in communication, such as the identity ID of game players, the product ID of online shopping malls, etc. If these real IDs on the server are exposed, the client can send a large number of simulated requests to the server to attack the server, which may cause the server to crash; from the user's perspective, the exposure of their real ID will also lead to information leakage. Therefore, for security reasons, these real IDs on the server usually need to be encrypted.

[0003] At present, the commonly used encryption and decryption method includes the following steps: the server saves the corresponding relationship between the ID transmitted to the client and the real ID in the memory, and then the server searches for the corresponding real ID after receiving the request. However, in reality, there will be a lot of encrypted content, which obviously reduces the data processing efficiency. Moreover, since the corresponding relationship is in the memory of a physical machine, the encrypted and decrypted data and process must be on the same physical machine. However, the common servers on the market currently have multiple servers to process requests, and this encryption and decryption method obviously does not meet the current market demand.

[0004] In addition, as for current encryption methods such as the Data Encryption Standard (DES) and RSA algorithm, since encryption operations are very frequent in practice, they usually cause excessive CPU consumption and affect the server throughput, thus affecting the overall service performance. For example, if "A" is encrypted into "ed311" using a general encryption method, the character length will be significantly increased, which not only increases memory consumption, but also increases CPU consumption during data processing, and increases bandwidth consumption during data transmission. Summary of the invention

[0005] In order to solve the above problems, one aspect of the present invention provides a method for encrypting and decrypting digital codes, including: obtaining a digital code to be encrypted; obtaining a preset code displacement strategy, and arranging and reorganizing the digital code to be encrypted according to the code displacement strategy to generate an encrypted digital code; and sending the encrypted digital code to a client.

[0006] Optionally, the method further includes: upon receiving an operation request from the client, obtaining an encrypted digital code according to the operation request; and decrypting the encrypted digital code according to the code shift strategy to obtain the digital code to be encrypted.

[0007] Optionally, the digital code to be encrypted is generated by encoding the user ID or by encoding the product ID. Optionally, the digital code to be encrypted is arranged and reorganized according to the coding displacement strategy to generate the encrypted digital code, specifically including: creating a new empty byte with the same number of bits according to the digital code to be encrypted; disassembling the digital code to be encrypted into several segments, and according to the coding displacement strategy, filling the several segments of the digital code to be encrypted into the empty bytes accordingly to obtain the encrypted digital code.

[0008] Optionally, the obtaining of a preset coding shift strategy specifically includes: obtaining an M-bit code of the digital code to be encrypted in a preset bit segment; wherein M is a natural number greater than 1; and obtaining a coding shift strategy corresponding to the M-bit code.

[0009] Optionally, the preset bit segment is located at the end of the digital code to be encrypted.

[0010] The present invention also provides a server, which executes the following steps: obtaining a digital code to be encrypted; obtaining a preset code displacement strategy, and arranging and reorganizing the digital code to be encrypted according to the code displacement strategy to generate an encrypted digital code; and sending the encrypted digital code to a client.

[0011] The present invention also provides a computer storage medium, on which a computer program is stored, and when the computer program is executed by a processor, any of the methods described above is implemented.

[0012] According to the above content, the encryption and decryption method of the digital code of the present invention includes: obtaining the digital code to be encrypted; obtaining a preset code displacement strategy, and arranging and reorganizing the digital code to be encrypted according to the code displacement strategy to generate an encrypted digital code; sending the encrypted digital code to the client. The present invention arranges and reorganizes the digital code to be encrypted, which can avoid adding redundant bytes. When the encryption and decryption operations are frequently performed, that is, when the server throughput is large, the performance of the overall service can be improved, and the encryption displacement operation is reversible, which can simplify the decryption operation. Moreover, the encryption and decryption operations of this process are only solved by the server, and have no substantial impact on the client. Even if the server changes the encryption and decryption policy rules, the client does not need to make corresponding adjustments, which is convenient for future upgrades of the encryption and decryption scheme, and can reduce a lot of trouble for the network server. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 A schematic flow chart of a digital code encryption and decryption method according to an embodiment of the present invention;

[0014] Figure 2 A schematic flow chart of the steps included in the method for encrypting and decrypting digital codes in one embodiment of the present invention;

[0015] Figure 3 The figure is a schematic diagram of binary coding before encryption and binary coding after encryption according to an embodiment of the present invention. DETAILED DESCRIPTION

[0016] Regarding the security of data transmitted between the server and the client, for example, when users play games on their mobile phones, they will use identity IDs. These identity IDs are self-incrementing numbers in the database, such as 1, 2, and 3. If the original data of the identity ID in the communication, such as 1, is sent directly to the client, then the user knows that the original data of his or her identity ID is 1, and he or she may guess the ID data of the subsequent user. Then some simulation behaviors can be performed through the interface in the system. For example, as long as the ID data is entered, the user's information can be queried. This is very dangerous. On the one hand, it causes the leakage of user information; on the other hand, the client can send a large number of simulation requests to the server to attack the server. Therefore, these identity IDs need to be encrypted before transmission.

[0017] However, as mentioned above, for example, encrypting "A" into "ed311" through a general encryption method obviously increases the character length, which not only increases memory consumption, but also increases CPU consumption during data processing, and increases bandwidth consumption during data transmission. The digital encoding encryption and decryption method provided by an embodiment of the present invention does not increase the character length. For example, when a user registers an account, the server generates an ID according to a preset rule, which can be an increasing rule or a decreasing rule, etc., and can be preset manually. Assume that the generated user's real ID is ten digits, such as 1000000000, and its encoding is 32-bit binary. If the server passes it to the client without encryption, then the client parses it according to the 32-bit binary and displays "1000000000", thus exposing the user's real ID; if the server generates an encrypted binary code using the encryption and decryption method for digital codes provided in an embodiment of the present invention, and then passes the encrypted binary code to the client, although the 32-bit binary is still passed to the client, and the client still parses it according to the original method, the parsed code may be 02113000000.

[0018] Through the above method, both the normal transmission and processing of data are achieved, and the purpose of keeping the real ID of the user confidential on the server side is achieved. In particular, in the above process, the real ID of the user is 32-bit binary, and the binary code generated after encryption is still 32 bits, that is, the content transmitted to the client will not add extra bytes due to the encryption process. Then for a memory that was originally 32-bit binary, a new 32-bit binary memory can be created for operation, which will not increase memory consumption or CPU consumption; moreover, since the binary code before and after encryption is 32 bits, there will be no additional bandwidth consumption during data transmission.

[0019] In the encryption and decryption process of the digital code of the first embodiment of the present invention, the server encrypts the sensitive information to generate a ciphertext, and then sends the ciphertext to the client, such as the encrypted user ID or product ID. When the object that the client needs to operate is the user ID or product ID, that is, when the client sends the user ID or product ID to the server, the server performs the decryption step. During the whole process, the user does not know the specific real user ID or product ID, which can achieve the purpose of confidentiality. In particular, the encryption and decryption operations of the process are only solved by the server, and have no substantial impact on the client. Even if the server changes the encryption and decryption policy rules, the client does not need to make corresponding adjustments, which is convenient for the future upgrade of the encryption and decryption scheme, and can reduce a lot of trouble for the network server.

[0020] In order to make the purpose, technical solution and advantages of the present invention more clear, the following will further describe the implementation mode of the present invention in detail with reference to the accompanying drawings. Figure 1 FIG. 1 is a flow chart of a method for encrypting and decrypting digital codes according to an embodiment of the present invention, comprising the following steps:

[0021] S1: Get the digital code to be encrypted;

[0022] S2: obtaining a preset code shift strategy, and arranging and reorganizing the digital code to be encrypted according to the code shift strategy to generate an encrypted digital code;

[0023] S3: Send the encrypted digital code to the client.

[0024] According to the above content, the byte occupancy of the result after displacement obfuscation is the same as that of the original data, and data encryption will not increase traffic consumption during data transmission.

[0025] Optional, such as Figure 2 As shown, the digital code encryption and decryption method also includes:

[0026] S4: upon receiving an operation request from the client, obtaining an encrypted digital code according to the operation request;

[0027] S5: Decrypt the encrypted digital code according to the code shift strategy to obtain the digital code to be encrypted.

[0028] Among them, the shift operation corresponding to the coding shift strategy in the decryption process is the inverse operation of the shift operation corresponding to the coding shift strategy in the encryption process, which can greatly simplify the decryption steps and improve the stability of the server as a whole.

[0029] In addition, the digital code to be encrypted can be pre-entered by a technician into the server, and the server converts the ID into the digital code to be encrypted. For example, the technician can pre-enter the ID of the virtual product into the server so that the server can convert the ID of the virtual product into the digital code to be encrypted. As for the user ID, for example, when a user registers an account, the server generates a new real identity ID, and the new real identity ID is used as the number to be encrypted. The binary code converted from the new real identity ID is the digital code to be encrypted. The server encrypts the digital code to be encrypted to generate an encrypted digital code, and then sends the encrypted digital code to the client, which parses the encrypted digital code and then displays it. When the client receives the user operation, it sends the encrypted digital code to the server, and the server performs a decryption step on the encrypted digital code to obtain the digital code to be encrypted. Therefore, the digital code to be encrypted described in step 1 can be obtained by converting the identity ID newly generated by the server, or it can be obtained through a decryption step. For example, when a user registers an account, the server generates a new identity ID, and the new identity ID is converted into a binary code to be encrypted as 001100, and the encrypted binary code generated is 110000, that is, the digital code to be encrypted at this time is obtained by converting the identity ID newly generated by the server. When the server executes the decryption step, the encrypted binary code 110000 is decrypted into the original binary code to be encrypted 001100. At this time, the server executes the encryption step again, and the digital code to be encrypted described in step S1 is obtained after the decryption step.

[0030] The above process involves converting the number to be encrypted into the digital code to be encrypted. For example, there are two encoding methods on the market: BigEndian and LittleEndian. For example, for "10321", the result obtained by using BigEndian encoding is 011144111, and then the obtained digital code is encrypted, for example, the generated encrypted code is 441110111, and then transmitted to the client, but the specific process is not displayed on the client.

[0031] Optionally, the digital code to be encrypted is generated by encoding the user ID or by encoding the commodity ID, which can improve the security of most data. When the server generates the ID, the server encrypts the ID and sends it to the client, thereby achieving the purpose of keeping the real ID confidential. For example, CD01 may be obtained by encrypting AAAA, and the user may see CD01 through the client, but not AAAA. When the client sends the encrypted ID to the server based on the user operation, the server performs the decryption operation. It should be noted that when the user operates the client, if the client does not send the ID to the server, the server does not perform the decryption step. For example, if the user modifies the basic information, the modified content is only saved locally, then the client does not need to send the ID to the server at this time, and the server naturally does not need to perform the decryption step. For another example, the server encrypts the game equipment ID and sends it to the client. The client parses the data encoding of the encrypted ID and displays it. When the user chooses to buy a certain game equipment on the client, the client needs to send the encrypted ID to the server. The server performs the decryption step to clarify which game equipment the user wants to buy. In daily applications, when users shop in an online mall, the goods here are equivalent to the above-mentioned game equipment, and both correspond to real IDs and encrypted IDs. The encryption and decryption processes are the same and will not be described here. Optionally, the digital code to be encrypted is arranged and reorganized according to the coding displacement strategy described in step 2 to generate an encrypted digital code, specifically including: according to the digital code to be encrypted, creating a new empty byte with the same number of bits; disassembling the digital code to be encrypted into several segments, and according to the coding displacement strategy, filling the several segments of the digital code to be encrypted into the empty bytes to obtain the encrypted digital code. This process will not generate redundant bytes and will not increase CPU consumption, thereby ensuring data processing performance. For example, in the encryption and decryption method of the digital code of the present embodiment, a new 32-bit byte with the same number of bits is created, and all bits are 0; after obtaining the digital code to be encrypted, it needs to be disassembled into several segments, and then according to the corresponding coding displacement strategy, the several segments of the digital code to be encrypted are filled into the empty bytes to obtain the encrypted digital code. This process can reorder the digital code to be encrypted only through the displacement confusion operation, so as to achieve the purpose of keeping the digital code to be encrypted confidential, and the obtained encrypted digital code is still 32-bit bytes, that is, no redundant bytes are generated. Here, the several segments into which the digital code to be encrypted is disassembled are at least two segments, and the specific number of segments is not limited. For example, the original order after disassembly is 111 and 000, then there is only one displacement transformation method, that is, after performing the encryption displacement operation, it becomes 000 and 111, and if it is disassembled into three, four, and five segments, there are more corresponding displacement transformation methods. Therefore, the more segments are disassembled, the more possibilities of displacement operation, and the higher the corresponding cracking difficulty.

[0032] Optionally, the step of obtaining a preset coding displacement strategy in step 2 specifically includes: obtaining an M-bit code of the digital code to be encrypted in a preset bit segment; wherein M is a natural number greater than 1; and obtaining a coding displacement strategy corresponding to the M-bit code. The coded numbers can be flexibly recombined and sorted, and the number of displacement rules can be increased to enhance the complexity of the coding combination sorting, thereby increasing the difficulty of cracking the encrypted digital code.

[0033] Optionally, the preset bit segment is located at the tail of the digital code to be encrypted, which is conducive to quickly obtaining the regular bit value during the decryption process and improving the decryption efficiency.

[0034] An embodiment of the present invention further provides a server, which executes the following steps: obtaining a digital code to be encrypted; obtaining a preset code displacement strategy, and arranging and reorganizing the digital code to be encrypted according to the code displacement strategy to generate an encrypted digital code; and sending the encrypted digital code to a client.

[0035] An embodiment of the present invention further provides a computer storage medium, wherein a computer program is stored on the computer storage medium, and when the computer program is executed by a processor, any of the methods described above is implemented.

[0036] The digital code may be a binary code. Since there are only logic 0 and logic 1 in a computer, directly performing a shift operation on the binary code can make the encryption and decryption process more convenient and efficient.

[0037] In order to more clearly understand the technical content of the present invention, the following embodiments are given in detail.

[0038] A specific form of encryption and decryption process is disclosed below as an implementation form of the present application.

[0039] First, the M-bit encoding of the preset bit segment is described in detail here: the preset bit segment can be the tail digit of the digital code to be encrypted, or the middle digit or the head digit of the digital code to be encrypted. However, since the binary code is usually high-order, for binary codes with very small values, the middle or head digit is always 0, and the corresponding displacement rule is relatively simple and easy to be cracked. The number to be encrypted is, for example, 000011, 000010 or 001100. If the first 2 digits are the preset bit segment, i.e., the displacement rule bit, then the heads of the above three numbers to be encrypted are all 00, and all correspond to the displacement rule numbered 0. However, if the same rule is always used for encryption, it is very easy to be cracked; if the last 2 digits are the preset bit segment, i.e., the displacement rule bit, then there are binary 11, 10, 00, corresponding to the displacement rules numbered 3, 2, 0, respectively, which can significantly increase the difficulty of cracking the encrypted digital code.

[0040] For M-bit encoding, the larger the value of M, the higher the corresponding encryption security. For example, if the value of M is 1, that is, the displacement rule bit is a binary number, the binary number may be 0 or 1, corresponding to two displacement rules; if the value of M is 2, that is, the displacement rule value is a two-bit binary number, it may be 00, 01, 10, 11, corresponding to four displacement rules; if the value of M is 3, the three-bit binary value of the displacement rule value may have 32, that is, 8 values, among which the maximum value of the three-bit binary value 111 corresponds to 7 in decimal. Then, for the displacement rules numbered 0-7, there are 8 corresponding encryption displacement operations, which greatly increases the difficulty of cracking.

[0041] Therefore, for the above-mentioned preset coding shift strategy, for example, a shift rule set is set, and the number of shift rules contained in it should be 2 to the power of n, where n is greater than 0, and the value of n is 2 here, that is, the number of shift rules is 4. The operation steps and marked numbers for setting each shift rule are shown in Table 1:

[0042]

[0043] (Table 1: Operation steps and marking numbers of each displacement rule)

[0044] For example, the original data of the identity ID of a game user is 310, and an encryption processing step is performed here, and the details are described below.

[0045] See also Figure 3 As shown, according to the computer's logic 0 and logic 1, the original data 310 is encoded in binary with the high bit first as follows:

[0046] 00000000 00000000 00000001 00110110,

[0047] For example, the values ​​at the two positions (a1) at the tail of the binary code x are designated as the M-bit codes of the preset bit segment (hereinafter referred to as the regular bit value); the regular bit value is obtained as 10; according to the decimal data 2 of the regular bit value 10, the displacement rule marked with the mark number 2 is correspondingly obtained from the above-mentioned displacement rule set, i.e., Table 1; in the above-mentioned binary code x, the value of the b1 area is encrypted and shifted according to the displacement rule numbered 2. Among them, the regular bit value 10 can remain unchanged at the tail a1, or it can be moved to other specified positions. Here, the regular bit value 10 is moved to the specified position a2 (head) of the new binary code y.

[0048] According to the above content, the encrypted binary code y is:

[0049] 01000000 00000000 00000000 01001101,

[0050] The value of area b2 is obtained by shifting the value of area b1. The encrypted binary code is sent to the client, or converted into a decimal value 1073741901 and sent to the client.

[0051] After the client receives the encrypted identity ID data, when the user generates an operation request, the encrypted identity ID data is sent by the client to the server. At this time, the server performs the decryption step. It should be noted that if the data transmitted by the server and the client is decimal, octal or hexadecimal data or letter data, it can be optionally converted into binary before encryption and decryption. For a computer with only logical 0 and 1, it can achieve efficient encryption and decryption. In addition, based on the main purpose of the present invention, any random code can be shifted, so that the original data is not exposed, thereby achieving the purpose of encryption, and the process will not add new bytes.

[0052] Based on the above content, when the server performs the decryption step, it obtains the rule bit value 10 at the specified position a2 of the encrypted binary code y, and its corresponding displacement rule number is 2. Then, the server executes to move the rule bit value 10 from a2 to a1. Moreover, the decryption displacement operation is performed on the value in the b2 area. The decryption displacement operation is the inverse operation of the encryption displacement operation using the displacement rule No. 2, and no extra bytes are added in the process. Moreover, the encrypted binary code can be quickly restored to the original binary code before encryption, which can improve the overall service performance when encryption and decryption operations are frequently performed, that is, when the server throughput is large.

[0053] It should be noted here that, during the encryption process, the position after the displacement rule value is moved is not limited to a2, but can be the head or any position in the middle of the encrypted binary code y. During the decryption process, the server can accurately obtain the value of the position.

[0054] In this specification, the present invention has been described with reference to specific embodiments thereof. However, it is apparent that various modifications and variations may be made without departing from the spirit and scope of the present invention. Therefore, the specification and drawings should be regarded as illustrative rather than restrictive.

Claims

1. A digital code encryption and decryption method, characterized in that: include: Get the digital code to be encrypted; Obtaining an M-bit code of the digital code to be encrypted in a preset bit segment; wherein M is a natural number greater than 1; and obtaining a preset code shift strategy corresponding to the M-bit code; According to the code displacement strategy, the digital code to be encrypted is decomposed into several code segments, one of which is the M-bit code, and the several code segments are arranged and reorganized to generate an encrypted digital code, specifically including: according to the digital code to be encrypted, creating a new empty byte with the same number of bits; decomposing the digital code to be encrypted into several code segments, one of which is the M-bit code, and according to the code displacement strategy, the several code segments are filled into the empty bytes accordingly to obtain the encrypted digital code; Send the encrypted data code to the client.

2. The digital code encryption and decryption method according to claim 1, characterized in that: The method further comprises: When receiving an operation request from a client, obtaining an encrypted digital code according to the operation request; Obtain the M-bit code and the code shift strategy corresponding to the M-bit code according to the encrypted digital code; The encrypted digital code is decrypted according to the code shift strategy to obtain the digital code to be encrypted.

3. The digital code encryption and decryption method according to claim 1, characterized in that: The digital code to be encrypted is generated by encoding the user ID or by encoding the product ID.

4. The digital code encryption and decryption method according to claim 1, characterized in that: The preset bit segment is located at the end of the digital code to be encrypted.

5. A server, characterized in that: The server is used to implement the method according to any one of claims 1 to 4.

6. A computer storage medium, characterized in that: The computer storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.