Production signal encryption transmission method, system and medium based on cryptographic hash function

By randomly generating encryption keys and using cryptographic hash functions to calculate signal hash values, the problem of insufficient integrity verification and easy cracking of keys in signal encrypted transmission is solved, and the security and integrity of signal encrypted transmission are improved.

CN118487865BActive Publication Date: 2024-09-20FUWEI BENTLER AUTO PARTS (TIANJIN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410912119.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-09
Publication Date
2024-09-20
Estimated Expiration
2044-07-09

AI Technical Summary

Technical Problem

Existing signal encryption transmission technology cannot ensure the integrity of the transmitted signal, and the fixed key is easy to be cracked, making the encrypted signal easy to be tampered with or cracked.

Method used

Randomly generate encryption keys, convert them into initial conversion codes and initial conversion keys, perform encryption operations based on the encoding matrix and key matrix, use the cryptographic hash function to calculate the signal hash value, and integrate the encrypted signal and key into the hash value, transmitted to the receiving end for integrity verification and decryption.

Benefits of technology

It improves the security and integrity of signal encryption transmission, prevents cracking caused by long-term key replacement, enhances the complexity and privacy of the encryption process, and ensures that the signal is not tampered with.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118487865B
    Figure CN118487865B
Patent Text Reader

Abstract

The present invention discloses a method, system and medium for encrypting and transmitting a production signal based on a cryptographic hash function, and relates to the technical field of signal encryption transmission, comprising the following steps: outputting a production signal, performing algorithm encryption on the production signal, and obtaining an encrypted signal; calculating the encrypted signal based on a cryptographic hash function, and obtaining an encrypted hash value; transmitting the encrypted signal and the encrypted hash value, and after a receiving end receives the encrypted signal and the encrypted hash value, performing integrity verification on the encrypted signal based on the encrypted hash value; after the verification is passed, the receiving end decrypts the encrypted signal to obtain a decrypted signal; the present invention is used to solve the problem that the existing signal encryption transmission technology still has insufficient verification of the integrity of the transmission signal and the encryption process is not complex enough, resulting in the encrypted signal being easily tampered with or cracked.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of signal encryption transmission, and in particular to a method, system and medium for encrypting and transmitting production signals based on a cryptographic hash function. Background Art

[0002] Signal encryption transmission technology refers to encrypting signals to ensure confidentiality, integrity and authentication during signal transmission. It involves the use of cryptographic algorithms and keys to convert original signals to protect them from unauthorized parties during transmission and storage. The goal of this technology is to prevent unauthorized visitors from obtaining signal content and protect the privacy and confidentiality of signals. It can also prevent unauthorized modification or tampering of signals to ensure the integrity of signals. In addition, by providing an authentication mechanism, encryption transmission technology can also verify the source of the signal and ensure the authentication of the signal.

[0003] The existing signal encryption transmission technology usually encrypts the transmission signal and then transmits the encrypted signal, which only ensures the security of the transmission signal but cannot ensure the integrity of the transmission signal. If the transmission signal is tampered with, it will cause instruction errors, which will cause a lot of economic losses in the production process. At the same time, the existing signal encryption transmission technology usually uses a fixed key when encrypting the transmission signal. If the key is not changed for a long time, it is easy to cause the encryption program to be cracked, and the encryption process is not complex enough, resulting in insufficient security of the transmission signal. For example, in the Chinese patent application publication number CN117879971A, a signal link encryption method, signal system, device and storage medium are disclosed. The scheme encrypts the first original message to ensure the privacy of the first original message, but does not verify the integrity of the data when decrypting it. If the data is tampered with, it will cause signal errors. The existing signal encryption transmission technology also has the problem of insufficient verification of the integrity of the transmission signal and the encryption process is not complex enough, resulting in the encrypted signal being easily tampered with or cracked. Summary of the invention

[0004] The present invention aims to solve one of the technical problems in the prior art to at least a certain extent, by randomly generating an encryption key, then converting a production signal and the encryption key into an initial conversion code and an initial conversion key, analyzing the initial conversion code and the initial conversion key to obtain a coding matrix and a key matrix, performing encryption operation on the coding matrix through the key matrix to obtain an encrypted signal, then calculating the encrypted signal through a cryptographic hash function to obtain a signal hash value, then integrating the function salt and the encryption key into the signal hash value to obtain an encrypted hash value, sending the encrypted signal and the encrypted hash value to a receiving end, the receiving end calculating the received encrypted signal and the encrypted hash value to obtain a decrypted hash value and a standard hash value, judging whether the encrypted signal has been tampered with based on the decrypted hash value and the standard hash value, and decrypting the encrypted signal if the integrity verification passes, so as to solve the problem that the existing signal encryption transmission technology still has insufficient verification of the integrity of the transmission signal and the encryption process is not complex enough, resulting in the encrypted signal being easily tampered with or cracked.

[0005] To achieve the above objectives, in a first aspect, the present application provides a method for encrypting and transmitting a production signal based on a cryptographic hash function, comprising the following steps:

[0006] Output the production signal, perform algorithm encryption on the production signal, and obtain an encrypted signal;

[0007] Calculating the encrypted signal based on the cryptographic hash function to obtain an encrypted hash value;

[0008] The encrypted signal and the encrypted hash value are transmitted, and after the receiving end receives the encrypted signal and the encrypted hash value, the receiving end verifies the integrity of the encrypted signal based on the encrypted hash value;

[0009] After the verification is passed, the receiving end decrypts the encrypted signal to obtain the decrypted signal.

[0010] Furthermore, outputting the production signal, encrypting the production signal by an algorithm, and obtaining the encrypted signal includes the following sub-steps:

[0011] Randomly generate encryption keys;

[0012] Obtain the production signal, convert the production signal into a hexadecimal code according to the ASCII code, and name it as the initial conversion code; convert the encryption key into a hexadecimal code according to the ASCII code, and name it as the initial conversion key;

[0013] Number the characters in the initial conversion code, using the symbol CB n Indicates, where n is a non-zero natural number and n is the serial number of CB, the characters in the initial conversion key are numbered, and the symbol CM m It represents, where m is a non-zero natural number and m is the serial number of CM;

[0014] Get the maximum values ​​of n and m, label them as max(n) and max(m) respectively, calculate max(n) / 4, and represent the result as p, calculate max(m) / 4, and represent the result as q;

[0015] Starting from n=1, follow to The initial conversion code is converted into a 2×2 coding sub-matrix in the order of , and all the coding sub-matrices are integrated and named as the coding matrix;

[0016] Starting from m=1, follow to The initial conversion code is converted into a 2×2 key sub-matrix in the order of , and all the key sub-matrices are integrated and named as the key matrix;

[0017] The encoding matrix is ​​encrypted using the key matrix to obtain an encrypted signal.

[0018] Furthermore, performing encryption operation on the encoding matrix by using the key matrix includes the following sub-steps:

[0019] Obtain the encoding matrix and the key matrix;

[0020] The encoding sub-matrices in the encoding matrix are numbered, using the symbol X i Indicates, where i is a non-zero natural number and i is the serial number of X; the key submatrices in the key matrix are numbered, and the symbol Y j Indicates, where j is a non-zero natural number and j is the sequence number of Y;

[0021] Starting from i=1, for X i ,calculate , and mark the result as V i , where max(j) is the maximum value of j, i is increased by 1, and V is calculated repeatedly i , until all X i The calculation is completed;

[0022] Starting from i=1, V i With V i+1 Swap, and continue to swap i+2 until i=max(i)+1, where max(i) is the maximum value of i;

[0023] After the replacement is completed, V i From left to right, they are labeled G t , where t is a non-zero natural number and the range of t is the same as that of i;

[0024] G t Convert to a coded format to obtain an encrypted signal.

[0025] Furthermore, G t The conversion into the encoding format to obtain the encrypted signal includes the following sub-steps:

[0026] Get G t , the G t The format is , where (4×t-3), (4×t-2), (4×t-1) and (4×t) are the serial numbers of A, named as element subscripts;

[0027] G t The matrix elements in are arranged in ascending order according to the element subscript to obtain the encrypted signal.

[0028] Furthermore, calculating the encrypted signal based on the cryptographic hash function to obtain the encrypted hash value includes the following sub-steps:

[0029] Based on the PBKDF2 algorithm, set the function salt and number of iterations;

[0030] Get the number of bits of the encryption key, marked as the number of bits of the key;

[0031] Set the number of iterations to the number of key bits, and randomly generate a function salt with the same number of key bits;

[0032] The encrypted signal is calculated using the PBKDF2 algorithm to obtain a signal hash value;

[0033] The function salt is concatenated to the head of the signal hash value, and the encryption key is concatenated to the tail of the signal hash value to obtain an encrypted hash value.

[0034] Furthermore, the encrypted signal and the encrypted hash value are transmitted, and after the receiving end receives the encrypted signal and the encrypted hash value, the integrity verification of the encrypted signal based on the encrypted hash value includes the following sub-steps:

[0035] transmitting the encrypted signal and the encrypted hash value to a receiving end;

[0036] After receiving the encrypted signal and the encrypted hash value, the receiving end starts from the head of the encrypted hash value and obtains characters in the encrypted hash value backward, which is named as the first string; and starts from the tail of the encrypted hash value and obtains characters forward, which is named as the second string;

[0037] The length of the first string and the length of the second string are always the same, and the number of characters remaining in the encrypted hash value is detected in real time, which is named as the number of remaining characters;

[0038] When the number of remaining characters is equal to the first character threshold, a hash legality signal is output;

[0039] If a hash legality signal is output, the remaining characters in the encrypted hash value are marked as standard hash values;

[0040] The integrity of the encrypted signal is verified based on a standard hash value.

[0041] Further, performing integrity verification on the encrypted signal based on the standard hash value includes the following sub-steps:

[0042] Set the first string as the function salt, obtain the number of characters in the first string, mark it as the salt number, and set the number of iterations to the salt number;

[0043] The encrypted signal is calculated using the PBKDF2 algorithm to obtain the decrypted hash value;

[0044] The decrypted hash value is compared with the standard hash value. If the decrypted hash value is the same as the standard hash value, a data integrity signal is output; if the decrypted hash value is different from the standard hash value, a data incomplete signal is output;

[0045] If the output data is incomplete, reapply for the production signal.

[0046] Furthermore, after the verification is passed, the receiving end decrypts the encrypted signal, and obtaining the decrypted signal includes the following sub-steps:

[0047] If a data integrity signal is output, the second character string is marked as a decryption key;

[0048] Based on the encryption operation process, the encrypted signal is inversely operated using the decryption key to obtain the decrypted signal.

[0049] In a second aspect, the present application provides a production signal encryption transmission system based on a cryptographic hash function, comprising a signal encryption module, a hash calculation module, a signal verification module and a signal decryption module; the signal encryption module, the hash calculation module and the signal decryption module are respectively connected to the signal verification module data;

[0050] The signal encryption module is used to output the production signal, perform algorithm encryption on the production signal, and obtain an encrypted signal;

[0051] The hash calculation module is used to calculate the encrypted signal based on the cryptographic hash function to obtain an encrypted hash value;

[0052] The signal verification module is used to transmit the encrypted signal and the encrypted hash value. After the receiving end receives the encrypted signal and the encrypted hash value, the receiving end verifies the integrity of the encrypted signal based on the encrypted hash value.

[0053] The signal decryption module is used to decrypt the encrypted signal at the receiving end to obtain a decrypted signal after the verification is passed.

[0054] In a third aspect, the present application provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the above method are performed.

[0055] Beneficial effects of the present invention: The present invention generates an encryption key randomly, converts the production signal and the encryption key into an initial conversion code and an initial conversion key, obtains a coding matrix and a key matrix based on the initial conversion code and the initial conversion key, performs encryption operation on the coding matrix through the key matrix, and obtains an encrypted signal. The advantage is that the randomly generated encryption key can prevent the encryption program from being cracked due to the long-term non-replacement of the key, and the encryption operation based on the coding matrix and the key matrix can increase the complexity of the encryption process, thereby improving the security and privacy of signal encryption transmission;

[0056] The present invention calculates the encrypted signal through a cryptographic hash function to obtain a signal hash value, and then integrates the function salt and the encryption key into the signal hash value to obtain an encrypted hash value. The advantage is that the hash value cannot be reversely calculated, but can be deduced by rainbow table attacks or pre-calculation attacks, so it is necessary to make certain changes to the hash value, and the hash value is a fixed length. Integrating the function salt and the encryption key into the signal hash value can prevent others from confirming the correct encrypted hash value, thereby improving the security and effectiveness of signal encryption transmission.

[0057] The present invention sends an encrypted signal and an encrypted hash value to a receiving end, and the receiving end calculates the received encrypted signal and the encrypted hash value to obtain a decrypted hash value and a standard hash value, and determines whether the encrypted signal has been tampered with based on the decrypted hash value and the standard hash value. If the integrity verification passes, the encrypted signal is decrypted. The advantage is that the hash value can well verify the integrity of the encrypted signal, ensure that the encrypted signal is not tampered with by others, and improve the integrity and security of signal encryption transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 is a functional block diagram of the system of the present invention;

[0059] Figure 2 A schematic diagram of obtaining a first character string and a second character string according to the present invention;

[0060] Figure 3 is a flow chart of the steps of the method of the present invention;

[0061] Figure 4 A connection block diagram of the electronic device of the present invention;

[0062] In the figure: 50, electronic device; 501, processor; 502, memory. DETAILED DESCRIPTION

[0063] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0064] Example 1, please refer to Figure 1 As shown, in the first aspect, the present application provides a production signal encryption transmission system based on a cryptographic hash function, including a signal encryption module, a hash calculation module, a signal verification module and a signal decryption module; the signal encryption module, the hash calculation module and the signal decryption module are respectively connected to the signal verification module data;

