Data exchange method based on Web Restful API
By using data interaction between the client and the server to verify and decrypt business data packets, the possible data tampering problem when transmitting data by network application program interface is solved, and the security of data transmission and the satisfaction of business needs are achieved.
Patent Information
- Application Number
- CN202411851632.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-04-08
AI Technical Summary
In the prior art, when data is transmitted using network application program interfaces, data may be tampered with, affecting the business needs of the customer side.
By receiving a service data packet and a data interaction token in response to the data interaction request initiated by the client, the data key is extracted when the legality verification of the data interaction token is passed, and the service data packet is consistently verified and decrypted, the target service data is obtained and the corresponding business process is executed.
Ensure the security of data transmission, prevent data tampering, meet customer-side business needs, and avoid data transmission security issues in the prior art.
Smart Images

Figure CN119783168A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data interaction, and in particular to a data exchange method based on Web Restful API. Background Art
[0002] Web Restful API is a network application program interface. In the current developed network application scenarios, it is often necessary to access PC clients, APP programs, website programs, WeChat applications, etc. These data can be provided by the same service provider. However, when executing client-side business through the Web Restful API network application program interface, the interactive data may be tampered with, resulting in the inability to accurately meet the client's business needs, and there are problems such as the security of data transmission.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present invention is to provide a data exchange method based on Web Restful API, aiming to solve the technical problem in the prior art that when using network application program interface to transmit data, data may be tampered with, affecting the business needs of the client side.
[0005] To achieve the above object, the present invention provides a data exchange method based on Web Restful API, the data exchange method based on Web Restful API is applied to a server, and the method comprises the following steps:
[0006] In response to a data interaction request initiated by a client, receiving a service data packet and a data interaction token;
[0007] When the legitimacy check of the data interaction token passes, extracting the data key in the data interaction token;
[0008] Performing consistency verification on the service data packet based on the data key;
[0009] When the consistency verification passes, the service data packet is decrypted according to the data key to obtain the target service data;
[0010] Execute the business process corresponding to the target business data.
[0011] Optionally, the performing consistency verification on the service data packet based on the data key includes:
[0012] Extracting carrier data, timestamp data and service message summary from the service data packet;
[0013] Generate a target character string according to the data key, the carrier data and the timestamp data by using a preset connection rule;
[0014] Encrypting the target character string by a first encryption method to obtain a target message digest;
[0015] The target message digest and the service message digest are compared to perform consistency verification.
[0016] Optionally, after receiving the service data packet, the method further includes:
[0017] Decapsulating the service data packet to obtain service data in a preset format;
[0018] Extracting timestamp data from the business data;
[0019] Calculate the time difference between the timestamp data and the current time;
[0020] When the time difference is less than or equal to a preset duration, a step of verifying the legitimacy of the data interaction token is performed.
[0021] Optionally, after decapsulating the service data packet to obtain service data in a preset format, the method further includes:
[0022] Extracting a request identifier from the business;
[0023] Performing duplication detection on the request identifier;
[0024] If the request identifier exists repeatedly, a target error code is generated;
[0025] An exception response is generated according to the target error code, and the exception response is fed back to the client.
[0026] Optionally, the data exchange method based on Web Restful API further includes:
[0027] In response to a username and password verification request initiated by a user terminal, when the verification passes, a response token in a preset format is sent to the client;
[0028] The response token at least includes a data key, and the data key corresponds to the user name.
[0029] In addition, to achieve the above object, the present invention further proposes a data exchange device based on Web Restful API, the data exchange device based on Web Restful API is applied to the data exchange method based on Web Restful API as described above, and the data exchange device based on Web Restful API includes:
[0030] A receiving module, used to respond to a data interaction request initiated by a client and receive a service data packet and a data interaction token;
[0031] An extraction module, used to extract the data key in the data interaction token when the legitimacy verification of the data interaction token passes;
[0032] A verification module, used to verify the consistency of the service data packet based on the data key;
[0033] A decryption module, used to decrypt the service data packet according to the data key to obtain target service data when the consistency verification passes;
[0034] An execution module is used to execute the business process corresponding to the target business data.
[0035] The present invention provides a data exchange method based on Web Restful API, the data exchange method based on Web Restful API is applied to a client, and the method comprises the following steps:
[0036] In response to a response token in a preset format sent by the server, extract a data key and timestamp data in the response token, wherein the timestamp data is current time data;
[0037] Encrypt the service data to be executed by using a second encryption method to obtain carrier data;
[0038] Generate a target character string according to the data key, the carrier data and the timestamp data by using a preset connection rule;
[0039] Encrypt the target character string using a first encryption method to obtain a message digest;
[0040] Assembling the message digest, carrier data and timestamp data according to a preset data format to obtain a service data packet;
[0041] The business data packet is sent to a server to execute the business process corresponding to the target business data.
[0042] In addition, to achieve the above object, the present invention further proposes a data exchange device based on Web Restful API, the data exchange device based on Web Restful API is applied to the data exchange method based on Web Restful API as described above, and the data exchange device based on Web Restful API includes:
[0043] A data extraction module, configured to extract a data key and a timestamp data in a response token in a preset format sent by a server, wherein the timestamp data is data at a current moment;
[0044] A data encryption module, used for encrypting the service data to be executed by a second encryption method to obtain carrier data;
[0045] A character combination module, used to generate a target character string according to the data key, the carrier data and the timestamp data through a preset connection rule;
[0046] A digest generation module, used for encrypting the target character string by a first encryption method to obtain a message digest;
[0047] A data assembly module, used to assemble the message digest, carrier data and timestamp data according to a preset data format to obtain a service data packet;
[0048] The data sending module sends the business data packet to the server to execute the business process corresponding to the target business data.
[0049] In addition, to achieve the above-mentioned purpose, the present invention also proposes a data exchange device based on Web Restful API, and the data exchange device based on Web Restful API includes: a memory, a processor, and a data exchange program based on Web Restful API stored in the memory and executable on the processor, and the data exchange program based on Web Restful API is configured to implement the steps of the data exchange method based on Web Restful API as described above.
[0050] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, on which a data exchange program based on Web Restful API is stored. When the data exchange program based on Web Restful API is executed by a processor, the steps of the data exchange method based on Web Restful API as described above are implemented.
[0051] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the data exchange method based on Web Restful API as described above.
[0052] One or more technical solutions proposed in the present invention have at least the following technical effects: the present invention receives a business data packet and a data interaction token in response to a data interaction request initiated by a client; when the legitimacy check of the data interaction token passes, extracts the data key in the data interaction token; performs consistency verification on the business data packet based on the data key; when the consistency verification passes, decrypts the business data packet according to the data key to obtain the target business data; and executes the business process corresponding to the target business data. Compared with the prior art, the present invention performs a legitimacy verification on the data interaction token sent by the client to ensure the security of the data key in the data interaction token, and performs consistency verification on the business data packet based on the data key. After the consistency verification passes, the business data packet is decrypted by the data key to obtain the target business data that has not been tampered with, thereby meeting the user's business needs and avoiding the technical problem in the prior art that when using a network application program interface to transmit data, data may be tampered with, thereby affecting the business needs of the client side. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0055] Figure 1 This is a flow chart of a first embodiment of a data exchange method based on a Web Restful API according to the present invention;
[0056] Figure 2 A control flow diagram of an embodiment of a data exchange method based on a Web Restful API according to the present invention;
[0057] Figure 3 A schematic diagram of the data format of a service data packet request and response according to an embodiment of a data exchange method based on a Web Restful API of the present invention;
[0058] Figure 4It is a structural block diagram of the first embodiment of the data exchange device based on Web Restful API of the present invention;
[0059] Figure 5 This is a flow chart of another embodiment of the data exchange method based on Web Restful API of the present invention;
[0060] Figure 6 It is a structural block diagram of another embodiment of the data exchange device based on Web Restful API of the present invention;
[0061] Figure 7 It is a structural diagram of a data exchange device based on a Web Restful API in a hardware operating environment involved in an embodiment of the present invention.
[0062] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0063] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0064] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0065] Based on this, the embodiment of the present invention provides a data exchange method based on Web Restful API, referring to Figure 1 and Figure 2 , Figure 1 This is a flow chart of a first embodiment of a data exchange method based on Web Restful API of the present invention. Figure 2 The figure is a control flow diagram of the data exchange method based on Web Restful API in this embodiment.
[0066] In this embodiment, the data exchange method based on Web Restful API includes:
[0067] Step S10: In response to a data interaction request initiated by the client, a service data packet and a data interaction token are received.
[0068] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a server, etc. The following takes the server as an example to illustrate this embodiment and the following embodiments.
[0069] In this embodiment, the server refers to a server platform that can provide network services or functions, such as APP programs, website programs, and applications, etc. This embodiment does not impose specific restrictions on this.
[0070] The data exchange request initiated by the client may carry the data stream, data packet or data message of the business process that the client needs to execute. Figure 3 , Figure 3 This is a schematic diagram of the data format of the service data packet request and response in this embodiment. The data format of the service data packet is qid=UUID&api=apiname_v001&data=jsondata&sign=data exchange based on Web Restful API x&key=123&stamp=123
[0071] jsondata is the original data encrypted by the SM4 encryption algorithm and converted into a hexadecimal string to ensure the confidentiality of the data; sign is the data (jsondata+stamp+keySecret, where keySecret is obtained from JWT) produced by the SM3 cryptographic hash algorithm to generate a 64-byte message digest to ensure the tamper-proof nature of the data; the security of the request is ensured by the timestamp and request ID.
[0072] Furthermore, after receiving the service data packet, the method further includes:
[0073] Decapsulating the service data packet to obtain service data in a preset format;
[0074] Extracting timestamp data from the business data;
[0075] Calculate the time difference between the timestamp data and the current time;
[0076] When the time difference is less than or equal to a preset duration, a step of verifying the legitimacy of the data interaction token is performed.
[0077] In a specific implementation, the decapsulation of the service data packet may be based on the decapsulation of the protocol stack, or may be other methods that can implement the decapsulation of the data packet, which is not specifically limited in this embodiment.
[0078] It can be understood that the preset duration can be set to 5s, that is, if the time difference between the timestamp data and the current moment is greater than 5 seconds, an error will be directly reported, and an error code and error message will be returned. If it is less than or equal to 5 seconds, the step of verifying the legitimacy of the data interaction token will be executed. By performing time difference detection on the timestamp of the business data packet, it is mainly to improve the timeliness of data packet interaction, reduce the interaction of invalid data packets, and improve the data processing efficiency of the network program interface.
[0079] Furthermore, after decapsulating the service data packet to obtain service data in a preset format, the method further includes:
[0080] Extracting a request identifier from the business;
[0081] Performing duplication detection on the request identifier;
[0082] If the request identifier exists repeatedly, a target error code is generated;
[0083] An exception response is generated according to the target error code, and the exception response is fed back to the client.
[0084] In the specific implementation, the request identifier is extracted from the request data, that is, the data of the qid field (request ID in uuid format) is extracted, and compared to see whether it already exists in the application server cache. If it does, an error code (6001) and an exception response are returned, and the exception response is fed back to the client.
[0085] Step S20: When the legitimacy verification of the data interaction token passes, extracting the data key in the data interaction token.
[0086] It should be noted that the validity check of the data interaction token may be performed by comparing the data format of the data interaction token or a data key stored in a database within the server.
[0087] Step S30: performing consistency verification on the service data packet based on the data key.
[0088] Since the client adjusts the data format of the business data packet during the data transmission process, and in order to prevent tampering, the business data to be executed is encrypted at least once, in order to improve the security of the transmitted data, this embodiment can perform consistency verification on the business data packet, that is, verifying the consistency of the message digest in the business data packet and the consistency of the plaintext data of the business data to be executed.
[0089] Further, the consistency verification of the service data packet based on the data key includes:
[0090] Extracting carrier data, timestamp data and service message summary from the service data packet;
[0091] Generate a target character string according to the data key, the carrier data and the timestamp data by using a preset connection rule;
[0092] Encrypting the target character string by a first encryption method to obtain a target message digest;
[0093] The target message digest and the service message digest are compared to perform consistency verification.
[0094] It is understood that carrier data refers to Figure 3 The business data in the format corresponding to data in the data, generating the target string through the preset connection rule according to the data key, the carrier data and the timestamp data refers to the connection rule for string connection of carrier data data+timestamp stamp+data key key.
[0095] The first encryption method can be to use the national secret SM3 algorithm to encrypt the target character string and obtain the target message digest. Since the service data packet stores the message digest Sign that has been combined and encrypted by the client, the target message digest obtained by the server combination encryption is compared with the original message digest obtained by the client combination encryption to determine whether the data transmission process has been tampered with.
[0096] Step S40: When the consistency verification is passed, the business data packet is decrypted according to the data key to obtain the target business data.
[0097] Decrypting the service data packet according to the data key means using the data in the key field as the key to decrypt the data in the data carrier field data using the national secret SM4 algorithm to obtain the original plaintext data. If the decryption fails, an error code and error message are directly returned; if the decryption succeeds, the business process corresponding to the target business data is executed.
[0098] Step S50: Execute the business process corresponding to the target business data.
[0099] Different target business data correspond to different business processes. For example, for business data corresponding to information query, it is only necessary to split the keywords in the business data and obtain the corresponding search query results.
[0100] Furthermore, the data exchange method based on Web Restful API also includes:
[0101] In response to a username and password verification request initiated by a user terminal, when the verification passes, a response token in a preset format is sent to the client;
[0102] The response token at least includes a data key, and the data key corresponds to the user name.
[0103] In a specific implementation, in order to improve the data interaction and security between the client and the server through the network program interface, the client's username and password can be verified before data transmission to improve the security of the client and be traceable when problems occur.
[0104] When the client initiates a data exchange request, it first sends the username and password data to the server of the security service platform. After verification, the server of the security service platform obtains a response token in the JWT format. The response token includes the user ID and the data key KEY, so that the client can subsequently combine the business data, obtain the message digest, and encrypt the business data to improve the security of data transmission.
[0105] This embodiment verifies the legitimacy of the data interaction token sent by the client to ensure the security of the data key in the data interaction token, and verifies the consistency of the business data packet based on the data key. After the consistency verification is passed, the business data packet is decrypted using the data key to obtain the target business data that has not been tampered with, thereby meeting the user's business needs and avoiding the technical problem in the prior art that when using a network application program interface to transmit data, data may be tampered with, thereby affecting the business needs of the client side.
[0106] This application also provides a data exchange device based on Web Restful API, please refer to Figure 4 , the data exchange device based on Web Restful API includes:
[0107] The receiving module 10 is used to receive a service data packet and a data interaction token in response to a data interaction request initiated by a client.
[0108] The extraction module 20 is used to extract the data key in the data interaction token when the legitimacy check of the data interaction token passes.
[0109] The verification module 30 is used to verify the consistency of the service data packet based on the data key.
[0110] The decryption module is used to decrypt the service data packet 40 according to the data key to obtain target service data when the consistency verification passes.
[0111] The execution module 50 is used to execute the business process corresponding to the target business data.
[0112] This embodiment verifies the legitimacy of the data interaction token sent by the client to ensure the security of the data key in the data interaction token, and verifies the consistency of the business data packet based on the data key. After the consistency verification is passed, the business data packet is decrypted using the data key to obtain the target business data that has not been tampered with, thereby meeting the user's business needs and avoiding the technical problem in the prior art that when using a network application program interface to transmit data, data may be tampered with, thereby affecting the business needs of the client side.
[0113] In one embodiment, the verification module 30 is also used to extract the carrier data, timestamp data and business message digest in the business data packet; generate a target character string according to the data key, the carrier data and the timestamp data through a preset connection rule; encrypt the target character string through a first encryption method to obtain a target message digest; compare the target message digest with the business message digest to perform consistency verification.
[0114] In one embodiment, the receiving module 10 is also used to decapsulate the business data to obtain business data in a preset format; extract timestamp data in the business data; calculate the time difference between the timestamp data and the current moment; and when the time difference is less than or equal to a preset duration, perform a step of verifying the legitimacy of the data interaction token.
[0115] In one embodiment, the receiving module 10 is also used to extract the request identifier in the business; perform duplication detection on the request identifier; if the request identifier exists repeatedly, generate a target error code; generate an exception response according to the target error code, and feed back the exception response to the client.
[0116] In one embodiment, the execution module 50 is also used to respond to a username and password verification request initiated by a user terminal, and when the verification passes, send a response token in a preset format to the client; wherein the response token includes at least a data key, and the data key corresponds to the username.
[0117] Based on this, the embodiment of the present invention provides a data exchange method based on Web Restful API, referring to Figure 5 , Figure 5 The figure is a control flow diagram of the data exchange method based on Web Restful API in this embodiment.
[0118] In this embodiment, the data exchange method based on Web Restful API includes:
[0119] Step S100: Respond to a response token in a preset format sent by the server.
[0120] Step S200: extracting the data key and timestamp data in the response token, wherein the timestamp data is the current moment data.
[0121] Step S300: encrypt the service data to be executed by using a second encryption method to obtain carrier data.
[0122] Step S400: Generate a target character string according to the data key, the carrier data and the timestamp data by using a preset connection rule.
[0123] Step S500: encrypt the target character string using a first encryption method to obtain a message digest.
[0124] Step S600: Assemble the message digest, carrier data and timestamp data according to a preset data format to obtain a service data packet.
[0125] Step S700: Send the service data packet to a server to execute the service process corresponding to the target service data.
[0126] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, a user terminal and a client that can realize the above functions. The following takes the client as an example to illustrate this embodiment and the following embodiments.
[0127] It should be noted that when the client initiates a data exchange request, it first sends the username and password data to the server of the security service platform. After verification, the server of the security service platform obtains a response token in the JWT format. The response token includes the user ID and the data key KEY, so that the client can subsequently combine the business data, obtain the message digest, and encrypt the business data to improve the security of data transmission.
[0128] In the specific implementation, the data key KEY in the response token token is used to perform SM4 encryption on the business data to be executed, and stored in the carrier data data field, and then the target string of the carrier data data + timestamp stamp + data key key is re-encrypted using SM3 to generate the corresponding message digest, which is stored in the message digest sign field. After the data is encapsulated, a data exchange request is initiated to the business application Web API service so that the server of the security service platform executes the business process corresponding to the target business data.
[0129] This embodiment responds to a response token in a preset format sent by a server; extracts a data key and timestamp data in the response token, wherein the timestamp data is current time data; encrypts the business data to be executed by a second encryption method to obtain carrier data; generates a target character string according to the data key, the carrier data and the timestamp data by a preset connection rule; encrypts the target character string by a first encryption method to obtain a message digest; assembles the message digest, carrier data and timestamp data according to a preset data format to obtain a business data packet; sends the business data packet to a server to execute the business process corresponding to the target business data. By encrypting the business data to be executed on the client side, the security of data during transmission through the Web Restful API is improved, and the risk of tampering is reduced.
[0130] This application also provides a data exchange device based on Web Restful API, please refer to Figure 6 , the data exchange device based on Web Restful API includes:
[0131] The data extraction module 100 is used to extract the data key and timestamp data in the response token in response to the response token in a preset format sent by the server, and the timestamp data is the current time data.
[0132] The data encryption module 200 is used to encrypt the service data to be executed by using a second encryption method to obtain carrier data.
[0133] The character combination module 300 is used to generate a target character string according to the data key, the carrier data and the timestamp data through a preset connection rule.
[0134] The digest generation module 400 is used to encrypt the target character string by a first encryption method to obtain a message digest.
[0135] The data assembly module 500 is used to assemble the message digest, carrier data and timestamp data according to a preset data format to obtain a service data packet.
[0136] The data sending module 600 sends the service data packet to the server to execute the service process corresponding to the target service data.
[0137] This embodiment responds to a response token in a preset format sent by a server; extracts a data key and timestamp data in the response token, wherein the timestamp data is current time data; encrypts the business data to be executed by a second encryption method to obtain carrier data; generates a target character string according to the data key, the carrier data and the timestamp data by a preset connection rule; encrypts the target character string by a first encryption method to obtain a message digest; assembles the message digest, carrier data and timestamp data according to a preset data format to obtain a business data packet; sends the business data packet to a server to execute the business process corresponding to the target business data. By encrypting the business data to be executed on the client side, the security of data during transmission through the Web Restful API is improved, and the risk of tampering is reduced.
[0138] The present application provides a data exchange device based on Web Restful API, and the data exchange device based on Web Restful API includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the data exchange method based on Web Restful API in the above-mentioned embodiment one.
[0139] Reference below Figure 7 , which shows a schematic diagram of the structure of a data exchange device based on Web Restful API suitable for implementing an embodiment of the present application. The data exchange device based on Web Restful API in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The data exchange device based on Web Restful API shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0140] like Figure 7As shown, the data exchange device based on Web Restful API may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM: Read Only Memory) 1002 or the program loaded from the storage device 1003 to the random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the data exchange device based on Web Restful API are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the data exchange device based on the Web Restful API to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a data exchange device based on the Web Restful API with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have alternatively.
[0141] 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 a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0142] The data exchange device based on Web Restful API provided by the present application adopts the data exchange method based on Web Restful API in the above embodiment, which can solve the technical problem of data exchange based on Web Restful API. Compared with the prior art, the beneficial effects of the data exchange device based on Web Restful API provided by the present application are the same as the beneficial effects of the data exchange method based on Web Restful API provided by the above embodiment, and other technical features in the data exchange device based on Web Restful API are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0143] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0144] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0145] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the data exchange method based on Web Restful API in the above-mentioned embodiment.
[0146] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, 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 this embodiment, the 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, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0147] The computer-readable storage medium may be included in a data exchange device based on the Web Restful API; or may exist independently without being assembled into a data exchange device based on the Web Restful API.
[0148] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the data exchange device based on the Web Restful API, the data exchange device based on the Web Restful API performs data exchange based on the Web Restful API.
[0149] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may 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 may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0150] 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 square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the 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 square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square 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 square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / 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.
[0151] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0152] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned data exchange method based on Web Restful API, and can solve the technical problems of data exchange based on Web Restful API. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the data exchange method based on Web Restful API provided by the above-mentioned embodiment, and will not be repeated here.
[0153] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the data exchange method based on Web Restful API as described above.
[0154] The computer program product provided by this application can solve the technical problem of data exchange based on Web Restful API. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the data exchange method based on Web Restful API provided by the above embodiment, which will not be repeated here.
[0155] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A data exchange method based on Web Restful API, characterized in that: The data exchange method based on Web Restful API is applied to a server, and the data exchange method based on Web Restful API includes: In response to a data interaction request initiated by a client, receiving a service data packet and a data interaction token; When the legitimacy check of the data interaction token passes, extracting the data key in the data interaction token; Performing consistency verification on the service data packet based on the data key; When the consistency verification passes, the service data packet is decrypted according to the data key to obtain the target service data; Execute the business process corresponding to the target business data.
2. The method according to claim 1, characterized in that The performing consistency verification on the service data packet based on the data key includes: Extracting carrier data, timestamp data and service message summary from the service data packet; Generate a target character string according to the data key, the carrier data and the timestamp data by using a preset connection rule; Encrypting the target character string by a first encryption method to obtain a target message digest; The target message digest and the service message digest are compared to perform consistency verification.
3. The method according to claim 1, characterized in that After receiving the service data packet, the method further includes: Decapsulating the service data packet to obtain service data in a preset format; Extracting timestamp data from the business data; Calculate the time difference between the timestamp data and the current time; When the time difference is less than or equal to a preset duration, a step of verifying the legitimacy of the data interaction token is performed.
4. The method according to claim 3, characterized in that After decapsulating the service data packet to obtain the service data in a preset format, the method further includes: Extracting a request identifier from the business; Performing duplication detection on the request identifier; If the request identifier exists repeatedly, a target error code is generated; An exception response is generated according to the target error code, and the exception response is fed back to the client.
5. The method according to any one of claims 1 to 4, characterized in that The data exchange method based on Web Restful API also includes: In response to a username and password verification request initiated by a user terminal, when the verification passes, a response token in a preset format is sent to the client; The response token at least includes a data key, and the data key corresponds to the user name.
6. A data exchange device based on Web Restful API, characterized in that: The data exchange device based on Web Restful API is applied to the data exchange method based on Web Restful API as described in any one of claims 1 to 5 above, and the data exchange device based on Web Restful API includes: A receiving module, used to respond to a data interaction request initiated by a client and receive a service data packet and a data interaction token; An extraction module, used to extract the data key in the data interaction token when the legitimacy verification of the data interaction token passes; A verification module, used to verify the consistency of the service data packet based on the data key; A decryption module, used to decrypt the service data packet according to the data key to obtain target service data when the consistency verification passes; An execution module is used to execute the business process corresponding to the target business data.
7. A data exchange method based on Web Restful API, characterized in that: The data exchange method based on Web Restful API is applied to the client, and the data exchange method based on Web Restful API includes: In response to a response token in a preset format sent by the server, extract a data key and timestamp data in the response token, wherein the timestamp data is current time data; Encrypt the service data to be executed by using a second encryption method to obtain carrier data; Generate a target character string according to the data key, the carrier data and the timestamp data by using a preset connection rule; Encrypt the target character string using a first encryption method to obtain a message digest; Assembling the message digest, carrier data and timestamp data according to a preset data format to obtain a service data packet; The business data packet is sent to a server to execute the business process corresponding to the target business data.
8. A data exchange device based on Web Restful API, characterized in that: The data exchange device based on Web Restful API is applied to the data exchange method based on Web Restful API as described in any one of the above claims 7. The data exchange device based on Web Restful API includes: A data extraction module, configured to extract a data key and a timestamp data in a response token in a preset format sent by a server, wherein the timestamp data is data at a current moment; A data encryption module, used for encrypting the service data to be executed by a second encryption method to obtain carrier data; A character combination module, used to generate a target character string according to the data key, the carrier data and the timestamp data through a preset connection rule; A digest generation module, used for encrypting the target character string by a first encryption method to obtain a message digest; A data assembly module, used to assemble the message digest, carrier data and timestamp data according to a preset data format to obtain a service data packet; The data sending module sends the business data packet to the server to execute the business process corresponding to the target business data.
9. A data exchange device based on Web Restful API, characterized in that: The data exchange device based on Web Restful API includes: a memory, a processor, and a data exchange program based on Web Restful API stored in the memory and executable on the processor, wherein the data exchange program based on Web Restful API is configured to implement the steps of the data exchange method based on Web Restful API as described in any one of claims 1 to 5 or claim 7.
10. A storage medium, characterized in that: The storage medium stores a data exchange program based on a Web Restful API, and when the data exchange program based on a Web Restful API is executed by a processor, the steps of the data exchange method based on a Web Restful API as described in any one of claims 1 to 5 or claim 7 are implemented.