Data transmission method, device and storage medium

By using dynamic encryption keys and multiple encryption technologies, the problem of difficulty in detecting front-end data tampering is solved, thus achieving security and reliability in data transmission.

CN115550915BActive Publication Date: 2026-05-15AGRICULTURAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
AGRICULTURAL BANK OF CHINA
Filing Date
2022-09-29
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing technologies cannot effectively identify whether data sent from the front end to the back end has been maliciously tampered with, resulting in a high security risk during data interaction.

Method used

By generating dynamic and random encryption keys, the data transmitted from the front end to the back end is encrypted multiple times and then verified on the back end to identify whether the data has been tampered with.

Benefits of technology

This improves the security of data received by the backend, prevents illegal data from being sent back to the backend, and ensures data reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115550915B_ABST
    Figure CN115550915B_ABST
Patent Text Reader

Abstract

The application provides a data transmission method, device and storage medium. The method comprises the following steps: a front end determines whether data of a target type exists in first data to be transmitted from the front end to a back end. If the data of the target type exists, a target key is generated by using a random number and an initial key. The first data is encrypted by using the target key, and the encrypted first data is added to the first data as an encrypted field to obtain second data. The second data is encrypted by using the initial key, and target data is generated according to the encrypted second data and the random number. The target data is transmitted to the back end. The back end performs legitimacy verification based on the random number and the target data to determine whether the first data is tampered. The method provided by the application improves the security of the data transmitted from the front end to the back end.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to communication technology, and more particularly to a data transmission method, device, and storage medium. Background Technology

[0002] Nowadays, people can use mobile phones, computers, tablets, and other terminal devices to browse news, shop, and handle various transactions. These transactions are completed through data interaction between the front end (e.g., the terminal device) and the back end (e.g., the server providing the service). Specifically, the front end sends data back to the back end by downloading front-end code from the back end.

[0003] When the front-end and back-end interact with each other, the front-end code providing the service (such as Hyper Text Markup Language (HTML), Cascading Style Sheets (CSS), JavaScript, etc.) needs to be downloaded to the front-end, and is therefore transparent to the user. Consequently, data sent back to the back-end using this front-end code is at risk of being tampered with, posing a security risk and leading to data security issues. Currently, code obfuscation techniques are primarily used to compress and obfuscate the front-end code, reducing its readability and increasing the difficulty and cost of tampering with it, thereby mitigating the risk of data tampering using the front-end code.

[0004] However, current data transmission methods that improve data security through code obfuscation techniques still cannot identify whether the data sent from the front end to the back end has been maliciously tampered with, resulting in a high security risk during data interaction. Summary of the Invention

[0005] This application provides a data transmission method, device, and storage medium to solve the problem that it is currently impossible to identify whether the data transmitted from the front end to the back end has been maliciously tampered with, resulting in a high security risk during data interaction.

[0006] In a first aspect, this application provides a data transmission method, including:

[0007] Determine if the target type of data exists in the first data that the front-end code is to send back to the back-end;

[0008] If it exists, the target key is generated using a random number and an initial key; the random number is generated by the backend and sent to the frontend.

[0009] The first data is encrypted using the target key, and the encrypted first data is added to the first data as an encrypted field to obtain the second data.

[0010] The second data is encrypted using the initial key, and target data is generated based on the encrypted second data and a random number.

[0011] The target data is sent to the backend.

[0012] Secondly, this application provides a data transmission method, including:

[0013] Receive target data sent from the front end;

[0014] Random numbers are extracted from the target data, and a first legality verification is performed based on the extracted random numbers and the stored random numbers to determine whether the extracted random numbers were generated by the backend and sent to the frontend.

[0015] If the first legitimacy verification passes, the target data is decrypted using the initial key to obtain the decrypted target data;

[0016] Determine whether there is an encrypted field in the decrypted target data;

[0017] If it is determined that an encrypted field exists, a target key is generated using the stored random number and the initial key, and the encrypted field is decrypted using the target key to obtain the decrypted first data;

[0018] A second legality verification is performed based on the decrypted first data and the first data in the decrypted target data excluding the encrypted field, to determine whether the first data has been tampered with; the first data is the data that the front-end code is to send back to the back-end.

[0019] Thirdly, this application provides a data transmission apparatus, comprising:

[0020] The processing module is used to determine whether the target type of data exists in the first data to be sent back to the backend from the frontend code; if it exists, a target key is generated using a random number and an initial key; the random number is generated by the backend and sent to the frontend; the first data is encrypted using the target key, and the encrypted first data is added to the first data as an encrypted field to obtain the second data; the second data is encrypted using the initial key, and the target data is generated based on the encrypted second data and the random number.

[0021] The sending module is used to send the target data to the backend.

[0022] Fourthly, this application provides a data transmission apparatus, comprising:

[0023] The receiving module is used to receive target data sent by the front end;