[0065] The signal encryption module is used to output the production signal, perform algorithm encryption on the production signal, and obtain the encrypted signal; the signal encryption module includes an encryption matrix generation unit, an encryption matrix calculation unit, and an encryption matrix conversion unit;

[0066] The encryption matrix generation unit is configured with an encryption matrix generation strategy, and the encryption matrix generation strategy includes:

[0067] Randomly generate encryption keys;

[0068] Obtain the production signal, convert the production signal into a hexadecimal code according to the ASCII code, and name it as the initial conversion code; convert the encryption key into a hexadecimal code according to the ASCII code, and name it as the initial conversion key;

[0069] In actual applications, a random number generator is used to randomly generate an encryption key. The randomly obtained encryption key is "134679". The production signal obtained is "execute encapsulation". The initial conversion code obtained by conversion is "6267 884C 5C0188C5". The initial conversion key obtained by conversion is "31 33 34 36 37 39". Among them, the spaces are used to distinguish bytes. There are no spaces in the actual analysis process.

[0070] Number the characters in the initial conversion code, using the symbol CB n Indicates, where n is a non-zero natural number and n is the serial number of CB, the characters in the initial conversion key are numbered, and the symbol CM m It represents, where m is a non-zero natural number and m is the serial number of CM;

[0071] Get the maximum values ​​of n and m, label them as max(n) and max(m) respectively, calculate max(n) / 4, and represent the result as p, calculate max(m) / 4, and represent the result as q;

