Data encryption method, device and storage medium of automobile diagnosis platform
By generating an array of encrypted characters with random numbers and offsets, and scrambling and offsetting the encrypted characters, the security and efficiency issues of data encryption in automotive diagnostic platforms are solved, achieving a more efficient data encryption method.
Patent Information
- Application Number
- CN202211438766.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-17
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2042-11-17
AI Technical Summary
Existing automotive diagnostic platform data encryption methods suffer from poor security and low encryption efficiency, especially the ease of key leakage during key transmission and data fragmentation issues caused by the complexity of the encryption process.
An encrypted character array with generated random numbers and offsets is used. By shuffling the order of the byte array to be encrypted and offsetting each character one by one, ciphertext is generated. This ciphertext is then combined with the identification code ciphertext to assemble a ciphertext byte array, thus achieving data encryption.
It improves the security and efficiency of data encryption, reduces data fragmentation, and is suitable for network transmission.
Smart Images

Figure CN115834025B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data encryption, in particular to a data encryption method, device and storage medium of an automobile diagnosis platform. BACKGROUND
[0002] With the rapid development of automobile diagnosis technology, automobile repair personnel greatly improve the work efficiency with the help of automobile diagnosis instrument, but at the same time, various valuable information on the diagnosis instrument also exists the risk of leakage, how to protect the safety of diagnosis instrument data is a crucial problem.
[0003] In the field of diagnosis instrument data security, using key encryption algorithm to encrypt data is a common security measure. Common key encryption algorithms include symmetric encryption and asymmetric encryption.
[0004] (1) Symmetric encryption algorithm uses single key encryption. In the communication process, the data sender divides the original data into fixed-size blocks, and encrypts each block with the key and encryption algorithm, and then sends it to the receiver. After receiving the encrypted message, the receiver decrypts and combines it with the same key to obtain the original data.
[0005] (2) Asymmetric encryption algorithm uses two different passwords, public key and private key, for encryption and decryption. Public key and private key are paired, and public key is extracted from private key and made public to everyone. If you use a public key to encrypt data, only the corresponding private key (which cannot be made public) can decrypt it, and vice versa.
[0006] The above data encryption method can ensure the security of user data to a certain extent, but in actual use, it is found that there are still some shortcomings in the method, which cannot achieve the best use effect, and the shortcomings can be summarized as follows:
[0007] (1) The shortcomings of symmetric encryption algorithm: poor security, and the encryption and decryption algorithm is public, so the secure transmission of the key is crucial. The key is usually negotiated by both parties and transmitted to the other party in a physical way, or transmitted to the other party by using a third-party platform. Once the key is leaked in this process, people with bad intentions can intercept and decrypt the encrypted content by combining the corresponding algorithm.
[0008] (2) The shortcomings of asymmetric encryption algorithm: the algorithm is very complex, resulting in a long time for encrypting a large amount of data, which is only suitable for encrypting a small amount of data. Moreover, additional information is added in the encryption process, making the encrypted message longer and prone to data fragmentation, which is not conducive to network transmission.
[0009] Therefore, the existing data encryption method has the inconvenience and defects, and needs to be further improved. How to create a new data encryption method has become the goal of the current industry. SUMMARY
[0010] Therefore, the present disclosure provides a data encryption method for an automobile diagnosis platform, which at least partially solves the problems in the prior art.
[0011] In a first aspect, the present disclosure provides a data encryption method for an automobile diagnosis platform, which comprises the following steps:
[0012] A first encrypted character array is generated, which contains a preset Z1 group of preset characters with subscripts. The characters only contain uppercase letters and numbers, and the subscripts are integers from 0 to Z1-1.
[0013] A first random number S1 is selected, wherein S1 is less than Z1.
[0014] An identification code is obtained, which is the character with subscript S1 in the first encrypted character array.
[0015] An identification code ciphertext is obtained, and the value of the first random number S1 is added to the first offset P1 of the identification code to obtain the offset identification code subscript S1+P1. The character with subscript S1+P1 in the first encrypted character array is searched as the identification code ciphertext. The first offset P1 is an integer from 0 to Z1.
[0016] A second encrypted character array and a third encrypted character array are generated, which contain a preset Z2 group of preset characters with subscripts. The subscripts are integers from 0 to Z2-1.
[0017] The first random number S1 is divided by Z2 to obtain a remainder, and the remainder is used as a second offset P2.
[0018] A byte array to be encrypted is obtained, and the order of the byte array to be encrypted is shuffled to obtain a shuffled byte array to be encrypted. The shuffled byte array to be encrypted is converted into a Z2 binary string in order.
[0019] According to the second offset P2, all characters in the Z2 binary string are encrypted one by one to obtain an encrypted Z2 binary string. The encrypted Z2 binary string is divided into two characters as a byte to generate an encrypted byte array.
[0020] Assemble the identification code ciphertext and the encrypted byte array to generate a ciphertext byte array.
[0021] According to a specific implementation of the embodiment of the present disclosure, the step of disarranging the order of the byte array to be encrypted includes the following steps: obtaining the byte array to be encrypted, and calculating the length L of the byte array to be encrypted; when L is greater than P2, moving P2 bytes of the byte array to be encrypted in normal order to the end of the byte array to be encrypted, and moving L-P2 bytes of the byte array to be encrypted in reverse order to the front of the byte array to be encrypted, to generate a byte array to be encrypted with disarranged order; and when the length of the byte array to be encrypted is less than or equal to P2, taking the byte array to be encrypted as the byte array to be encrypted with disarranged order.
[0022] According to a specific implementation of the embodiment of the present disclosure, the step of encrypting all characters in the Z2-ary string one by one according to the second offset P2 includes the following steps:
[0023] When encrypting the Nth character, when N is less than P2, taking the second encrypted character array as an encryption code table; and when N is greater than or equal to P2, taking the third encrypted character array as an encryption code table.
[0024] Finding the subscript N of N in the encryption code table 下标 , taking the value of N 下标 +P2 as the offset identification code subscript; when N 下标 +P2 is greater than Z1-1, resetting the offset identification code subscript to N 下标 +P2-Z2.
[0025] Finding the character with the subscript of the offset identification code subscript in the encryption code table as the ciphertext of the Nth character.
[0026] According to a specific implementation of the embodiment of the present disclosure, the step of converting the byte array to be encrypted with disarranged order into a Z2-ary string in order includes the following steps: converting each byte into two characters, and filling the front with 0 if there are less than two characters.
[0027] According to a specific implementation of the embodiment of the present disclosure, the value of the first random number S1 is added by the first offset P1 of the preset identification code to obtain an offset identification code subscript S1+P1, and the method further includes: when the S1+P1 is greater than Z1-1, resetting the S1+P1 to S1+P1-Z1.
[0028] According to a specific implementation manner of the embodiment of the present disclosure, the subscripted preset character type contained in the second encrypted character array and the third encrypted character array is related to the value of the preset Z2.
[0029] According to a specific implementation manner of the embodiment of the present disclosure, the identification code is one byte.
[0030] In a second aspect, the embodiment of the present disclosure further provides a data decryption method of an automobile diagnosis platform, which is used for decrypting the data encryption method of the automobile diagnosis platform in the first aspect or any implementation manner of the first aspect, and the method comprises the following steps:
[0031] An identification code cipher text in the cipher text array is obtained, and a first random number S1 is obtained by subtracting a first offset P1 of the identification code from the identification code cipher text.
[0032] The first random number S1 is divided by Z2, and a remainder is taken as a second offset P2.
[0033] The cipher text array is converted into the encrypted Z2 binary string.
[0034] According to the second offset P2, all characters in the encrypted Z2 binary string are decrypted one by one to obtain the Z2 binary string.
[0035] The Z2 binary string is taken as two characters as one byte to obtain the scrambled order of the to-be-encrypted byte array.
[0036] The length L of the scrambled order of the to-be-encrypted byte array is calculated, wherein when L is greater than P2, the front L-P2 length of the scrambled order of the to-be-encrypted byte array is moved to the end of the scrambled order of the to-be-encrypted byte array, and at the same time, the last P2 bytes of the scrambled order of the to-be-encrypted byte array are placed at the front of the scrambled order of the to-be-encrypted byte array to obtain the to-be-encrypted byte array; and when the length of the to-be-encrypted byte array is less than or equal to P2, the scrambled order of the to-be-encrypted byte array is the to-be-encrypted array.
[0037] In a third aspect, the embodiment of the present disclosure further provides an electronic device, which comprises:
[0038] at least one processor; and
[0039] a memory in communication connection with the at least one processor; wherein
[0040] The memory stores instructions capable of being executed by the at least one processor, and the instructions are executed by the at least one processor to cause the at least one processor to execute the data encryption method of the automobile diagnosis platform in the first aspect or any one of the implementation manners of the first aspect.
[0041] In a fourth aspect, the embodiments of the present disclosure further provide a non-transitory computer-readable storage medium storing computer instructions, which, when executed by at least one processor, cause the at least one processor to execute the data encryption method of the automobile diagnosis platform in the first aspect or any one of the implementation manners of the first aspect.
[0042] In a fifth aspect, the embodiments of the present disclosure further provide a computer program product, which comprises a computer program stored on a non-transitory computer-readable storage medium, and the computer program comprises program instructions, which, when executed by a computer, cause the computer to execute the data encryption method of the automobile diagnosis platform in the first aspect or any one of the implementation manners of the first aspect.
[0043] The data encryption method of the automobile diagnosis platform in the embodiments of the present disclosure can improve data encryption security and encryption efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0044] The above is only a summary of the technical scheme of the present application. In order to more clearly understand the technical means of the present application, the present application will be further described in detail below in combination with the drawings and specific embodiments.
[0045] Figure 1 A flowchart of the data encryption method of the automobile diagnosis platform provided by the embodiments of the present disclosure is shown in the figure.
[0046] Figure 2 An electronic device provided by the embodiments of the present disclosure is shown in the figure. DETAILED DESCRIPTION
[0047] The embodiments of the present disclosure will be described in detail below in combination with the drawings.
[0048] The following detailed description is presented in order to describe the aspects of the application and it is not intended that this application be limited thereof. It will be appreciated that the detailed description is presented primarily for purposes of illustration and that deviations from the specific embodiments described herein, that are clear to one skilled in the art, are intended to be within the scope of the present application. It should be appreciated by persons skilled in the art that the present application is not limited to the embodiments described herein and that the scope of the present application is defined by the appended claims.
[0049] It is to be understood that the foregoing description is that of certain examples of the application and that numerous changes in the details of construction and the combination and arrangement of parts can be made by those skilled in the art without departing from the scope of the application. It is intended that all such changes be within the scope of the following claims.
[0050] It is also to be understood that the following description is only illustrative of the aspects of the present application and that changes can be made in the details and arrangement of parts by those skilled in the art without departing from the scope of the present application as set forth in the appended claims.
[0051] Furthermore, in the following description, numerous specific details are set forth in order to provide a thorough understanding of the examples. However, it will be recognized by one skilled in the art that the aspects described herein can be practiced without these specific details.
[0052] The data encryption method of the automobile diagnosis platform provided by the application is used for encrypting data of communication between the automobile diagnosis platform and the server, such as a username, a password, permission data issued from the server during update of user menu permission, special inspection permission data issued from the server during update of user special inspection permission, user id and tablet mac address and other client information which need to be uploaded when the client accesses the server, so that the data encryption security is improved and the encryption efficiency is improved.
[0053] Figure 1A schematic diagram of a data encryption method flow of an automobile diagnosis platform provided by an embodiment of the present disclosure.
[0054] As shown in FIG. 1, at step S110, a first encrypted character array is generated, which contains preset characters with subscripts of a Z1 group, wherein the characters only contain capital letters and numbers, and the subscripts are integers from 0 to Z1-1. Figure 1
[0055] For example, an encrypted character array g_cArrayEncrypt1 (or first encrypted character array) with a length of ENC_KEY_MAXCOUNT=36 (or Z1=36) is generated in advance, which contains only capital letters and numbers, and the subscripts are integers from 0 to 36, as shown in Table g_cArrayEncrypt1.
[0056] g_cArrayEncrypt1:
[0057]
[0058] More specifically, next turn to step S120.
[0059] At step S120, a first random number S1 is selected, wherein S1 is less than Z1.
[0060] For example, an integer between 0 and 36 is randomly generated, and the value range is S1=[0, 36) (or rand=[0, 36)), which includes 0 but does not include 36, for example, S1=5 is selected.
[0061] Next turn to step S130.
[0062] At step S130, an identification code is obtained, which is a character with subscript S1 in the first encrypted character array.
[0063] For example, the character with subscript 5 in Table g_cArrayEncrypt1 is found as the identification code, that is, identification code=g_cArrayEncrypt1[rand]=2.
[0064] Next turn to step S140.
[0065] At step S140, an identification code ciphertext is obtained, the value of the first random number S1 is added to a preset first offset P1 of the identification code, to obtain an offset identification code subscript S1+P1; and a character with subscript S1+P1 in the first encrypted character array is found as the identification code ciphertext.
[0066] In the embodiment of the present application, the method further comprises resetting the S1+P1 to S1+P1-Z1 when the S1+P1 is greater than Z1-1.
[0067] For example, the identification code encryption comprises the following steps:
[0068] (1) The first offset KEY OFFSET is fixed to 9 (or P1=9), and the encryption code array is fixed to g_cArrayEncrypt1.
[0069] (2) The value of rand (the first random number S1)+KEY OFFSET (the first offset P1) is taken as the offset identification code index new_index, that is,
[0070] new_index=rand+KEY OFFSET=5+9=14.
[0071] The value of new_index is compared with ENC KEY MAXCOUNT-1, and when the value of new_index is greater than ENC KEY MAXCOUNT-1, the new_index is reset to rand+KEY OFFSET-ENC KEY MAXCOUNT.
[0072] According to the data, 14 is less than 36-1, so the offset identification code index is 14.
[0073] (3) The character with the index new_index in the encryption array g_cArrayEncrypt1 is taken as the identification code ciphertext encryptKey, that is,
[0074] The identification code ciphertext encryptKey=g_cArrayEncrypt1[new_index].
[0075] According to the search of the encryption array g_cArrayEncrypt1, the character corresponding to the identification code index 14 is J.
[0076] Next, go to step S150.
[0077] At step S150, a second encryption code character array and a third encryption code character array are generated, and the second encryption code character array and the third encryption code character array contain preset Z2 groups of preset characters with indexes, and the indexes are integers from 0 to Z2-1.
[0078] In the embodiment of the present application, the subscripted preset character types contained in the second and third encryption character arrays are related to the value of the preset Z2. For example, when Z2 is 16, the preset characters are A-F and numbers in hexadecimal system, and the lengths of the second and third encryption character arrays are 16; when Z2 is 10, the preset characters are 0-9 in decimal system, and the lengths of the second and third encryption character arrays are 10; when Z2 is 8, the preset characters are 0-7 in octal system, and the lengths of the second and third encryption character arrays are 8; and so on.
[0079] For example, two encryption character arrays g_cArrayEncrypt2 (or the second encryption character array) and g_cArrayEncrypt3 (or the third encryption character array) with the length of ENC_MAXCOUNT = 16 (or Z2 = 16) are generated in advance, and the encryption character arrays are shown in Table g_cArrayEncrypt2 and Table g_cArrayEncrypt3.
[0080] g_cArrayEncrypt2:
[0081] subscript 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 character 3 4 F 6 1 E 2 D A 0 B C 5 8 9 7
[0082] g_cArrayEncrypt3:
[0083] subscript 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 character C 3 4 F 6 1 E 2 D A 0 B 5 8 9 7
[0084] Next, go to step S160.
[0085] At step S160, the first random number S1 is divided by Z2 to obtain a remainder, and the remainder is taken as the second offset P2.
[0086] For example, the value of offset (or the second offset P2) is obtained by dividing the first random number S1 by the length ENC_MAXCOUNT (or Z2) of the second and third encryption character arrays and taking the remainder, i.e., offset = rand / ENC_MAXCOUNT.
[0087] According to the data, the second offset P2 is 5.
[0088] Next, go to step S170.
[0089] At step S170, an array of bytes to be encrypted is obtained, and the order of the array of bytes to be encrypted is shuffled to obtain an array of bytes to be encrypted with shuffled order; and the array of bytes to be encrypted with shuffled order is converted into a Z2-ary string in order.
[0090] In the embodiment of the present application, the order of the byte array to be encrypted is shuffled, including the following steps: obtaining the byte array to be encrypted, and calculating the length L of the byte array to be encrypted, wherein when L is greater than P2, P2 bytes of the byte array to be encrypted in normal order are moved to the end of the byte array to be encrypted, and L-P2 bytes of the byte array to be encrypted in reverse order are moved to the front of the byte array to be encrypted, to generate the byte array to be encrypted in shuffled order; and when the length of the byte array to be encrypted is less than or equal to P2, the byte array to be encrypted is taken as the byte array to be encrypted in shuffled order, which does not constitute a limitation to the present application.
[0091] For example, the order of the byte array to be encrypted byte[] contentBytes is shuffled, including the following steps: calculating the length length (or L) of the byte array to be encrypted, and if the length is greater than the value of the second offset offset, then the first offset bytes in the byte array to be encrypted byte[] contentBytes are placed at the end of the byte array to be encrypted, and the last length-offset bytes of the byte array to be encrypted are placed at the front of the byte array to be encrypted, to generate the byte array to be encrypted in shuffled order, otherwise the order of the byte array to be encrypted is not changed.
[0092] The byte array to be encrypted contentBytes:
[0093]
[0094] The length of the byte array to be encrypted is taken as L=15, and the data shows that 15 is greater than the second offset 5, the first 5 bytes in the byte array to be encrypted are placed at the end of the byte array to be encrypted, and the last 11 bytes of the byte array to be encrypted are placed at the front of the byte array to be encrypted, to generate the byte array to be encrypted in shuffled order contentBytes.
[0095] The byte array to be encrypted in shuffled order:
[0096]
[0097] As can be seen from the example of step S150, when Z2=16, the Z2 system is hexadecimal, the byte array to be encrypted in shuffled order is converted into a hexadecimal string contentHexs, each byte is converted into two characters, and 0 is added in front of the characters if there are less than two characters.
[0098] The hexadecimal string contentHexs:
[0099]
[0100] Next, go to step S180.
[0101] At step S180, according to the second offset P2, all characters in the Z2 binary string are encrypted by offsetting one by one to obtain an encrypted Z2 binary string; and the encrypted Z2 binary string is taken as two characters as a byte to generate an encrypted byte array.
[0102] In the embodiment of the present application, according to the second offset P2, all characters in the Z2 binary string are encrypted by offsetting one by one, including the following steps:
[0103] When offsetting the Nth character, if N is less than P2, the second encrypted code character array is taken as an encryption code table; and if N is greater than or equal to P2, the third encrypted code character array is taken as an encryption code table;
[0104] In the encryption code table, the index N of the Nth character is found 下标 , and the value of N 下标 +P2 is taken as the index of the offset identification code; wherein when N 下标 +P2 is greater than Z1-1, the index of the offset identification code is reset to N 下标 +P2-Z2;
[0105] In the encryption code table, the character with the index of the index of the offset identification code is found as the ciphertext of the Nth character.
[0106] For example, according to the second offset, the byte array byte[]contentBytes to be encrypted is encrypted to obtain an encrypted byte array byte[]encryptContentBytes, including the following steps:
[0107] (1) According to the second offset offset, all characters in the hexadecimal string contentHexs are encrypted by offsetting one by one to obtain an encrypted hexadecimal string encryptContentHexs, for example: when offsetting the Nth character, if N<offset, the second encrypted code character array g_cArrayEncrypt2 is taken as an encryption code table g_cArrayEncrypt; and if n>=offset, the third encrypted code character array g_cArrayEncrypt3 is taken as an encryption code table g_cArrayEncrypt.
[0108] In the encryption code table g_cArrayEncrypt, the index index of the Nth character is found, and the value of index+offset is taken as the index new_index of the offset identification code, that is
[0109] new_index=index+offset, when the value of new_index is greater than ENC_MAXCOUNT-1, reset new_index to: index+offset-ENC_MAXCOUNT, and find the character with index new_index in the encryption table g_cArrayEncrypt as the ciphertext of the Nth character, that is: the ciphertext of the Nth character=g_cArrayEncrypt[new_index], and the encryption of the Nth character ends.
[0110] For example, according to the second offset offset=5, all characters in the hexadecimal string contentHexs=“05060708090A0B0C0D0E0F0001020304” are encrypted by offsetting one by one to obtain the encrypted hexadecimal string encryptContentHexs, for example: for example, when encrypting the first character 0, find the character 0 in g_cArrayEncrypt2 with index 9, and index+offset=9+5=14 as the ciphertext index after offsetting, find the character 9 with index 14 in the encryption table g_cArrayEncrypt as the ciphertext of the current plaintext character 0.
[0111] In this way, the entire encrypted hexadecimal string encryptContentHexs is “949A96747F797C71787B7D7770757E72”, which will not be described here.
[0112] (2) The encrypted hexadecimal string encryptContentHexs is converted into an encrypted byte array encryptContentBytes with two characters as a byte.
[0113] The encrypted byte array encryptContentBytes:
[0114]
[0115] Next, go to step S190.
[0116] At step S190, the identification code ciphertext and the encrypted byte array are assembled to generate a ciphertext byte array.
[0117] More specifically, the ciphertext byte array=identification code ciphertext (1 byte)+encrypted byte array, wherein the identification code is an automatically generated byte, and the encrypted byte array is obtained by encrypting the user-entered byte array to be encrypted byte[]contentBytes.
[0118] In the embodiments of the present application, the identification code ciphertext can be located in the first byte of the ciphertext byte array, or in other agreed positions in the ciphertext byte array, which does not constitute a limitation to the present application.
[0119] For example, the identification code ciphertext is J, and the corresponding hexadecimal is 4A, so the assembled entire ciphertext byte array is as follows:
[0120]
[0121] In the embodiments of the present application, the first random number, the first encrypted character array, the second encrypted character array, and the third encrypted character array are data agreed by the encryption party and the decryption party in advance.
[0122] In the embodiments of the present application, the decryption method corresponding to the data encryption method of the automobile diagnosis platform of the present application specifically includes the following decryption steps:
[0123] Obtaining the identification code ciphertext in the ciphertext byte array, and obtaining the first random number S1 by subtracting the first offset P1 of the identification code from the subscript of the identification code ciphertext.
[0124] Dividing the first random number S1 by Z2 and taking the remainder, and the remainder is the second offset P2.
[0125] Converting the encrypted byte array into the encrypted Z2 binary string.
[0126] According to the second offset P2, offset decryption is performed on all characters in the encrypted Z2 binary string to obtain the Z2 binary string.
[0127] Taking two characters as a byte, the Z2 binary string is obtained as the disordered to-be-encrypted byte array.
[0128] Calculating the length L of the disordered to-be-encrypted byte array, wherein when L is greater than P2, the front L-P2 length of the disordered to-be-encrypted byte array is moved to the end of the disordered to-be-encrypted byte array, and at the same time, the last P2 bytes of the disordered to-be-encrypted byte array are placed at the front of the disordered to-be-encrypted byte array to obtain the to-be-encrypted byte array; and when the length of the to-be-encrypted byte array is less than or equal to P2, the disordered to-be-encrypted byte array is the to-be-encrypted array.
[0129] For example, the decryption includes the following steps:
[0130] Ciphertext byte group:
[0131]
[0132] (1) Get the first random number rand from the cipher byte array: get the identification code cipher byte 4A from the first bit of the cipher byte array, and convert it to the decimal character J. Find the index of this byte in the first encryption code character array g_cArrayEncryptl, which is 14. Since the offset of the identification code is 9, the index of the plaintext (or the index of the identification code after the offset) new_index = 15 - 9 = 5, that is, the value of the first random number is 5.
[0133] (2) Calculate the second offset offset: divide the first random number 5 by the length 16 of the second and third encryption code character arrays and take the remainder, which is the value of the second offset offset, that is: offset = 5.
[0134] (3) Decrypt the encrypted byte array.
[0135] a) Convert the cipher byte group excluding the identification code into a capital hexadecimal string encryptContentHexs in order, each byte into two characters, and the insufficient two characters are supplemented in front of 0, to get the hexadecimal string "949A96747F797C71787B7D7770757E72".
[0136] b) Because the second offset is 5, the first 5 bits of the hexadecimal string use g_cArrayEncrypt2 as the decryption code table, and the rest use the code table g_cArrayEncrypt3 as the decryption code table. For example, when decrypting the first character 9, find the index of character '9' in the code table g_cArrayEncrypt2, which is 14. Because the cipher index is: plaintext index + offset offset during encryption, so the plaintext index is: cipher index - offset offset = 14 - 5 = 9. Find the character with index 9 in the code table g_cArrayEncrypt2, which is 0. 0 is the plaintext corresponding to the cipher character 9. Thus, the first character 9 is decrypted. Similarly, the decrypted hexadecimal string is "05060708090A0B0C0D0E0F0001020304". This will not be described in detail.
[0137] c) Convert the decrypted hexadecimal character "05060708090A0B0C0D0E0F0001020304" into a decrypted hexadecimal byte array contentBytes with two characters as a byte. The decrypted hexadecimal byte array contentBytes:
[0138]
[0139] The decrypted hexadecimal byte array contentBytes is converted into a decrypted decimal byte array.
[0140] The decrypted decimal byte array:
[0141]
[0142] d) Restoring the byte array order: if the length of the decrypted decimal byte array contentBytes is greater than 5, the first 11 bytes of the decrypted decimal byte array contentBytes are placed at the end of the decrypted byte array, and the last 5 bytes of the decrypted decimal byte array are placed at the front of the decrypted byte array, to generate a decrypted decimal byte array of restored byte array order, and the decryption ends.
[0143] The decrypted decimal byte array of restored byte array order:
[0144]
[0145] Referring to Figure 2 The embodiments of the present disclosure also provide an electronic device 20, which comprises:
[0146] at least one processor; and
[0147] a memory connected in communication with the at least one processor; wherein
[0148] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the data encryption method of the automotive diagnostic platform in the foregoing method embodiments.
[0149] The embodiments of the present disclosure also provide a non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the data encryption method of the automotive diagnostic platform in the foregoing method embodiments.
[0150] The embodiments of the present disclosure also provide a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions that, when executed by a computer, cause the computer to perform the data encryption method of the automotive diagnostic platform in the foregoing method embodiments.
[0151] Reference will be made to the following Figure 2The diagram illustrates a structural schematic of an electronic device 20 suitable for implementing embodiments of the present disclosure. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 2 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0152] like Figure 2 As shown, the electronic device 20 may include a processing unit (e.g., a central processing unit, a graphics processor, etc.) 201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 202 or a program loaded from a storage device 208 into a random access memory (RAM) 203. The RAM 203 also stores various programs and data required for the operation of the electronic device 20. The processing unit 201, ROM 202, and RAM 203 are interconnected via a bus 204. An input / output (I / O) interface 205 is also connected to the bus 204.
[0153] Typically, the following devices can be connected to I / O interface 205: input devices 206 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 207 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 208 including, for example, magnetic tapes, hard disks, etc.; and communication devices 209. Communication device 209 allows electronic device 20 to communicate wirelessly or wiredly with other devices to exchange data. Although electronic device 20 with various devices is shown in the figure, it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0154] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 209, or installed from storage device 208, or installed from ROM 202. When the computer program is executed by processing device 201, it performs the functions defined in the methods of embodiments of this disclosure.
[0155] It should be noted that the computer-readable medium in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the present disclosure, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take many forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or apparatus. The program code contained in the computer-readable medium can be transmitted by any suitable medium, including but not limited to a wire, a cable, a RF (radio frequency) or the like, or any suitable combination of the above.
[0156] The computer-readable medium described above can be contained in the electronic device described above; or can exist separately and not be assembled into the electronic device.
[0157] The computer-readable medium described above carries one or more programs, when the one or more programs are executed by the electronic device, the electronic device is caused to: obtain at least two Internet protocol addresses; send a node evaluation request including the at least two Internet protocol addresses to a node evaluation device, wherein the node evaluation device selects an Internet protocol address from the at least two Internet protocol addresses and returns; receive the Internet protocol address returned by the node evaluation device; wherein the obtained Internet protocol address indicates an edge node in a content distribution network.
[0158] Alternatively, the computer readable medium described above carries one or more programs, when the one or more programs are executed by the electronic device, the electronic device is caused to: receive a node evaluation request comprising at least two internet protocol addresses; select an internet protocol address from the at least two internet protocol addresses; and return the selected internet protocol address; wherein the received internet protocol address indicates an edge node in a content distribution network.
[0159] Computer program code for carrying out operations of the present disclosure can be written in any one or more of a variety of programming languages or combinations of languages, including an object-oriented programming language such as Java, Smalltalk, C++, or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0160] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flow diagrams, and combinations of blocks in the block diagrams and / or flow diagrams, can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.
[0161] The units described in the embodiments of the present disclosure can be implemented by means of software, or by means of hardware. In some cases, the name of a unit does not constitute a limitation on the unit itself, for example, a first obtaining unit can also be described as an "obtaining unit of at least two internet protocol addresses".
[0162] It should be understood that various parts of the present disclosure can be implemented by hardware, software, firmware, or a combination thereof.
[0163] The above description is merely that of a specific implementation of the present disclosure, but the scope of protection of the present disclosure is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present disclosure, and such changes or replacements should be covered within the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure should be subject to the scope of protection of the claims.
Claims
1. A data encryption method of an automotive diagnostic platform, characterized by, The method comprises the following steps: generating a first encryption character array containing preset characters with subscripts in Z1 groups, wherein the characters only contain capital letters and numbers, and the subscripts are integers from 0 to Z1-1; selecting a first random number S1, wherein S1 is less than Z1; obtaining an identification code, which is a character with subscript S1 in the first encryption character array; obtaining an identification code ciphertext, adding a first offset P1 of the identification code to the value of the first random number S1 to obtain an offset identification code subscript S1+P1, and searching for a character with subscript S1+P1 in the first encryption character array as the identification code ciphertext, wherein the first offset P1 is an integer from 0 to Z1; generating a second encryption character array and a third encryption character array, which contain preset characters with subscripts in Z2 groups, wherein the subscripts are integers from 0 to Z2-1; dividing the first random number S1 by Z2 to obtain a remainder, and taking the remainder as a second offset P2; obtaining a byte array to be encrypted, and shuffling the order of the byte array to be encrypted to obtain a shuffled byte array to be encrypted; and converting the shuffled byte array to be encrypted into a Z2-ary string in order; according to the second offset P2, offset-encrypting all characters in the Z2-ary string one by one to obtain an encrypted Z2-ary string; and generating an encrypted byte array by taking two characters as a byte in the encrypted Z2-ary string; the offset-encryption of all characters in the Z2-ary string according to the second offset P2 comprises the following steps: when N is less than P2, taking the second encryption character array as an encryption code table; and when N is greater than or equal to P2, taking the third encryption character array as an encryption code table; finding the index N of N in the encryption table 下标 , N 下标 + P2 as the offset identification code index; wherein when N 下标 + P2 is greater than Z1-1, resetting the offset identification code index as N 下标 + P2 - Z2; finding a character with the offset identification code subscript in the encryption code table as the ciphertext of the Nth character; assembling the identification code ciphertext and the encrypted byte array to generate a ciphertext byte array.
2. The method of data encryption for automotive diagnostic platform as claimed in claim 1 wherein, the shuffling of the order of the byte array to be encrypted comprises the following steps: obtaining a byte array to be encrypted, and calculating the length L of the byte array to be encrypted; when L is greater than P2, moving the first P2 bytes of the byte array to be encrypted to the end of the byte array to be encrypted, and moving the last L-P2 bytes of the byte array to be encrypted to the front of the byte array to be encrypted to generate a shuffled byte array to be encrypted; and when the length of the byte array to be encrypted is less than or equal to P2, taking the byte array to be encrypted as a shuffled byte array to be encrypted.
3. The method of data encryption for automotive diagnostic platform as claimed in claim 1 wherein, the conversion of the shuffled byte array to be encrypted into a Z2-ary string in order comprises the following steps: converting each byte into two characters, and supplementing 0 in front of the characters if the number of characters is less than two.
4. The method of data encryption for automotive diagnostic platform as claimed in claim 1 wherein, The value of the first random number S1 is added by a preset first offset P1 of the identification code to obtain an offset identification code index S1+P1, and the method further includes resetting the S1+P1 as S1+P1-Z1 when the S1+P1 is greater than Z1-1.
5. The method of data encryption for automotive diagnostic platform as claimed in claim 1 wherein, The preset character type with index contained in the second encrypted character array and the third encrypted character array is related to the value of the preset Z2.
6. The method of data encryption of an automotive diagnostic platform according to any one of claims 1 to 5, characterized in that, The identification code is one byte.
7. A data decryption method of an automobile diagnosis platform, characterized in that, The data decryption method of the automobile diagnosis platform is used for decrypting the data encryption method of the automobile diagnosis platform in any one of claims 1 to 6, and the method comprises the following steps: An identification code ciphertext in the ciphertext byte array is obtained by subtracting a first offset P1 of the identification code from an index of the identification code ciphertext to obtain a first random number S1. The first random number S1 is divided by Z2 and the remainder is a second offset P2. The ciphertext byte array is converted into the encrypted Z2 binary string. According to the second offset P2, all characters in the encrypted Z2 binary string are decrypted by offsetting one by one to obtain the Z2 binary string. The Z2 binary string is taken as two characters as one byte to obtain the disordered sequence of the to-be-encrypted byte array. The length L of the disordered sequence of the to-be-encrypted byte array is calculated, wherein when L is greater than P2, the front L-P2 length of the disordered sequence of the to-be-encrypted byte array is moved to the end of the disordered sequence of the to-be-encrypted byte array, and at the same time, the last P2 bytes of the disordered sequence of the to-be-encrypted byte array are placed at the front of the disordered sequence of the to-be-encrypted byte array to obtain the to-be-encrypted byte array; and when the length of the to-be-encrypted byte array is less than or equal to P2, the disordered sequence of the to-be-encrypted byte array is the to-be-encrypted array.
8. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions, when executed by the at least one processor, cause the at least one processor to execute the data encryption method of the automobile diagnosis platform in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium, comprising: The non-transitory computer readable storage medium stores computer instructions, and the computer instructions, when executed by at least one processor, cause the at least one processor to execute the data encryption method of the automobile diagnosis platform in any one of claims 1 to 6.
Citation Information
Patent Citations
Encryption and decryption method capable of automatically retrieving keys and selecting algorithms
CN104363091A
XDR data information encryption method, device and equipment, and medium
CN108377183A