[0024] The processing module is configured to extract random numbers from the target data, and perform a first validity verification based on the extracted random numbers and stored random numbers to determine whether the extracted random numbers were generated by the backend and sent to the frontend; if the first validity verification passes, the target data is decrypted using an initial key to obtain decrypted target data; it is determined whether there is an encrypted field in the decrypted target data; if an encrypted field is determined to exist, a target key is generated using the stored random numbers and the initial key, and the encrypted field is decrypted using the target key to obtain decrypted first data; based on the decrypted first data and the first data in the decrypted target data excluding the encrypted field, a second validity verification is performed to determine whether the first data has been tampered with; the first data is the data that the frontend code needs to send back to the backend.

[0025] Fifthly, this application provides a data transmission device, comprising: a processor, a communication interface, and a memory; the processor is communicatively connected to both the communication interface and the memory.

[0026] The memory stores computer-executed instructions;

[0027] The communication interface communicates and interacts with external devices.

[0028] The processor executes computer execution instructions stored in the memory to implement the method as described in any one of the first or second aspects.

[0029] In a sixth aspect, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the data transmission method as described in any one of the first or second aspects.

[0030] The data transmission method, device, and storage medium provided in this application encrypt the data transmitted from the front end to the back end by generating a dynamic and random encryption key. The back end, by recognizing the encrypted fields, can quickly identify whether the data transmitted from the front end has been tampered with, thereby effectively preventing the transmission of illegal data back to the back end through front-end code, which could lead to unreliable data and improve the security of the data received by the back end. Attached Figure Description

[0031] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0032] Figure 1 A system architecture diagram for an application scenario provided in this application;

[0033] Figure 2 A flowchart illustrating how the front-end sends data using multiple encryption methods, as provided in this application;

[0034] Figure 2A This application provides a flowchart illustrating how data is decrypted.

[0035] Figure 3 This is a schematic diagram illustrating the acquisition of second data as provided in an embodiment of this application.

[0036] Figure 4 An interactive schematic diagram of another data transmission method provided in an embodiment of this application;

[0037] Figure 5A A flowchart illustrating an initial key transmission method provided in an embodiment of this application;

[0038] Figure 5B A flowchart illustrating a data transmission method provided in an embodiment of this application;

[0039] Figure 6 A schematic diagram of a data transmission device provided in this application;

[0040] Figure 7 A schematic diagram of another data transmission device provided in this application;

[0041] Figure 8 This is a schematic diagram of a data transmission device structure provided in this application.

[0042] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0043] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0044] First, let me explain the terms used in this application:

[0045] Front-end: refers to the terminal device on which the client of a website or application is deployed, used to display the front-end of the website or application, enabling users to browse and interact with it. This terminal device can be, for example, a smartphone, computer, laptop, tablet, etc. In this application, the client of the website or application can be, for example, a web-based client, a mini-program client, or an app-based client.

[0046] Backend: refers to the backend part of a website or application, which provides data access services to the frontend. It can be a server, server cluster, etc.

[0047] Code obfuscation, also known as code splicing, refers to the act of transforming computer program code into a functionally equivalent but difficult-to-read and understand form. For example, it can rewrite various elements in the code, such as variable, function, and class names, into meaningless names. This might involve rewriting them as single letters, short, meaningless combinations of letters, or even symbols like "__", making it impossible for the reader to guess their purpose from the name. It can also involve rewriting parts of the code's logic into a functionally equivalent but more difficult-to-understand form, simplifying intermediate variables, or disrupting code formatting, such as removing spaces, squeezing multiple lines of code into one line, or breaking one line of code into multiple lines.

[0048] First, the application scenarios and system architecture of this application will be explained.

[0049] Figure 1 This is a system architecture diagram for one application scenario provided in this application. For example... Figure 1 As shown, the system may include at least one front-end and one back-end.

[0050] Users can access and browse the front-end of a website or application through the front-end, or complete business transactions through data interaction. These transactions could include online shopping, handling everyday services, etc. The user's terminal device downloads the front-end code to obtain the website or application's pages and functions. Using these pages and functions, the data generated by the front-end is transmitted to the back-end, enabling the back-end to process the user's business requests and information. After processing the front-end data, the back-end returns the processing result to the front-end to notify the user of the business processing outcome.

[0051] When the front-end and back-end interact with each other, the code that constitutes the front-end business logic and the user interface is downloaded to the user's terminal device. Therefore, the front-end code can be accessed by the user. Users can tamper with the data sent back to the back-end by the front-end code, making the data transmitted from the front-end to the back-end unreliable. Currently, code obfuscation techniques are mainly used to compress and obfuscate the front-end code, reducing its readability and increasing the difficulty of tampering with the data sent back to the back-end using the front-end code, thereby reducing the risk of data tampering.

[0052] However, while code obfuscation techniques can reduce the readability of front-end code to some extent, the possibility of the front-end code being deciphered still exists. This can lead to data being sent back to the back-end through tampering with the front-end code, resulting in unreliable data. Therefore, the security of data sent from the front-end to the back-end remains relatively low.

[0053] In view of this, this application provides a data transmission method that generates a dynamic and random encryption key to encrypt the data transmitted from the front end to the back end. By recognizing the encrypted fields, the back end can quickly identify whether the data transmitted from the front end has been tampered with, thereby effectively preventing the transmission of illegal data back to the back end through front end code, which could lead to unreliable data and improve the security of the data received by the back end.