[0072] In practical applications, CB1 to CB 16 6, 2, 6, 7, 8, 8, 4, C, 5, C, 0, 1, 8, 8, C, and 5, CM1 to CM 12 They are 3, 1, 3, 3, 3, 4, 3, 6, 3, 7, 3, and 9, respectively. We get max(n)=16, max(m)=12, and calculate p=4, q=3.

[0073] Starting from n=1, follow to The initial conversion code is converted into a 2×2 coding sub-matrix in the order of , and all the coding sub-matrices are integrated and named as the coding matrix;

[0074] Starting from m=1, follow to The initial conversion code is converted into a 2×2 key sub-matrix in the order of , and all the key sub-matrices are integrated and named as the key matrix;

[0075] Perform encryption operation on the coding matrix through the key matrix to obtain an encrypted signal;

[0076] In practical applications, the converted encoding matrix includes , , as well as ; The key matrix includes , as well as .

[0077] The encryption matrix calculation unit is configured with an encryption matrix calculation strategy, which includes:

[0078] Obtain the encoding matrix and the key matrix;

[0079] The encoding sub-matrices in the encoding matrix are numbered, using the symbol X i Indicates, where i is a non-zero natural number and i is the serial number of X; the key submatrices in the key matrix are numbered, and the symbol Y j Indicates, where j is a non-zero natural number and j is the sequence number of Y;

