Data transmission encryption method and device, electronic equipment and storage medium
By encrypting different fields in the initial request sent by the front-end server to the back-end server in different encryption methods, the data insecurity caused by key leakage under a single encryption method is solved, and the security of data transmission and network communication is improved.
Patent Information
- Application Number
- CN202411868478.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-03-21
AI Technical Summary
After encrypting data transmission with a single encryption method in the prior art, if the key is leaked, all data encrypted with the key will no longer be secure, resulting in a decrease in the security of data transmission encryption and affecting the security of network communication.
By intercepting the initial request sent by the front-end server to the back-end server, the encryption method of each field is determined according to the field types of multiple fields in the request and the corresponding encryption method, and encrypting it, a first encryption request is generated, and sent to the back-end server.
By encrypting different fields in the initial request in different encryption methods, there are multiple encryption methods in the generated encryption request, which avoids the insecure data after key leakage, improves the security of data transmission encryption, and thus improves the security of network communication.
Smart Images

Figure CN119675963A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network security technology, and in particular to a data transmission encryption method, device, electronic device and storage medium. Background Art
[0002] In modern network communications, the security of data transmission is one of the key issues in the communication process. Therefore, the security of data transmission between the front end and the back end has received widespread attention.
[0003] At present, data transmission between the front-end and back-end usually adopts a fixed encryption scheme, for example, the front-end and back-end uniformly adopt a symmetric encryption algorithm (Advanced Encryption Standard, AES) encryption or an asymmetric encryption algorithm (Rivest-Shamir-Adleman, RSA) encryption.
[0004] However, after using a single encryption method to encrypt data transmission, if the key is leaked during transmission, all data encrypted using the key will no longer be secure, reducing the security of data transmission encryption and further affecting the security of network communications. Summary of the invention
[0005] The present application provides a data transmission encryption method, device, electronic device and storage medium to solve the problem in the prior art that after using a single encryption method to encrypt data transmission, if the key is leaked during transmission, all data encrypted using the key will no longer be safe, which reduces the security of data transmission encryption and further affects the security of network communications.
[0006] In a first aspect, the present application provides a data transmission encryption method, the method comprising:
[0007] Intercept the initial request sent by the front-end server to the back-end server;
[0008] Determine, according to field types of multiple fields in the initial request and encryption methods corresponding to the field types, an encryption method corresponding to each of the fields in the initial request;
[0009] Encrypting multiple fields in the initial request according to the encryption method corresponding to each field to obtain a first encrypted request;
[0010] The first encryption request is sent to the backend server.
[0011] In a second aspect, the present application provides a data transmission encryption device, the device comprising:
[0012] An interception module, used to intercept the initial request sent by the front-end server to the back-end server;
[0013] A mode determination module, used to determine the encryption mode corresponding to each field in the initial request according to the field types of the multiple fields in the initial request and the encryption modes corresponding to the field types;
[0014] An encryption module, used for encrypting multiple fields in the initial request according to an encryption method corresponding to each field, to obtain a first encrypted request;
[0015] A sending module is used to send the first encryption request to the back-end server.
[0016] In a third aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the data transmission encryption method as described in any embodiment of the present application is implemented.
[0017] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the data transmission encryption method as described in any embodiment of the present application.
[0018] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the data transmission encryption method as described in any embodiment of the present application.
[0019] The solution of the present application intercepts the initial request sent by the front-end server to the back-end server; determines the encryption method corresponding to each field in the initial request according to the field types of multiple fields in the initial request and the encryption method corresponding to the field type; encrypts multiple fields in the initial request according to the encryption method corresponding to each field to obtain a first encryption request; and sends the first encryption request to the back-end server. That is, the solution of the present application encrypts different fields in the initial request using different encryption methods, so that there are multiple encryption methods in the obtained encryption request, avoiding the situation that if the key is leaked during data transmission, all data encrypted using the key will no longer be safe, thereby improving the security of data transmission encryption and thus improving the security of network communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 It is a flowchart of the data transmission encryption method provided by this application;
[0022] Figure 2 This is another flowchart of the data transmission encryption method provided by this application;
[0023] Figure 3 It is a structural schematic diagram of a data transmission encryption device provided by the present application;
[0024] Figure 4 It is a structural schematic diagram of the electronic device provided by this application. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0026] Figure 1 This is a flow chart of the data transmission encryption method provided by the present application. The method can be executed by a data transmission encryption device, which can be implemented in software and / or hardware. In a specific embodiment, the device can be applied to an electronic device, which can be a computer, and the electronic device is connected to a front-end server and a back-end server respectively. Alternatively, the electronic device is connected to a client and a server respectively. The following embodiments will be described by taking the application of the device in an electronic device as an example, referring to Figure 1 , the method may specifically include the following steps:
[0027] Step 101, intercepting the initial request sent by the front-end server to the back-end server.
[0028] Specifically, when the front-end server needs to interact with the back-end server, it needs to send a request to the back-end server. At this time, the initial request sent by the front-end server to the back-end server is intercepted. The interception method can be to intercept the initial request through the interceptor provided by axios. Axios is a request library based on the promise network, which can be used in node.js and browsers. Therefore, the interceptor provided by axios can intercept the initial request sent by the front-end server to the back-end server.
[0029] For example, the implementation method of intercepting network requests using the interceptor provided by axios is to call the interceptor to intercept the request and call config for encryption. The code implementation process is to first introduce the third-party network request library axios, the code is import axios from'axios'; then introduce the custom encapsulated encryption and decryption processor, the code is import{handleRequestCrypto, handleResponseCrypto}from'network'; then put the custom encryption processor into the request interceptor, intercept and encrypt the data sent by the front-end server or client to the back-end server, the code is axios.interceptors.request.use(function(config){const encrypted=handleRequestCrypto(config); return encrypted;}).
[0030] Step 102: Determine the encryption method corresponding to each field in the initial request according to the field types of multiple fields in the initial request and the encryption methods corresponding to the field types.
[0031] Specifically, the initial request includes multiple fields, such as multiple string type fields and multiple object type fields in the initial request, wherein the multiple objects may also include multiple type attribute objects and multiple name attribute objects. An encryption method corresponding to the field type is preset, such as the encryption method corresponding to the string type is the AES encryption method, the encryption method corresponding to the object type of the type attribute is the RSA encryption method, and the encryption method corresponding to the object type of the name attribute is the AES encryption method. According to the field types of the multiple fields in the initial request and the encryption method corresponding to each field type, the encryption method corresponding to each field in the initial request is determined.
[0032] Exemplarily, the field type of field A is a string type, and the encryption method corresponding to the string type is an AES encryption method, so it is determined that the encryption method corresponding to field A is an AES encryption method.
[0033] Step 103: encrypt multiple fields in the initial request according to the encryption method corresponding to each field to obtain a first encrypted request.
[0034] Specifically, after determining the encryption method corresponding to each field in the initial request, each field is encrypted according to the encryption method corresponding to each field, and the request obtained after encryption is the first encrypted request. The config.crypto field is used to declare the encryption and decryption configuration used in requests and responses. This field can configure the encryption or decryption of the entire request body and response body, or the encryption or decryption of a single request field or response field. According to the encryption method corresponding to each field, each field can be encrypted by configuring the encryption of each field through the config.crypto field.
[0035] For example, the method for implementing the encryption of each field through the config.crypto field is to call the crypto field of config to configure the encryption method of the field type of the field. For example, the encryption method corresponding to parameter A is AES encryption method, and the code for encrypting parameter A of type type is crypto:{type:'aes',fields:{req:['paramsA']}}. That is, the request parameter paramsA is encrypted using the AES encryption method.
[0036] Optionally, after step 103 , step 31 may also be performed.
[0037] Step 31: perform secondary encryption on the first encryption request according to the file type of the first encryption request to obtain a second encryption request.
[0038] Specifically, according to the file type of the first encryption request, the encryption method of the first encryption request is determined, and the first encryption request is re-encrypted according to the encryption method, and the re-encrypted file is the re-encrypted request. According to the file type of the first encryption request, determining the encryption method of the first encryption request may be to obtain a pre-set encryption method corresponding to the file type.
[0039] Optionally, step 31 may be implemented through steps 311 to 312 .
[0040] Step 311: Determine the encryption method corresponding to the first encryption request according to the file type of the first encryption request and the encryption method corresponding to the file type.
[0041] Specifically, there may be multiple file types in the first encryption request, and there is a preset encryption method corresponding to each file type. For example, the encryption method for the file type is RSA encryption method. According to the file type of the first encryption request and the encryption method corresponding to the file type, the encryption method corresponding to the first encryption request can be determined.
[0042] Step 312: perform secondary encryption on the first encryption request according to the encryption method corresponding to the first encryption request to obtain a second encryption request.
[0043] Specifically, after determining the encryption method corresponding to the first encryption request, the first encryption request is encrypted twice according to the encryption method corresponding to the first encryption request, and the request obtained after the second encryption is the second encryption request. The config.crypto field can be configured to encrypt or decrypt the entire request body and response body. Therefore, according to the encryption method corresponding to the first encryption request, the second encryption of the first encryption request can be configured through the crypto field.
[0044] For example, all files of the file type are encrypted using AES encryption, and the configuration method is crypto:{type:'aes',fields:{req:['file']}}, that is, AES encryption is used for the file file.
[0045] Step 104: Send the first encryption request to the backend server.
[0046] Specifically, after obtaining the first encrypted request, the first encrypted request is sent to the back-end server, so that the back-end server decrypts and processes the request and returns a response.
[0047] Optionally, after executing step 31 , step 104 may be implemented through step 1041 .
[0048] Step 1041, sending the second encryption request to the backend server.
[0049] Specifically, after obtaining the second encrypted request, the second encrypted request is sent to the back-end server, so that the back-end server decrypts and processes the request and returns a response.
[0050] The solution of the present application intercepts the initial request sent by the front-end server to the back-end server; determines the encryption method corresponding to each field in the initial request according to the field types of multiple fields in the initial request and the encryption method corresponding to the field type; encrypts multiple fields in the initial request according to the encryption method corresponding to each field to obtain a first encryption request; and sends the first encryption request to the back-end server. That is, the solution of the present application encrypts different fields in the initial request using different encryption methods, so that there are multiple encryption methods in the obtained encryption request, avoiding the situation that if the key is leaked during data transmission, all data encrypted using the key will no longer be safe, thereby improving the security of data transmission encryption and thus improving the security of network communication.
[0051] Figure 2is another flow chart of the data transmission encryption method provided by the present application. Figure 1 Based on the illustrated embodiment and various optional implementation schemes, the process of intercepting the response returned by the backend server is described in detail. Figure 2 As shown, the method may include the following steps:
[0052] Step 201, intercepting an initial request sent by a front-end server to a back-end server.
[0053] Exemplarily, the interceptor provided by axios is used to intercept network requests, and the implementation method for encrypting the intercepted initial request can be to call the interceptor to intercept the request and call config for encryption. The code implementation process is to introduce the third-party network request library axios, the code is import axios from'axios', and then introduce the custom encapsulated encryption and decryption processor, the code is import{handleRequestCrypto, handleResponseCrypto}from'network'; then put the custom encryption processor into the request interceptor, intercept and encrypt the data sent by the front-end server or client to the back-end server, the code is axios.interceptors.request.use(function(config){constencrypted=handleRequestCrypto(config); return encrypted;}), which means calling the request interceptor and encrypting the request file according to config.
[0054] Step 202: Determine the encryption method corresponding to each field in the initial request according to the field types of multiple fields in the initial request and the encryption methods corresponding to the field types.
[0055] Step 203: encrypt multiple fields in the initial request according to the encryption method corresponding to each field to obtain a first encrypted request.
[0056] Step 204: Send the first encryption request to the backend server.
[0057] Step 205: intercepting the initial encrypted response returned by the back-end server to the front-end server.
[0058] Specifically, after receiving the encryption request, the back-end server decrypts the encryption request according to the encryption method agreed in advance with the electronic device that executes the encryption method of this embodiment, and obtains the initial request. The back-end server responds to the initial request, and encrypts the response according to the encryption method agreed between the electronic device that executes the encryption method of this embodiment, and obtains the initial encrypted response. After generating the initial encrypted response, the back-end server returns the initial encrypted response to the front-end server. At this time, the initial encrypted response returned by the back-end server to the front-end server is intercepted. The interception method can be to intercept the initial encrypted response by the interceptor provided by axios. Axios is a request library based on a promise network, which can act on node.js and browsers, so the interceptor provided by axios can intercept the initial encrypted response returned by the back-end server to the front-end server.
[0059] Exemplarily, the implementation method of intercepting the initial encrypted response using the interceptor provided by axios is to call the interceptor to intercept the initial encrypted response and call config to decrypt the response. The code implementation process is to introduce the third-party network request library axios, the code is import axios from'axios', and then introduce the custom encapsulated encryption and decryption processor, the code is import{handleRequestCrypto, handleResponseCrypto}from'network', and then put the custom encryption processor into the request interceptor to intercept and encrypt the data sent by the front-end server or client to the back-end server, the code is axios.interceptors.request.use(function(config){constencrypted=handleRequestCrypto(config);return encrypted;},function(error){return Promise.reject(error);}), and then put the custom decryption processor into the response interceptor to intercept and decrypt the encrypted data returned by the back-end server to the front-end server or client, the code is axios.interceptors.response.use(function(response){const decrypted = handleResponseCrypto(response); return decrypted;}), which means calling the request response interceptor to use response.config to decrypt the response data.
[0060] Step 206: decrypt the initial encrypted response according to the data type of the initial encrypted response to obtain a first decrypted response.
[0061] Specifically, according to the data type of the initial encrypted response, the decryption method of the initial encrypted response is determined, and the initial encrypted response is decrypted according to the decryption method, and the decrypted data is the first decrypted response. According to the data type of the initial encrypted response, determining the decryption method of the initial encrypted response can be to obtain a pre-set decryption method corresponding to the data type. For example, the decryption method of the initial encrypted response and the encryption method of the first encrypted request can both be uniformly set through the crypto.type field, which is used to indicate the encryption method of the entire request file and the decryption method of the entire response data.
[0062] Optionally, the encryption method corresponding to the file type includes encryption using a symmetric encryption algorithm and encryption using an asymmetric encryption algorithm. The decryption method corresponding to the data type includes decryption using a symmetric encryption algorithm and decryption using an asymmetric encryption algorithm.
[0063] Specifically, the encryption methods corresponding to the file type include AES encryption and RSA encryption. The decryption methods corresponding to the data type include AES decryption and RSA decryption. The encryption method and the decryption method may be the same or different.
[0064] Exemplarily, in the method of setting the encryption and decryption type used for the entire request file and response data through the crypto.type field, the value of the type field can be set as follows: aes means that both the request file and the response data are encrypted and decrypted using AES. rsa means that both the request file and the response data are encrypted and decrypted using RSA. aesrsa means that the request file is encrypted using AES, and the response data is decrypted using RSA. rsaes means that the request file is encrypted using RSA, and the response data is decrypted using AES. aesno means that the request file is encrypted using AES, and the response data is not decrypted. rsano means that the request file is encrypted using RSA, and the response data is not decrypted. noaes means that the request file is not encrypted, and the response data is decrypted using AES. norsa means that the request file is not encrypted, and the response data is decrypted using RSA. The crypto.type field is used to set the encryption and decryption type used for the entire request file and response data. The field structure is set by calling the type field and the fields field. The implementation code is: {type:'aes'|'rsa'|'aesrsa'|'rsaes'|'aesno'|'rsano'|'noaes'|'norsa',fields:{req:Array<String|Object> ,res:Array<String|Object> The code for encrypting the request file using AES and decrypting the response data using RSA is: crypto:{type:'aesrsa'}.
[0065] Optionally, step 206 may be implemented through steps 61 and 62 .
[0066] Step 61, determining a decryption method corresponding to the initial encrypted response according to the data type of the initial encrypted response and the decryption method corresponding to the data type.
[0067] Specifically, there may be multiple data types in the initial encrypted response, and a decryption method corresponding to each data type is preset. For example, the decryption method for the file data type is the RSA decryption method. According to the data type of the initial encrypted response and the decryption method corresponding to the data type, the decryption method corresponding to the initial encrypted response can be determined.
[0068] Step 62: decrypt the initial encrypted response according to the decryption method corresponding to the initial encrypted response to obtain a first decrypted response.
[0069] Specifically, after determining the decryption method corresponding to the initial encrypted response, the initial encrypted response is decrypted according to the decryption method corresponding to the initial encrypted response, and the response obtained after decryption is the first decrypted response. The config.crypto field can configure the encryption or decryption of the entire request body and response body. Therefore, according to the decryption method corresponding to the initial encrypted response, the decryption of the initial encrypted response can be configured through the crypto field.
[0070] Exemplarily, the data whose response type is file type is decrypted by AES decryption, and the configuration method is crypto:{type:'aes',fields:{res:['file']}}, that is, AES is used to decrypt the data file.
[0071] Step 207: Determine the decryption method corresponding to each field in the first decryption response according to the field types of the multiple fields in the first decryption response and the decryption methods corresponding to the field types.
[0072] Specifically, the first decryption response includes multiple fields, such as multiple string type fields and multiple object type fields in the first decryption response, wherein the multiple objects may also include multiple type attribute objects and multiple name attribute objects. A decryption method corresponding to the field type is preset, for example, the decryption method corresponding to the string type is the AES decryption method, the decryption method corresponding to the object type of the type attribute is the RSA decryption method, and the decryption method corresponding to the object type of the name attribute is the AES decryption method. According to the field types of the multiple fields in the first decryption response and the decryption method corresponding to each field type, the decryption method corresponding to each field in the first decryption response is determined. For example, the crypto.fields field is used to set the encryption and decryption methods for the fields in the request file or the fields in the response data. The fields field is used to perform separate encryption and decryption on the fields in the request file or the fields in the response data. The field types supported by the fields field include strings and objects.
[0073] Exemplarily, the field type of field A is a string type, and the decryption method corresponding to the string type is an AES decryption method, so it is determined that the decryption method corresponding to field A is the AES decryption method.
[0074] Optionally, the field type includes a string type and an object type.
[0075] Specifically, the field types include string types and object types, and the object types include type object types and name field types.
[0076] For example, for the field parameter A (paramsA) of string type, use crypto.type to declare the encryption method. The implementation code is: crypto:{type:'aes',fields:{req:['paramsA']}}, which means to use AES to encrypt the request field 'paramsA'. For the field parameter B (paramsB) of object type, use RSA to encrypt, overwriting the encryption method declared by crypto.type. The implementation code is: crypto:{type:'aes',fields:{req:[{name:'paramsB',type:'rsa'}]}}, which means that parameter B is encrypted using RSA, and other parameters in the request are encrypted using AES.
[0077] Step 208: decrypt multiple fields in the first decryption response according to the decryption method corresponding to each field, obtain response data, and send the response data to the front-end server.
[0078] Specifically, after determining the decryption method corresponding to each field in the first decryption response, each field is decrypted according to the decryption method corresponding to each field, and the response obtained after decryption is the response data. According to the decryption method corresponding to each field, the decryption method of each field can be configured through the fields field of the config.crypto field. After obtaining the response data, the response data is returned to the front-end server so that the front-end server can obtain the response data corresponding to the initial request.
[0079] Exemplarily, the implementation method of configuring the decryption method of each field through the config.crypto field is to call the crypto field of config to configure the decryption method of the field type of the field. For example, the decryption method corresponding to field A is the AES decryption method, and the code for decrypting field A of type type is crypto:{type:'aes',fields:{res:['fieldA']}}. That is, the response field fieldA is decrypted using the AES decryption method. When the decryption method corresponding to field B is the RSA decryption method and the decryption method of other fields is the AES decryption method, the implementation code for decryption is: crypto:{type:'aes',fields:{res:[{name:'fieldB',type:'rsa'}]}}, which means that field B is decrypted using the RSA decryption method, and other fields are decrypted using the AES decryption method.
[0080] Exemplarily, when crypto.type and crypto.fields are configured at the same time, double-layer encryption can be implemented, that is, the entire request file and response data are encrypted and decrypted, and a single parameter or field is encrypted and decrypted. After encrypting or decrypting the field, the implementation code for encrypting or decrypting the request file is: crypto:{type:'aes',fields:{req:['paramsA',{name:'paramsB',type:'rsa'}],res:['fieldA',{name:'fieldB',type:'rsa'}]}}, which means that parameter B in the request file is encrypted using RSA, other parameters and the request file are encrypted using AES, field B in the response data is decrypted using RSA, and other parameters and the response data are decrypted using AES.
[0081] Exemplarily, the implementation code for encryption and decryption configuration using the above configuration method on the front-end server through the xxx Application Programming Interface (API) is: exportfunction someRequest(data){return request({url:' / api / xxx',crypto:{type:'aesrsa',fields:{req:['paramsA',{name:'paramsB',type:'rsa'},{name:'file',type:'asr',file:true}],res:['fieldA',{name:'fieldB',type:'aes'}],}},data});}, which means that when the front-end server sends a request to the back-end server through the xxxAPI, the request is intercepted, and the parameter A in the request is encrypted by AES, and the parameter B in the request is encrypted by RSA to obtain a first encrypted request, and then the file of the first encrypted request is encrypted by AES to obtain a second encrypted request. When the back-end server returns an encrypted response to the front-end server through xxxAPI, the encrypted response is intercepted and RSA decrypted. Then, field B in the first decrypted response obtained after RSA decryption is AES decrypted, and field A in the response is RSA decrypted to obtain the response data.
[0082] The solution of the present application performs a first decryption on the encrypted response returned by the back-end server, and then decrypts different fields in the decrypted data using corresponding decryption methods, so that the response data corresponds to the encryption method in the aforementioned embodiment, further avoiding the situation where if the key is leaked during data transmission, all data encrypted using the key will no longer be safe, further improving the security of data transmission, thereby improving the security of network communications.
[0083] Figure 3 is a structural diagram of a data transmission encryption device provided by the present application, and the device is suitable for executing the data transmission encryption method provided by the present application. Figure 3 As shown, the device may specifically include:
[0084] The interception module 301 is used to intercept the initial request sent by the front-end server to the back-end server.
[0085] The method determination module 302 is used to determine the encryption method corresponding to each field in the initial request according to the field types of multiple fields in the initial request and the encryption methods corresponding to the field types.
[0086] The encryption module 303 is used to encrypt multiple fields in the initial request according to the encryption method corresponding to each field to obtain a first encrypted request.
[0087] The sending module 304 is used to send the first encryption request to the backend server.
[0088] In one embodiment, the encryption module 303 is also used to: encrypt multiple fields in the initial request according to the encryption method corresponding to each of the fields, and after obtaining the first encryption request, perform secondary encryption on the first encryption request according to the file type of the first encryption request to obtain a second encryption request; the sending module 304 is specifically used to: send the second encryption request to the back-end server.
[0089] In one embodiment, the encryption module 303 performs a secondary encryption on the first encryption request according to the file type of the first encryption request to obtain a second encryption request, and is specifically used to: determine the encryption method corresponding to the first encryption request according to the file type of the first encryption request and the encryption method corresponding to the file type; and perform a secondary encryption on the first encryption request according to the encryption method corresponding to the first encryption request to obtain a second encryption request.
[0090] In one embodiment, the device also includes: a response interception module, used to intercept the initial encrypted response returned by the back-end server to the front-end server; a first decryption module, used to decrypt the initial encrypted response according to the data type of the initial encrypted response to obtain a first decrypted response; a decryption confirmation module, used to determine the decryption method corresponding to each field in the first decrypted response according to the field type of multiple fields in the first decrypted response and the decryption method corresponding to the field type; a second decryption module, used to decrypt multiple fields in the first decrypted response according to the decryption method corresponding to each field, obtain response data, and send the response data to the front-end server.
[0091] In one embodiment, the first decryption module is specifically used to: determine the decryption method corresponding to the initial encryption response based on the data type of the initial encryption response and the decryption method corresponding to the data type; decrypt the initial encryption response according to the decryption method corresponding to the initial encryption response to obtain a first decrypted response.
[0092] In one embodiment, the field type of the mode determination module 302 includes a string type and an object type.
[0093] In one embodiment, the encryption method corresponding to the file type in the encryption module 303 includes symmetric encryption algorithm encryption and asymmetric encryption algorithm encryption; the decryption method corresponding to the data type in the first decryption module includes symmetric encryption algorithm decryption and asymmetric encryption algorithm decryption.
[0094] The device of the present application intercepts the initial request sent by the front-end server to the back-end server; determines the encryption method corresponding to each field in the initial request according to the field types of multiple fields in the initial request and the encryption method corresponding to the field type; encrypts multiple fields in the initial request according to the encryption method corresponding to each field to obtain a first encryption request; and sends the first encryption request to the back-end server. That is, the scheme of the present application encrypts different fields in the initial request using different encryption methods, so that there are multiple encryption methods in the obtained encryption request, avoiding the situation that if the key is leaked during data transmission, all data encrypted using the key will no longer be safe, thereby improving the security of data transmission encryption, and thus improving the security of network communication.
[0095] The present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the data transmission encryption method provided in any of the above embodiments is implemented.
[0096] The present application also provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the data transmission encryption method provided by any of the above embodiments is implemented.
[0097] Reference below Figure 4 , which shows a structural schematic diagram of an electronic device 400 suitable for implementing the present application. Figure 4 The electronic device shown is only an example and should not bring any limitation to the function and scope of use of the present application.
[0098] like Figure 4 As shown, the electronic device 400 includes a central processing unit (CPU) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage part 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The CPU 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0099] The following components are connected to the I / O interface 405: an input section 406 including a keyboard, a mouse, etc.; an output section 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, a modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the I / O interface 405 as needed. A removable medium 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as needed, so that a computer program read therefrom is installed into the storage section 408 as needed.
[0100] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 409, and / or installed from the removable medium 411. When the computer program is executed by the central processing unit (CPU) 401, the above-mentioned functions defined in the system of the present application are executed.
[0101] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0102] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0103] The modules and / or units described in this application may be implemented in software or hardware. The modules and / or units described may also be set in a processor. For example, it may be described as follows: a processor includes an interception module, a mode determination module, an encryption module, and a sending module. The names of these modules do not, in some cases, constitute limitations on the modules themselves.
[0104] As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device performs the following operations:
[0105] Intercept an initial request sent by a front-end server to a back-end server; determine the encryption method corresponding to each field in the initial request according to the field types of multiple fields in the initial request and the encryption method corresponding to the field type; encrypt multiple fields in the initial request according to the encryption method corresponding to each field to obtain a first encrypted request; and send the first encrypted request to the back-end server.
[0106] According to the technical solution of the present application, the initial request sent by the front-end server to the back-end server is intercepted; the encryption method corresponding to each field in the initial request is determined according to the field types of multiple fields in the initial request and the encryption method corresponding to the field type; the multiple fields in the initial request are encrypted according to the encryption method corresponding to each field to obtain a first encryption request; the first encryption request is sent to the back-end server. That is, the solution of the present application uses different encryption methods to encrypt different fields in the initial request, so that there are multiple encryption methods in the obtained encryption request, which avoids the situation that if the key is leaked during data transmission, all data encrypted using the key will no longer be safe, thereby improving the security of data transmission encryption and thus improving the security of network communication.
[0107] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the data transmission encryption method provided in any embodiment of the present application.
[0108] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to perform the computer program code of the present application, and the programming language includes an object-oriented programming language, such as Java, Smalltalk, C++, and also includes a conventional procedural programming language, such as "C" language or similar programming language. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on the remote computer, or completely on the remote computer or server. In the case of a remote computer, 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 can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0109] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution of this application can be achieved, and this document is not limited here.
[0110] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A data transmission encryption method, characterized in that: The method comprises: Intercept the initial request sent by the front-end server to the back-end server; Determine, according to field types of multiple fields in the initial request and encryption methods corresponding to the field types, an encryption method corresponding to each of the fields in the initial request; Encrypting multiple fields in the initial request according to the encryption method corresponding to each field to obtain a first encrypted request; The first encryption request is sent to the backend server.
2. The method according to claim 1, characterized in that After encrypting the multiple fields in the initial request according to the encryption mode corresponding to each of the fields to obtain the first encrypted request, the method further includes: According to the file type of the first encryption request, the first encryption request is re-encrypted to obtain a second encryption request; The sending the first encryption request to the backend server includes: The second encryption request is sent to the backend server.
3. The method according to claim 2, characterized in that The step of performing secondary encryption on the first encryption request according to the file type of the first encryption request to obtain a second encryption request includes: Determining an encryption method corresponding to the first encryption request according to a file type of the first encryption request and an encryption method corresponding to the file type; The first encryption request is encrypted twice according to the encryption method corresponding to the first encryption request to obtain a second encryption request.
4. The method according to claim 2, characterized in that: The method further comprises: intercepting an initial encrypted response returned by the back-end server to the front-end server; Decrypting the initial encrypted response according to the data type of the initial encrypted response to obtain a first decrypted response; Determine, according to field types of multiple fields in the first decryption response and decryption methods corresponding to the field types, a decryption method corresponding to each of the fields in the first decryption response; According to the decryption method corresponding to each of the fields, multiple fields in the first decryption response are decrypted to obtain response data, and the response data is sent to the front-end server.
5. The method according to claim 4, characterized in that The decrypting the initial encrypted response according to the data type of the initial encrypted response to obtain a first decrypted response includes: Determine a decryption method corresponding to the initial encrypted response according to the data type of the initial encrypted response and the decryption method corresponding to the data type; The initial encrypted response is decrypted according to a decryption method corresponding to the initial encrypted response to obtain a first decrypted response.
6. The method according to claim 4, characterized in that The field types include string types and object types.
7. The method according to claim 5, characterized in that The encryption method corresponding to the file type includes encryption with a symmetric encryption algorithm and encryption with an asymmetric encryption algorithm; the decryption method corresponding to the data type includes decryption with the symmetric encryption algorithm and decryption with the asymmetric encryption algorithm.
8. A data transmission encryption device, characterized in that: The device comprises: An interception module, used to intercept the initial request sent by the front-end server to the back-end server; A mode determination module, used to determine the encryption mode corresponding to each field in the initial request according to the field types of the multiple fields in the initial request and the encryption modes corresponding to the field types; An encryption module, used for encrypting multiple fields in the initial request according to an encryption method corresponding to each field, to obtain a first encrypted request; A sending module is used to send the first encryption request to the back-end server.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the data transmission encryption method as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the data transmission encryption method as described in any one of claims 1 to 7 is implemented.