[0054] exist Figure 1 Under the system architecture described below, taking data interaction between a front-end and a back-end as an example, the technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems will be described in detail with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.

[0055] The embodiments of this application can be used for online shopping, business processing, etc. The following uses the scenario of users conducting business online in a banking system as an example to describe in detail the data transmission method provided by this application.

[0056] Figure 2 This is a flowchart illustrating how the front-end sends data using multiple encryption methods, as provided in this application. Figure 2 As shown, the method may include:

[0057] S201. The front-end determines whether the target type of data exists in the first data to be sent back to the back-end from the front-end code.

[0058] The target type mentioned above can be set according to actual needs. For example, the target type can be the type of data that, if tampered with, would cause damage, leakage, alteration, or loss to backend users.

[0059] Therefore, before sending data, the front end can first determine whether the target type of data exists in the first data to be sent back to the back end. If the target type of data exists in the first data, it means that tampering with the first data would have a significant impact on the back end data. Therefore, secondary encryption is required to reduce the risk of data tampering through multiple encryption methods, i.e., execute steps S202-S204; if the target type of data does not exist in the first data, it means that tampering with the first data will not have a significant impact on the back end data. A single encryption method can be used, i.e., execute step S205.

[0060] For example, the first data can be data transmitted from the front end to the banking system (back end) when a user makes an online remittance, bill payment, or credit card service through the banking system. This data may include one or more of the following: order information, user account information, and business requests. The target type may refer to user account information, order information, etc. When the first data includes account information and / or order information, it is considered that data of this target type exists.

[0061] S202. The front end uses random numbers and the initial key to generate the target key.

[0062] The random number is generated by the backend and sent to the frontend. This random number can be generated using any existing random number generation method, and this application does not impose any restrictions on it. When the frontend and backend transmit data, the frontend can first send a random number retrieval request to the backend to trigger the backend to generate and send the random number to the frontend. Alternatively, the backend can proactively send the random number to the connected frontend according to a preset strategy, such as sending the random number to the frontend at preset time intervals.

[0063] One possible implementation is to generate a random number for each data transmission action between the front-end and the back-end. For example, after the front-end and back-end complete a data transmission, the back-end needs to regenerate a random number and send it to the front-end for use in the next data transmission.

[0064] Another possible implementation is to generate a random number for multiple data transmissions within a preset number of times. For example, if the preset number of times is 3, then after the backend generates a random number and sends it to the frontend, the next three data transmissions will use this random number. Before the fourth data transmission, the backend will regenerate a random number and send it to the frontend for use in the next three data transmissions.

[0065] The initial key is a key used in a symmetric encryption algorithm. Symmetric encryption algorithms use the same key to encrypt and decrypt data. Examples of such algorithms include the Data Encryption Standard (DES), Advanced Encryption Standard (AES), RC2, RC4, and RC5. The initial key can be any of these symmetric encryption algorithms, such as an AES key. When using an AES key for data transmission, the high encryption efficiency of AES allows for faster data encryption at the front end and more efficient data decryption at the back end, thus improving the overall efficiency of encrypted data transmission.

[0066] The initial key can be generated by the front-end, generated by the back-end and synchronized to the front-end, generated by another device and synchronized to either the front-end or the back-end, which then synchronizes it to the other, or directly synchronized to both the front-end and the back-end, etc. This application does not impose any restrictions on this. The initial key can be sent encrypted or unencrypted. When the initial key is sent encrypted, the encryption algorithm can be an asymmetric encryption algorithm, such as RSA or Elgamal.

[0067] Optionally, the target key can be generated by inserting the random number into the data corresponding to the initial key. This application does not restrict the position of the random number insertion; for example, the random number can be added before the first data in the data string of the initial key, inserted at any intermediate position in the data string of the initial key, or added after the last data in the data string of the initial key.

[0068] Optionally, the target key can also be generated by replacing part of the data in the initial key with the random number, or by performing operations on the random number with part or all of the data in the initial key. This application does not limit how the random number and the initial key are used to generate the target key, as long as any one or a combination of the above possible implementations is used.

[0069] In this implementation, the target key can be randomly generated by random number generation, so that the target key corresponding to the encrypted data is dynamically random, which increases the difficulty of cracking the target key and further improves the security of the first data, making the data sent from the front end to the back end by the front end code more secure.

[0070] S203. The front end uses the target key to encrypt the first data, and adds the encrypted first data as an encrypted field to the first data to obtain the second data.

[0071] The specific method for adding the encrypted first data as an encrypted field to the first data can be pre-agreed upon by the front-end and back-end, or it can be pre-set in the front-end and back-end to ensure that the back-end can accurately obtain the encrypted field when decrypting later.

[0072] For example, the encrypted first data can be added as an encrypted field to any position within the first data. This could be before the first data item, in the middle, or after the last data item. Alternatively, the encrypted first data can be split into multiple encrypted fields and added to different positions within it. Or, the first data can have a reserved address range for storing the encrypted field, which can then be stored there. Then, the first data with the added encrypted field becomes the second data. That is, the second data includes the first data and the encrypted field corresponding to the encrypted first data.