[0080] Starting from i=1, for X i ,calculate , and mark the result as V i , where max(j) is the maximum value of j, i is increased by 1, and V is calculated repeatedly i , until all X i The calculation is completed;

[0081] In practical applications, the numbers X1 to X4 are , , as well as , Y1 to Y3 are , as well as , first calculate , the calculation result is The calculation process is hexadecimal calculation, that is, X1 to X4 are all Add them together and get V1 to V4 respectively: , , as well as ;

[0082] Starting from i=1, V i With V i+1 Swap, and continue to swap i+2 until i=max(i)+1, where max(i) is the maximum value of i;

[0083] After the replacement is completed, V i From left to right, they are labeled G t , where t is a non-zero natural number and the range of t is the same as that of i;

[0084] G t Converting into a coding format to obtain an encrypted signal;

[0085] In practical applications, swap V1 with V2, i+2=3, swap V3 with V4, max(i)=4, then add i+2 to get i=5, at this time i=max(i)+1, stop swapping, that is, swap V1 with V2 and V3 with V4, and get G1 to G4 in order , , as well as .

[0086] The encryption matrix conversion unit is configured with an encryption matrix conversion strategy. The encryption matrix generation strategy includes:

[0087] Get G t , G t The format is , where (4×t-3), (4×t-2), (4×t-1) and (4×t) are the serial numbers of A, named as element subscripts;

[0088] G t The matrix elements in are arranged in ascending order according to the element subscripts to obtain the encrypted signal;

[0089] In practical applications, the element subscripts are arranged to get 11, 14, D, 1E, F, E, F, 19, 11, 14, 15, 17, E, 18, 9, and 13. To facilitate subsequent decoding, they need to be supplemented with two-digit numbers, namely 11, 14, 0D, 1E, 0F, 0E, 0F, 19, 11, 14, 15, 17, 0E, 18, 09, and 13. The encrypted signal is 11140D1E0F0E0F19111415170E180913. In actual use, since hexadecimal calculation is used and the matrix contains only one digit, the encryption key below 20 bits is calculated after G is completed. t The matrix elements in will not have three digits, so its format is fixed to two digits, and the encryption key can be randomly 6 to 20 digits.