[0073] Taking the encrypted first data as an example, and adding it after the last data in the first data as the encrypted field. Figure 3 This is a schematic diagram illustrating an embodiment of obtaining second data. For example... Figure 3 As shown, the second data includes the first data and an encrypted field, which are combined to form the second data. The above example is merely one possible implementation for illustrative purposes; it should be understood that this application does not limit the method of obtaining the second data.

[0074] S204. The front end uses the initial key to encrypt the second data, and generates the target data based on the encrypted second data and a random number.

[0075] This random number is used by the backend to verify the validity of the target data.

[0076] The target data may exist in other data forms that can be transmitted between the front end and the back end. As long as the target data includes encrypted second data and a random number, this application does not limit the specific data form of the target data.

[0077] For example, the target data may exist in the form of a message. In one possible implementation, the encrypted second data is stored in the message's payload, and the random number may be located in the message's header. In another possible implementation, both the encrypted second data and the random number are located in the message's payload.

[0078] In this application, the second data is first encrypted with a target key, and then, based on this target key encryption, it is further encrypted with an initial key. This ensures that the target data transmitted from the front-end to the back-end via the front-end code includes the first data, which is encrypted in two layers, thus improving the security of the first data.

[0079] It should be understood that the embodiments of this application are merely illustrative examples of multiple encryption of the first data using two-layer encryption as an example. This application can also implement the above process by using multiple random numbers and multiple initial keys to perform multiple encryption on the data. For example, based on one random number and two initial keys, data at different positions of the two initial keys can be processed to obtain two target keys, thereby performing triple encryption on the data; or multiple encryption can be performed using two random numbers and two initial keys in the above manner, thereby further improving the security of data transmitted from the front end to the back end through the front-end code and reducing the risk of the data being tampered with.

[0080] After step S204 is completed, i.e. after the target data is generated, step S206 is executed.

[0081] S205. Encrypt the first data using the initial key, and generate target data to be sent to the backend based on the encrypted first data and a random number. After generating the target data, proceed to step S206.

[0082] The method of generating target data based on the encrypted first data and the random number is similar to the method of generating target data based on the second data and the random number in step S204 above, and will not be repeated here.

[0083] S206. The front end sends the target data to the back end.

[0084] Correspondingly, the backend receives the target data.

[0085] For example, the method by which the front end sends the encrypted data to the back end can be a data transmission method in the existing technology, such as any of the data transmission methods such as XMLHttpRequest, post, and ajax.

[0086] The above describes how the front end uses multiple encryption methods to send data. The following examples describe the process from the back end's perspective, illustrating how to decrypt data.

[0087] Figure 2A This is a flowchart illustrating the process of decrypting data provided in this application. Figure 2A As shown, the method may include:

[0088] S207. The backend extracts random numbers from the target data and performs the first validity verification based on the extracted random numbers and the stored random numbers.

[0089] The first validity verification is used to determine whether the extracted random number was generated by the backend and sent to the frontend. If the first validity verification passes, it indicates that the target data can be further processed, and step S208 is executed. Optionally, if the first validity verification fails, it indicates that the target data has been tampered with and poses a security risk, and the backend refuses to process the target data, that is, step S213 is executed.

[0090] In this embodiment, after the backend generates a random number, it can store the random number in its local database or in a separate database connected to the backend. This database can be any existing database such as Redis, MySQL, Oracle, or SQL Server. When storing the random number, the backend also needs to store the frontend's identification information to determine the frontend corresponding to the random number. This frontend identification information can be, for example, the frontend's MAC address or device name. When using a Redis database to store the random number, Redis's memory-based architecture offers high performance and fast response time, further improving the speed of extracting the random number and / or initial key, thereby increasing the efficiency of encrypted data transmission.

[0091] The backend retrieves the corresponding random number from the database and compares it with the random number in the target data. If the random number in the database is the same as the random number in the target data, the first validity verification passes; if the random number in the database is different from the random number in the target data, the first validity verification fails.

[0092] S208. The backend uses the initial key to decrypt the target data and obtains the decrypted target data.

[0093] S209. The backend determines whether there is an encrypted field in the decrypted target data.

[0094] If an encrypted field exists, it indicates that the target data contains data encrypted with the target key, that is, there is multi-encrypted data. The target key is needed to decrypt the encrypted field to further verify whether the data has been tampered with, that is, to execute steps S210-212; if no encrypted field exists, it indicates that the decrypted target data does not contain multi-encrypted data, that is, the decrypted target data is the first data, and to execute step S212.

[0095] One possible approach is to include an identifier in the target data indicating the presence of an encrypted field, allowing the backend to determine the presence of the encrypted field by detecting this identifier. Alternatively, the backend can read the decrypted target data based on the specific method of adding the encrypted field to determine its existence.

[0096] S210. Generate a target key using the stored random number and the initial key, and use the target key to decrypt the encrypted field to obtain the decrypted first data.

[0097] When the backend determines that the target data contains encrypted fields, it generates a target key using stored random numbers and an initial key, following the same method as generating the target key on the frontend. The target key can be generated in a way that is pre-set in both the frontend and backend, synchronized from the frontend to the backend, synchronized from the backend to the frontend, or synchronized from other devices to both the frontend and backend, etc.