[0090] The hash calculation module is used to calculate the encrypted signal based on the cryptographic hash function to obtain an encrypted hash value;

[0091] The hash calculation module is configured with a hash calculation strategy, which includes:

[0092] Based on the PBKDF2 algorithm, set the function salt and number of iterations;

[0093] Get the number of bits of the encryption key, marked as the number of bits of the key;

[0094] Set the number of iterations to the number of key bits, and randomly generate a function salt with the same number of key bits;

[0095] The encrypted signal is calculated using the PBKDF2 algorithm to obtain a signal hash value;

[0096] The function salt is concatenated to the head of the signal hash value, and the encryption key is concatenated to the tail of the signal hash value to obtain the encrypted hash value. In actual use, since the PBKDF2 algorithm has two parameters, the function salt and the number of iterations, and parameter randomization can make the existing hash value deduction technology more difficult to deduce, a random encryption key and a random function salt are used each time the production signal is encrypted and transmitted. At the same time, the number of iterations is set based on the encryption key, and all parameters in the encryption process are set to random mode, which greatly improves the security of signal encryption transmission.

[0097] In practical applications, the PBKDF2 algorithm is an existing password hash function algorithm, and the function salt and the number of iterations are parameters of the PBKDF2 algorithm; the number of key bits is obtained to be 6, that is, the number of iterations is set to 6, and a 6-digit function salt is randomly generated by a random number generator, and the function salt is "158469". The encrypted signal is calculated to obtain a signal hash value of "864d26d9cac4e62c81c5c287fbd387d3". In this embodiment, the KEY length of the PBKDF2 algorithm defaults to 128 bits; the encrypted hash value obtained by splicing is "158469864d26d9cac4e62c81c5c287fbd387d3134679".

[0098] The signal verification module is used to transmit the encrypted signal and the encrypted hash value. After the receiving end receives the encrypted signal and the encrypted hash value, the integrity of the encrypted signal is verified based on the encrypted hash value. The signal verification includes a standard hash extraction unit and an integrity verification unit.

[0099] The standard hash extraction unit is configured with a standard hash extraction strategy, which includes:

[0100] transmitting the encrypted signal and the encrypted hash value to a receiving end;

[0101] See also Figure 2 As shown, after receiving the encrypted signal and the encrypted hash value, the receiving end starts from the head of the encrypted hash value and obtains characters in the encrypted hash value backward, which is named the first string; and starts from the tail of the encrypted hash value and obtains characters forward, which is named the second string;

[0102] The length of the first string and the length of the second string are always the same, and the number of characters remaining in the encrypted hash value is detected in real time, which is named as the number of remaining characters;

[0103] When the number of remaining characters is equal to the first character threshold, a hash legality signal is output;

[0104] If a hash legality signal is output, the remaining characters in the encrypted hash value are marked as standard hash values;

[0105] Performing integrity verification on encrypted signals based on standard hash values;

[0106] In actual applications, the received encrypted hash value is "158469864d26d9cac4e62c81c5c287fbd387d3134679", and the first character string and the second character string are obtained at the same time. For example, the first character string obtained in real time is "158", the second character string is "976", and the number of remaining characters is 38. Since the KEY length of the PBKDF2 algorithm in this embodiment defaults to 128 bits, the first character threshold is 32. By comparison, it is found that the number of remaining characters is not equal to the first character threshold, and the acquisition continues until the first character string is "158469" and the second character string is "976431". When the number of remaining characters is 32, which is equal to the first character threshold, a hash legality signal is output. At this time, the standard hash value is "864d26d9cac4e62c81c5c287fbd387d3".

[0107] The integrity verification unit is configured with an integrity verification strategy, which includes:

[0108] Set the first string as the function salt, obtain the number of characters in the first string, mark it as the salt number, and set the number of iterations to the salt number;

[0109] The encrypted signal is calculated using the PBKDF2 algorithm to obtain the decrypted hash value;

[0110] The decrypted hash value is compared with the standard hash value. If the decrypted hash value is the same as the standard hash value, a data integrity signal is output; if the decrypted hash value is different from the standard hash value, a data incomplete signal is output;

[0111] If the output data is an incomplete signal, reapply for the production signal;

[0112] In actual applications, the first string is "158469", that is, the function salt is "158469", the number of salts is 6, that is, the number of iterations is set to 6, and the decrypted hash value is calculated to be "864d26d9cac4e62c81c5c287fbd387d3". By comparison, the decrypted hash value is the same as the standard hash value, and a data integrity signal is output.

[0113] The signal decryption module is used to decrypt the encrypted signal at the receiving end after verification to obtain the decrypted signal;

[0114] The signal decryption module is configured with a signal decryption strategy, which includes:

[0115] If a data integrity signal is output, the second character string is marked as a decryption key;