[0098] S211. The backend performs a second legality verification based on the decrypted first data and the first data in the decrypted target data excluding the encrypted field.

[0099] The second legitimacy verification is used to determine whether the first data has been tampered with. Optionally, if the second legitimacy verification passes, it indicates that the first data has not been tampered with and there is no data security issue, and step S212 is executed; alternatively, if the second legitimacy verification fails, it indicates that the first data has been tampered with and there is a data security issue, and step S213 is executed.

[0100] The backend determines the legitimacy of the first data by comparing it with the first data in the decrypted target data excluding the encrypted field. For example, the legitimacy of the first data can be determined by comparing whether the first data in the decrypted first data and the first data in the decrypted target data excluding the encrypted field are the same.

[0101] If the decrypted first data and the decrypted target data (excluding the encrypted field) are the same, it indicates that the first data has not been tampered with and there is no data security issue; the second validity verification is then performed. If the decrypted first data and the decrypted target data (excluding the encrypted field) are different, it indicates that the first data has been tampered with and there is a data security issue; the second validity verification fails.

[0102] The above is a detailed description of how the backend decrypts data according to this application. Optionally, after the backend completes data decryption, this application may also include the following steps:

[0103] S212. The backend processes the first data to obtain the processing result of the first data and a new random number, and sends the processing result of the first data and the new random number to the frontend.

[0104] The processing result could be, for example, approving and executing a user's remittance request, or determining changes to a user's account information. The new random number is a random number regenerated by the backend.

[0105] S213. The backend generates a new random number and sends the new random number to the frontend.

[0106] In any of the above embodiments, the methods for encrypting data with a key and decrypting data with a key can refer to existing technologies, and will not be described in detail here.

[0107] The data transmission method provided in this application generates a dynamic and random encryption key to perform multiple encryption transmissions of data sent from the front end to the back end. By performing multiple validity checks on the random number and encrypted fields, the back end can quickly identify whether the data sent from the front end has been tampered with. This effectively prevents illegal data from being sent back to the back end through front end code, thus preventing data unreliability and improving the security of data received by the back end from the front end.

[0108] Regarding step S208, where the initial key is sent from the front end to the back end before sending the target data, the following describes another data transmission method provided by this application embodiment using encrypted transmission of the initial key as an example. The encryption algorithm in this method can be a symmetric encryption algorithm or an asymmetric encryption algorithm; the following explanation uses an asymmetric encryption algorithm (RSA encryption algorithm) as an example.

[0109] Figure 4 This is an interactive schematic diagram of another data transmission method provided in an embodiment of this application. For example... Figure 4 As shown, the method may include:

[0110] S401, Backend generates key pairs.

[0111] The key pair consists of a public key and a private key. The public key is sent to the front end so that the front end can encrypt the initial key using the public key. The private key is used to decrypt the initial key encrypted with the public key and received by the back end from the front end.

[0112] S402, The backend sends the public key to the frontend.

[0113] Correspondingly, the front end generates an initial key and receives the public key.

[0114] The method for generating the initial key at the front end can refer to the existing methods for generating keys for symmetric encryption algorithms, and the method for the back end to send the public key to the front end can refer to the existing methods for distributing public keys, which will not be elaborated here. The method by which the back end sends the public key to the front end can be encrypted or unencrypted, and this application does not impose any restrictions on this.

[0115] S403. The front end uses the public key to encrypt the initial key to obtain encrypted data.

[0116] The front end uses the public key of the RSA algorithm and the method of encrypting data using the public key in the RSA algorithm to encrypt the initial key, thereby obtaining the encrypted data. The encrypted data includes the encrypted initial key.

[0117] S404, The front end sends the encrypted data to the back end.

[0118] Correspondingly, the backend receives the encrypted data sent by the frontend.

[0119] The encrypted data is obtained by encrypting the initial key using a public key.

[0120] S405. The backend uses the private key to decrypt the encrypted data and obtain the initial key.

[0121] The backend decrypts the encrypted data, which was encrypted with the public key, using the private key from the key pair, thereby obtaining the initial key from the encrypted data. This private key can be stored in the backend's memory or in a database connected to the backend. When the backend receives the encrypted data, it retrieves the private key from its storage location to decrypt the encrypted data.

[0122] Another data transmission method provided in this application embodiment encrypts the initial key during transmission using a key pair, thereby improving the security of the initial key when the front end sends it to the back end, reducing the risk of leakage of the initial key, and thus improving the security of encrypting the data to be sent back to the back end using the initial key, further reducing the risk of data tampering when the front end code is sent back to the back end.

[0123] As mentioned above Figure 2 Following the method steps described above, the method for updating the random number will be explained. The following example illustrates a random number updating method provided in this application, using the generation of a new random number for each data transmission as an example.

[0124] When the legality verification passes, it indicates that the first legality verification in step S207 has passed, and the second legality verification in step S211 has passed.

[0125] The legitimacy verification confirms that the content of the first data has not been tampered with. The frontend transmits the target data corresponding to the first data to the backend without posing a data security risk to the backend. At this point, the backend processes the first data to obtain the processing result and a new random number, and sends the processing result and the new random number back to the frontend.