[0116] Based on the encryption operation process, the encrypted signal is inversely operated by the decryption key to obtain the decrypted signal;

[0117] In actual applications, a data integrity signal is output, the second character string "976431" is marked as the decryption key and the encrypted signal is decrypted. Since the decryption process is the inverse operation of the encryption process, it will not be specifically demonstrated in this embodiment. The decrypted signal obtained by decryption is "execution encapsulation".

[0118] Example 2, please refer to Figure 3 As shown, in a second aspect, the present application provides a production signal encryption transmission method based on a cryptographic hash function, comprising the following steps:

[0119] Step S1, outputting a production signal, encrypting the production signal by an algorithm, and obtaining an encrypted signal; Step S1 includes the following sub-steps:

[0120] Step S101, randomly generate an encryption key;

[0121] Step S102, obtaining a production signal, converting the production signal into a hexadecimal code according to bytes based on the ASCII code, named as an initial conversion code, and converting an encryption key into a hexadecimal code according to bytes based on the ASCII code, named as an initial conversion key;

[0122] Step S103: number the characters in the initial conversion code, using the symbol CB n Indicates, where n is a non-zero natural number and n is the serial number of CB, the characters in the initial conversion key are numbered, and the symbol CM m It represents, where m is a non-zero natural number and m is the serial number of CM;

[0123] Step S104, obtaining the maximum values ​​of n and m, marked as max(n) and max(m) respectively, calculating max(n) / 4, and representing the calculation result as p, and calculating max(m) / 4, and representing the calculation result as q;

[0124] Step S105, starting from n=1, follow to The initial conversion code is converted into a 2×2 coding sub-matrix in the order of , and all the coding sub-matrices are integrated and named as the coding matrix;

[0125] Step S106, starting from m=1, follow to The initial conversion code is converted into a 2×2 key sub-matrix in the order of , and all the key sub-matrices are integrated and named as the key matrix;

[0126] Step S107, performing encryption operation on the encoding matrix through the key matrix to obtain an encrypted signal;

[0127] Step S107 includes the following sub-steps:

[0128] Step S107.1, obtaining a coding matrix and a key matrix;

[0129] Step S107.2: number the coding sub-matrices in the coding matrix, using the symbol X i Indicates, where i is a non-zero natural number and i is the serial number of X; the key submatrices in the key matrix are numbered, and the symbol Y j Indicates, where j is a non-zero natural number and j is the sequence number of Y;

[0130] Step S107.3, starting from i=1, for X i ,calculate , and mark the result as V i , where max(j) is the maximum value of j, i is increased by 1, and V is calculated repeatedly i , until all X i The calculation is completed;

[0131] Step S107.4, starting from i=1, set V i With V i+1 Swap, and continue to swap i+2 until i=max(i)+1, where max(i) is the maximum value of i;

[0132] Step S107.5, after the replacement, V i From left to right, they are labeled G t , where t is a non-zero natural number and the range of t is the same as that of i;

[0133] Step S107.6, G t Converting into a coding format to obtain an encrypted signal;

[0134] Step S107.6 includes the following sub-steps:

[0135] Step S107.6.a, obtain G t , G t The format is , where (4×t-3), (4×t-2), (4×t-1) and (4×t) are the serial numbers of A, named as element subscripts;

[0136] Step S107.6.b, G t The matrix elements in are arranged in ascending order according to the element subscripts to obtain the encrypted signal;

[0137] Step S2, calculating the encrypted signal based on the cryptographic hash function to obtain an encrypted hash value; Step S2 includes the following sub-steps:

[0138] Step S201, based on the PBKDF2 algorithm, set the function salt and the number of iterations;

[0139] Step S202, obtaining the number of bits of the encryption key, marked as the number of bits of the key;

[0140] Step S203, setting the number of iterations to the number of key bits, and randomly generating a function salt of the number of key bits;

[0141] Step S204, calculating the encrypted signal using the PBKDF2 algorithm to obtain a signal hash value;

[0142] Step S205, concatenating the function salt to the head of the signal hash value, and concatenating the encryption key to the tail of the signal hash value, to obtain an encrypted hash value;

[0143] Step S3, transmitting the encrypted signal and the encrypted hash value, after the receiving end receives the encrypted signal and the encrypted hash value, the receiving end verifies the integrity of the encrypted signal based on the encrypted hash value; Step S3 includes the following sub-steps:

[0144] Step S301, transmitting the encrypted signal and the encrypted hash value to the receiving end;

[0145] Step S302: After receiving the encrypted signal and the encrypted hash value, the receiving end obtains characters in the encrypted hash value starting from the head of the encrypted hash value and named as the first character string; and obtains characters starting from the tail of the encrypted hash value and named as the second character string;