[0126] The backend processes the first data in a specific way, and the processing result is determined based on the content of the first data. For example, if the first data includes a remittance request, then the backend retrieves the account information related to the remittance, the remittance amount, the remittance time, etc., and executes the remittance operation accordingly. Then, based on the result of the remittance operation, the corresponding processing result is obtained, which could be, for example, remittance successful or remittance failed. The method for generating the new random number is the same as the aforementioned random number generation method, and will not be repeated here. After the new random number is generated, it replaces the original random number and is stored in the backend or database.

[0127] Correspondingly, the front end receives the processing result of the first data sent by the back end after the legality verification is passed, as well as a new random number.

[0128] The processing result can be directly pushed to the front end, for example, via SMS, telephone, or displayed on the front end in at least one way. The new random number updates the location where the random number was originally stored on the front end, replacing the original random number, so that the front end can use it in the next data transmission with the back end.

[0129] If either the first validity verification in step S207 or the second validity verification in step S211 fails, then the validity verification fails.

[0130] A failed validity verification indicates that the content of the first data has been tampered with. Transmitting the target data corresponding to this first data from the front end to the back end would pose a data security risk to the back end. In this case, the back end refuses to process the first data. Furthermore, the back end generates a new random number and sends it to the front end.

[0131] Correspondingly, the front end receives a new random number sent by the back end after the validity verification fails.

[0132] It should be understood that, under this implementation, regardless of whether the target type of data exists in the first data to be sent back to the backend by the frontend code, or whether the target data passes the first legality verification and / or the first legality verification, the backend considers the data transmission process to be over after completing the corresponding process. A new random number needs to be generated to replace the original random number, so that a random number can only be used for one data transmission. This further ensures that each target key generated based on the random number can only be used for one data transmission. Therefore, by using dynamic and random random numbers and target keys for data transmission, the difficulty of cracking the data to be sent back to the backend is increased, and the security of the frontend transmitting data to the backend using the frontend code is improved.

[0133] Another data transmission method provided in this application updates a random number each time the front-end transmits data to the back-end. This ensures that the front-end verifies the dynamically changing random number each time it sends data back to the back-end via its code. Furthermore, a target key is generated using this random number, making the target key dynamically changing and random for each data transmission. This increases the difficulty of cracking the random number and target key, thereby reducing data security issues caused by data tampering and improving the security of data transmitted from the front-end to the back-end.

[0134] Below, for ease of understanding, we will use the RSA algorithm to encrypt the initial key, the AES algorithm key (here, the initial key is referred to as AES and the target key is referred to as AES1) to encrypt the data transmission, and the backend database is a Redis database as an example to illustrate the data transmission method provided in this application.

[0135] Figure 5A This is a flowchart illustrating an initial key transmission method provided in an embodiment of this application, as shown below. Figure 5A As shown, the method may include:

[0136] S501. The backend generates an RSA key pair and sends the RSA public key to the frontend.

[0137] Accordingly, the front end receives the public key.

[0138] The backend also stores the RSA private key in the Redis database.

[0139] S502, the front end generates the initial key AES.

[0140] S503: The front end encrypts the initial key AES using the RSA public key to obtain encrypted data.

[0141] S504: The front end synchronizes encrypted data to the back end.

[0142] S505: The backend reads the RSA private key to decrypt the encrypted data, obtains the initial key AES, and generates a random number.

[0143] S506, The backend sends the random number to the frontend.

[0144] Correspondingly, the front end receives the random number.

[0145] Optionally, steps S501-S506 can be performed once before each data transmission from the front end to the back end, once within a preset number of data transmissions between the front end and the back end, or only once between the front end and the back end. The execution method can be determined according to actual needs, and this application does not impose any restrictions on it.

[0146] Figure 5B This is a schematic flowchart illustrating a data transmission method provided in an embodiment of this application. Figure 5B As shown, the method may include:

[0147] S507. The front end determines whether the target type of data exists in the first data to be sent back to the back end. If it exists, proceed to steps S508-S511. If it does not exist, proceed to step S512.

[0148] S508: The front end obtains the target key AES1 based on the random number and the initial key AES.

[0149] S509. The front end uses the target key AES1 to encrypt the first data and uses the encrypted first data as the encrypted field.

[0150] S510: The front end obtains the second data based on the first data and the encrypted field.

[0151] S511. The front end uses the initial key AES to encrypt the second data, and generates the target data based on the random number and the encrypted second data.

[0152] After executing step S511, execute step S513.

[0153] S512. The front end uses the initial key AES to encrypt the first data, and generates the target data based on the random number and the encrypted first data.

[0154] After executing step S512, execute step S513.

[0155] S513, The front end sends the target data to the back end.

[0156] Accordingly, the backend receives the data.

[0157] S514. The backend reads a random number and the initial key AES from the Redis database and performs a first validity verification with the random number in the target data. If the verification passes, proceed to step S515; if the verification fails, proceed to step S522.

[0158] S515: The backend decrypts the target data using the initial key AES to obtain the first data and the encrypted fields.

[0159] S516. The backend determines whether the encrypted field exists in the decrypted target data. If it exists, proceed to steps S517-519; otherwise, proceed to step S520.

[0160] S517. The backend generates the target key AES1 based on the random number and the initial key AES.

[0161] S518: The backend uses the target key AES1 to decrypt the encrypted field and obtain the first decrypted data.

[0162] S519. The backend performs a second validity verification based on the decrypted first data and the first data in the target data excluding the encrypted fields. If the verification passes, proceed to step S521; if the verification fails, proceed to step S522.

[0163] S520: The backend uses the initial key AES to decrypt the target data and obtain the first data. Execute step S521.

[0164] S521. The backend obtains the processing result of the first data and a new random number based on the first data, and then sends the processing result and the new random number to the frontend.

[0165] S522: The backend generates a new random number and sends the new random number to the frontend.

[0166] The backend saves the updated random number to the Redis database.

[0167] This application provides a data transmission method that can be executed in the above-described method embodiments. Figures 2 to 4 The data transmission method shown is similar in principle and technical effect, and will not be described in detail here.

[0168] Figure 6 This is a schematic diagram of a data transmission device provided in this application. Figure 6 As shown, the data transmission device includes a processing module 11 and a sending module 12. Optionally, the data transmission device may also include a receiving module 13.

[0169] Processing module 11 is used to determine whether the target type of data exists in the first data to be sent back to the backend from the frontend code; if it exists, a target key is generated using a random number and an initial key; the first data is encrypted using the target key, and the encrypted first data is added to the first data as an encrypted field to obtain the second data; the second data is encrypted using the initial key, and the target data is generated based on the encrypted second data and the random number; the random number is generated by the backend and sent to the frontend;

[0170] The sending module 12 is used to send target data to the backend.

[0171] Optionally, the receiving module 13 is used to receive the public key sent by the backend; the processing module 11 is further used to generate the initial key, encrypt the initial key using the public key to obtain encrypted data; the sending module 12 is further used to send the encrypted data to the backend so that the backend decrypts the encrypted data to obtain the initial key.

[0172] Optionally, the receiving module 13 is further configured to receive, after the sending module 12 sends the target data to the backend, the processing result of the first data sent by the backend after the validity verification based on the random number and the encrypted first data is passed, and a new random number; or, to receive a new random number sent by the backend after the validity verification based on the random number and / or the encrypted first data fails.

[0173] Optionally, the processing module 11 is further configured to, after determining whether there is data of the target type in the first data to be sent back to the backend from the frontend code, if there is no data of the target type, encrypt the first data using the initial key, and generate target data based on the encrypted first data and a random number. The sending module 12 is further configured to send the target data to the backend; the receiving module 13 is further configured to, after the sending module 12 sends the target data to the backend, receive the processing result of the first data sent by the backend, and a new random number.

[0174] The data transmission device provided in this application embodiment can execute the methods described above. Figures 2 to 5B The actions of the front end in the data transmission method shown are implemented in a similar way, and the technical effects are similar, so they will not be described again here.

[0175] Figure 7 A schematic diagram of another data transmission device provided in this application. Figure 7 As shown, the data transmission device includes a receiving module 21 and a processing module 22. Optionally, the data transmission device may further include at least one of the following modules: a sending module 23.

[0176] The receiving module 21 is used to receive target data sent by the front end.

[0177] Processing module 22 is used to extract random numbers from the target data and perform a first validity verification based on the extracted random numbers and stored random numbers to determine whether the extracted random numbers were generated by the backend and sent to the frontend. If the first validity verification passes, the target data is decrypted using the initial key to obtain the decrypted target data. It is then determined whether an encrypted field exists in the decrypted target data. If an encrypted field is found, a target key is generated using the stored random numbers and the initial key, and the encrypted field is decrypted using the target key to obtain the decrypted first data. Based on the decrypted first data and the first data in the decrypted target data excluding the encrypted field, a second validity verification is performed to determine whether the first data has been tampered with. The first data is the data that the frontend code needs to send back to the backend.

[0178] Optionally, processing module 22 is further configured to generate a key pair, which includes a public key and a private key. Sending module 23 is configured to send the public key to the front end. Receiving module 21 is further configured to receive encrypted data sent by the front end; the encrypted data is obtained by encrypting the initial key using the public key. Processing module 22 is further configured to decrypt the encrypted data using the private key to obtain the initial key.

[0179] Optionally, processing module 22 is further configured to, if the validity verification based on the random number and the encrypted first data passes, process the first data to obtain a processing result of the first data and a new random number. Sending module 23 is further configured to send the processing result of the first data and the new random number to the front end. Alternatively, processing module 22 is further configured to, if the validity verification based on the random number and / or the second data fails, generate a new random number. Sending module 23 is further configured to send the new random number to the front end.

[0180] Optionally, the processing module 22 is further configured to, after determining whether an encrypted field exists in the decrypted target data, if no encrypted field exists, process the first data to obtain a processing result of the first data and a newly generated random number. The sending module 23 is further configured to send the processing result of the first data and the new random number to the front end.

[0181] This application provides a data transmission device that can perform the methods described in the above embodiments. Figures 2 to 5B The backend actions in the data transmission method shown are implemented in a similar way, and their technical effects are similar, so they will not be described in detail here.