[0146] Step S303, the length of the first character string is always consistent with the length of the second character string, and the number of characters remaining in the encrypted hash value is detected in real time, which is named as the number of remaining characters;

[0147] Step S304, when the number of remaining characters is equal to the first character threshold, outputting a hash legality signal;

[0148] Step S305, if a hash legality signal is output, the remaining characters in the encrypted hash value are marked as standard hash values;

[0149] Step S306, verifying the integrity of the encrypted signal based on the standard hash value;

[0150] Step S306 includes the following sub-steps:

[0151] Step S306.1, set the first string as the function salt, obtain the number of characters in the first string, mark it as the salt number, and set the number of iterations as the salt number;

[0152] Step S306.2, calculating the encrypted signal using the PBKDF2 algorithm to obtain a decrypted hash value;

[0153] Step S306.3, compare the decrypted hash value with the standard hash value, if the decrypted hash value is the same as the standard hash value, then output a data complete signal; if the decrypted hash value is different from the standard hash value, then output a data incomplete signal;

[0154] Step S306.4, if the output data is an incomplete signal, reapply for a production signal;

[0155] Step S4: after the verification is passed, the receiving end decrypts the encrypted signal to obtain a decrypted signal; Step S4 includes the following sub-steps:

[0156] Step S401, if a data complete signal is output, the second character string is marked as a decryption key;

[0157] Step S402: Based on the encryption operation process, the encrypted signal is inversely operated using a decryption key to obtain a decrypted signal.

[0158] Example 3, please refer to Figure 4 As shown, in the third aspect, the present application provides an electronic device, including a processor 501 and a memory 502, the memory 502 stores computer-readable instructions, and when the computer-readable instructions are executed by the processor 501, the steps in the above method are executed. Through the above technical solution, the processor 501 and the memory 502 are interconnected and communicate with each other through a communication bus and / or other forms of connection mechanisms (not shown), and the memory 502 stores a computer program executable by the processor 501. When the electronic device 50 is running, the processor 501 executes the computer program to execute the method in any optional implementation of the above embodiment to achieve the following functions: output a production signal, encrypt the production signal by algorithm, and obtain an encrypted signal; calculate the encrypted signal based on a cryptographic hash function to obtain an encrypted hash value; transmit the encrypted signal and the encrypted hash value, and after the receiving end receives the encrypted signal and the encrypted hash value, the encrypted signal is verified for integrity based on the encrypted hash value; after the verification is passed, the receiving end decrypts the encrypted signal to obtain a decrypted signal.

[0159] Embodiment 4, in the fourth aspect, the present application provides a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above method are executed. Through the above technical solution, when the computer program is executed by the processor, the method in any optional implementation of the above embodiment is executed to achieve the following functions: output a production signal, encrypt the production signal by an algorithm, and obtain an encrypted signal; calculate the encrypted signal based on a cryptographic hash function to obtain an encrypted hash value; transmit the encrypted signal and the encrypted hash value, and after the receiving end receives the encrypted signal and the encrypted hash value, the receiving end verifies the integrity of the encrypted signal based on the encrypted hash value; after the verification is passed, the receiving end decrypts the encrypted signal to obtain a decrypted signal.

[0160] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0161] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program codes. Among them, the storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0162] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

Claims