[0182] Figure 8 This application provides a schematic diagram of a data transmission device structure. This data transmission device can be, for example, the aforementioned front-end device, or a back-end device. Figure 8As shown, the data transmission device 800 may include at least one processor 801, a memory 802, and a communication interface 803.

[0183] The memory 802 is used to store programs. Specifically, the program may include program code, which includes computer operation instructions.

[0184] The memory 802 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0185] The processor 801 is used to execute computer execution instructions stored in the memory 802 to implement the data transmission method described in the foregoing method embodiments. The processor 801 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0186] The processor 801 can communicate and interact with external devices through the communication interface 803. When the data transmission device 800 is the front-end device, the external device can be the back-end device; when the data transmission device 800 is the back-end device, the external device can be the front-end device, a database, etc. In specific implementations, if the communication interface 803, memory 802, and processor 801 are implemented independently, they can be interconnected via a bus to complete communication. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc., but this does not mean there is only one bus or one type of bus.

[0187] Optionally, in a specific implementation, if the communication interface 803, memory 802, and processor 801 are integrated on a single chip, then the communication interface 803, memory 802, and processor 801 can communicate through an internal interface.

[0188] This application also provides a computer-readable storage medium, which may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk. Specifically, the computer-readable storage medium stores program instructions, which are used in the methods described in the above embodiments.

[0189] This application also provides a program product including executable instructions stored in a readable storage medium. At least one processor of an electronic device can read the executable instructions from the readable storage medium, and the at least one processor executes the executable instructions to cause the electronic device to implement the data transmission methods provided in the various embodiments described above.

[0190] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A data transmission method, characterized in that, The method includes: Determine if the target type of data exists in the first data that the front-end code is to send back to the back-end; If it exists, the target key is generated using a random number and an initial key; the random number is generated by the backend and sent to the frontend. The first data is encrypted using the target key, and the encrypted first data is added as an encrypted field to a preset position in the first data to obtain the second data; The second data is encrypted using the initial key, and target data is generated based on the encrypted second data and a random number. The target data is sent to the backend.

2. The method according to claim 1, characterized in that, The method further includes: Generate the initial key and receive the public key sent by the backend; The initial key is encrypted using the public key to obtain encrypted data; The encrypted data is sent to the backend so that the backend can decrypt the encrypted data and obtain the initial key.

3. The method according to claim 1 or 2, characterized in that, After sending the target data to the backend, the method further includes: The system receives the processing result of the first data sent by the backend after the validity verification based on the random number and the encrypted first data has passed, as well as a new random number; or, The system receives a new random number sent by the backend after the validity verification based on the random number and / or the encrypted first data fails.

4. The method according to claim 1 or 2, characterized in that, After determining whether data of the target type exists in the first data to be sent back to the backend from the frontend code, the process also includes: If it does not exist, the first data is encrypted using the initial key, and target data is generated based on the encrypted first data and a random number, and the target data is sent to the backend. After sending the target data to the backend, the method further includes: The system receives the processing result of the first data sent by the backend, as well as a new random number.

5. A data transmission method, characterized in that, The method includes: The front end receives target data sent by the front end. The target data is generated by the front end based on encrypted second data and a random number. The second data is obtained by the front end adding encrypted first data as an encryption field to a preset position in the first data. The first data is encrypted based on the target key. Random numbers are extracted from the target data, and a first legality verification is performed based on the extracted random numbers and the stored random numbers to determine whether the extracted random numbers were generated by the backend and sent to the frontend. If the first legitimacy verification passes, the target data is decrypted using the initial key to obtain the decrypted target data; Determine whether there is an encrypted field in the decrypted target data; If it is determined that an encrypted field exists, a target key is generated using the stored random number and the initial key, and the encrypted field is decrypted using the target key to obtain the decrypted first data; A second legality verification is performed based on the decrypted first data and the first data in the decrypted target data excluding the encrypted field, to determine whether the first data has been tampered with; the first data is the data that the front-end code is to send back to the back-end.

6. The method according to claim 5, characterized in that, The method further includes: Generate a key pair, the key pair comprising a public key and a private key; Send the public key to the front end; Receive encrypted data sent by the front end; the encrypted data is obtained by encrypting the initial key using the public key; The encrypted data is decrypted using the private key to obtain the initial key.

7. The method according to claim 5 or 6, characterized in that, The method further includes: If the validity verification based on the random number and the encrypted first data passes, the first data is processed to obtain the processing result of the first data, and the processing result of the first data and a new random number are sent to the front end. The new random number is regenerated by the back end. or, If the validity verification based on the random number and / or the encrypted first data fails, a new random number is generated and sent to the front end.

8. The method according to claim 5 or 6, characterized in that, After determining whether the decrypted target data contains an encrypted field, the method further includes: If it is determined that there is no encrypted field, the first data is processed to obtain the processing result of the first data and a new random number, and the processing result of the first data and the new random number are sent to the front end.

9. A data transmission device, characterized in that, include: The processor includes a communication interface and a memory; the processor is communicatively connected to both the communication interface and the memory. The memory stores computer-executed instructions; The communication interface communicates and interacts with external devices. The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the data transmission method as described in any one of claims 1 to 8.