1. A method for encrypting and transmitting production signals based on a cryptographic hash function, characterized in that: The steps include: Output the production signal, perform algorithm encryption on the production signal, and obtain an encrypted signal; Calculating the encrypted signal based on the cryptographic hash function to obtain an encrypted hash value; The encrypted signal and the encrypted hash value are transmitted, and after the receiving end receives the encrypted signal and the encrypted hash value, the receiving end verifies the integrity of the encrypted signal based on the encrypted hash value; After verification, the receiving end decrypts the encrypted signal to obtain the decrypted signal; Outputting the production signal, encrypting the production signal with an algorithm, and obtaining the encrypted signal includes the following sub-steps: Randomly generate encryption keys; Obtain the production signal, convert the production signal into a hexadecimal code according to the ASCII code, and name it as the initial conversion code; convert the encryption key into a hexadecimal code according to the ASCII code, and name it as the initial conversion key; Number the characters in the initial conversion code, using the symbol CB n Indicates, where n is a non-zero natural number and n is the serial number of CB, the characters in the initial conversion key are numbered, and the symbol CM m It represents, where m is a non-zero natural number and m is the serial number of CM; Get the maximum values ​​of n and m, label them as max(n) and max(m) respectively, calculate max(n) / 4, and represent the result as p, calculate max(m) / 4, and represent the result as q; Starting from n=1, follow to The initial conversion code is converted into a 2×2 coding sub-matrix in the order of , and all the coding sub-matrices are integrated and named as the coding matrix; Starting from m=1, follow to The initial conversion code is converted into a 2×2 key sub-matrix in the order of , and all the key sub-matrices are integrated and named as the key matrix; Perform encryption operation on the coding matrix through the key matrix to obtain an encrypted signal; Calculating the encrypted signal based on the cryptographic hash function to obtain the encrypted hash value includes the following sub-steps: Based on the PBKDF2 algorithm, set the function salt and number of iterations; Get the number of bits of the encryption key, marked as the number of bits of the key; Set the number of iterations to the number of key bits, and randomly generate a function salt with the same number of key bits; The encrypted signal is calculated using the PBKDF2 algorithm to obtain a signal hash value; The function salt is concatenated to the head of the signal hash value, and the encryption key is concatenated to the tail of the signal hash value to obtain an encrypted hash value; The encrypted signal and the encrypted hash value are transmitted. After the receiving end receives the encrypted signal and the encrypted hash value, the integrity verification of the encrypted signal based on the encrypted hash value includes the following sub-steps: transmitting the encrypted signal and the encrypted hash value to a receiving end; After receiving the encrypted signal and the encrypted hash value, the receiving end starts from the head of the encrypted hash value and obtains characters in the encrypted hash value backward, which is named as the first string; and starts from the tail of the encrypted hash value and obtains characters forward, which is named as the second string; The length of the first string and the length of the second string are always the same, and the number of characters remaining in the encrypted hash value is detected in real time, which is named as the number of remaining characters; When the number of remaining characters is equal to the first character threshold, a hash legality signal is output; If a hash legality signal is output, the remaining characters in the encrypted hash value are marked as standard hash values; Performing integrity verification on encrypted signals based on standard hash values; The integrity verification of the encrypted signal based on the standard hash value includes the following sub-steps: Set the first string as the function salt, obtain the number of characters in the first string, mark it as the salt number, and set the number of iterations to the salt number; The encrypted signal is calculated using the PBKDF2 algorithm to obtain the decrypted hash value; The decrypted hash value is compared with the standard hash value. If the decrypted hash value is the same as the standard hash value, a data integrity signal is output; If the decrypted hash value is different from the standard hash value, a data incomplete signal is output; If the output data is an incomplete signal, reapply for the production signal; After verification, the receiving end decrypts the encrypted signal, and obtaining the decrypted signal includes the following sub-steps: If a data integrity signal is output, the second character string is marked as a decryption key; Based on the encryption operation process, the encrypted signal is inversely operated using the decryption key to obtain the decrypted signal.

2. The method for encrypting and transmitting production signals based on cryptographic hash functions according to claim 1 is characterized in that: The encryption operation of the encoding matrix by the key matrix includes the following sub-steps: Obtain the encoding matrix and the key matrix; The encoding sub-matrices in the encoding matrix are numbered, using the symbol X i represents, where i is a non-zero natural number and i is the sequence number of X; The key submatrices in the key matrix are numbered and represented by Y j Indicates, where j is a non-zero natural number and j is the sequence number of Y; Starting from i=1, for X i ,calculate , and mark the result as V i , where max(j) is the maximum value of j, i is increased by 1, and V is calculated repeatedly i , until all X i The calculation is completed; Starting from i=1, V i With V i+1 Swap, and continue to swap i+2 until i=max(i)+1, where max(i) is the maximum value of i; After the replacement is completed, V i From left to right, they are labeled G t , where t is a non-zero natural number and the range of t is the same as that of i; G t Convert to a coded format to obtain an encrypted signal.

3. The method for encrypting and transmitting production signals based on cryptographic hash functions according to claim 2 is characterized in that: G t The conversion into the encoding format to obtain the encrypted signal includes the following sub-steps: Get G t , the G t The format is , where (4×t-3), (4×t-2), (4×t-1) and (4×t) are the serial numbers of A, named as element subscripts; G t The matrix elements in are arranged in ascending order according to the element subscript to obtain the encrypted signal.

4. A production signal encryption transmission system based on a cryptographic hash function, applicable to the production signal encryption transmission method based on a cryptographic hash function according to any one of claims 1 to 3, characterized in that: It includes a signal encryption module, a hash calculation module, a signal verification module and a signal decryption module; the signal encryption module, the hash calculation module and the signal decryption module are respectively connected to the signal verification module; The signal encryption module is used to output the production signal, perform algorithm encryption on the production signal, and obtain an encrypted signal; The hash calculation module is used to calculate the encrypted signal based on the cryptographic hash function to obtain an encrypted hash value; The signal verification module is used to transmit the encrypted signal and the encrypted hash value. After the receiving end receives the encrypted signal and the encrypted hash value, the receiving end verifies the integrity of the encrypted signal based on the encrypted hash value. The signal decryption module is used to decrypt the encrypted signal at the receiving end to obtain a decrypted signal after the verification is passed.

5. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are performed.