Interface calling method, device, storage medium and electronic device

By encoded and transforming the parameter information multiple times during the interface call process, the first verification data that is difficult to crack is generated and the second verification data is generated at the receiving end for verification, the problem of poor security of interface call data in the prior art is solved, and higher data security and lower maintenance costs are achieved.

CN115712888BActive Publication Date: 2025-04-15CHINA TELECOM CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211234575.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-10
Publication Date
2025-04-15
Estimated Expiration
2042-10-10

AI Technical Summary

Technical Problem

In the prior art, data security in interface calling methods is poor and is easily forged, affecting the security of data.

Method used

The parameter information corresponding to the interface call request is determined in the first electronic device, and the data to be encrypted is determined based on the first character encoding table and parameter information. Then, the key data is determined based on the target information selected from the second character encoding table and parameter information, and the encrypted data is converted to obtain the first verification data. The interface call request and the first verification data are sent to the second electronic device, which generates the second verification data based on the interface call request, and determines the response result to the interface call request based on the first verification data and the second verification data.

Benefits of technology

It effectively reduces the risk of interfaces being illegally brute-forced, improves data security, and saves the work cost of maintaining interface security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115712888B_ABST
    Figure CN115712888B_ABST
Patent Text Reader

Abstract

The present invention provides an interface calling method, device, storage medium and electronic device, and the method applied to a first electronic device includes: determining parameter information corresponding to an interface calling request; determining data to be encrypted based on a first character encoding table and the parameter information; determining key data based on a second character encoding table and target information selected in the parameter information; converting the data to be encrypted based on the second character encoding table and the key data to obtain first verification data; sending the interface calling request and the first verification data to a second electronic device, so that the second electronic device generates second verification data based on the interface calling request; and determining a response result to the interface calling request based on the first verification data and the second verification data. The technical solution provided by the present invention verifies the legitimacy of the interface calling request through the first verification data and the second verification data, effectively ensuring the security of the data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information processing technology, and more specifically, to an interface calling method, device, storage medium and electronic device. Background Art

[0002] With the development of information society, interface calls between electronic devices are becoming more and more frequent. At present, when making an interface call, the electronic device as the requesting end sends an interface call request to the electronic device as the requested end, and the requested end responds to the interface call request. In this process, plain text data is generally used for transmission, which makes it more likely that the interface call request will be forged, seriously affecting the security of data. Summary of the invention

[0003] The present invention provides an interface calling method, a device, a storage medium and an electronic device to solve the technical problem of poor data security in the interface calling method in the prior art.

[0004] According to a first aspect of the present invention, there is provided an interface calling method, which is applied to a first electronic device and comprises:

[0005] Determine the parameter information corresponding to the interface call request;

[0006] Determining the data to be encrypted based on the first character encoding table and the parameter information;

[0007] Determining key data based on a second character encoding table and target information selected from the parameter information;

[0008] Based on the second character encoding table and the secret key data, convert the data to be encrypted to obtain first verification data;

[0009] The interface call request and the first verification data are sent to a second electronic device, so that the second electronic device generates second verification data based on the interface call request; and determines a response result to the interface call request based on the first verification data and the second verification data.

[0010] Optionally, the determining the data to be encrypted based on the first character encoding table and the parameter information includes:

[0011] Sorting the parameter information according to a preset rule to determine the sorted parameter information;

[0012] The data to be encrypted is determined based on the first character encoding table and the sorted parameter information.

[0013] Optionally, the parameter information includes at least one parameter name and a parameter value corresponding to each of the at least one parameter name, the preset rule includes a first preset rule and a second preset rule, and sorting the parameter information according to the preset rule to determine the sorted parameter information includes:

[0014] Determine a second character corresponding to a first character at a first target position in each of the parameter names in the first character code;

[0015] Based on the second character corresponding to the first target position in each of the parameter names and the first preset rule, sorting the parameter names and the parameter values ​​corresponding to each of the parameter names to determine the parameter information after the initial sorting;

[0016] The parameter information after the initial sorting is sorted according to the second preset rule to determine the sorted parameter information.

[0017] Optionally, the determining the data to be encrypted based on the first character encoding table and the sorted parameter information includes:

[0018] Performing character conversion on the sorted parameter information using the first character encoding table to determine converted parameter information;

[0019] The converted parameter information is concatenated with a timestamp corresponding to the interface call request to determine the data to be encrypted.

[0020] Optionally, converting the data to be encrypted based on the second character encoding table and the key data to obtain first verification data includes:

[0021] Determining the number of keys corresponding to the key data;

[0022] Grouping the data to be encrypted according to the number of secret keys to obtain at least one group to be encrypted;

[0023] Determine the calculation result of each of the to-be-encrypted groups and the secret key data;

[0024] The calculation result is character-converted using the second character encoding table to obtain the first verification data.

[0025] Optionally, determining the key data based on the second character encoding table and the target information selected from the parameter information includes:

[0026] Selecting the parameter name at the second target position in the parameter information as the target information;

[0027] The key data is determined based on the second character encoding table and the target information.

[0028] According to a second aspect of the present invention, there is provided an interface calling method, which is applied to a second electronic device and comprises:

[0029] Receiving an interface calling request and first verification data sent by a first electronic device; the first verification data is generated by the first electronic device based on the interface calling request;

[0030] Determine parameter information corresponding to the interface call request;

[0031] Determining the data to be encrypted based on the first character encoding table and the parameter information;

[0032] Determining key data based on a second character encoding table and target information selected from the parameter information;

[0033] Based on the second character encoding table and the secret key data, convert the data to be encrypted to obtain second verification data;

[0034] Based on the first verification data and the second verification data, a response result of the interface call request is determined.

[0035] According to a third aspect of the present invention, there is provided an interface calling device, which is arranged in a first electronic device and includes:

[0036] A first parameter determination module, used to determine parameter information corresponding to the interface call request;

[0037] A first data determination module, used to determine the data to be encrypted based on the first character encoding table and the parameter information;

[0038] A first key determination module, configured to determine key data based on a second character encoding table and target information selected from the parameter information;

[0039] A first conversion processing module, used for converting the data to be encrypted based on the second character encoding table and the secret key data to obtain first verification data;

[0040] A data sending processing module is used to send the interface call request and the first verification data to a second electronic device, so that the second electronic device generates second verification data based on the interface call request; and determines a response result to the interface call request based on the first verification data and the second verification data.

[0041] According to a fourth aspect of the present invention, there is provided an interface calling device, which is arranged in a second electronic device and includes:

[0042] A data receiving and processing module, configured to receive an interface calling request and first verification data sent by a first electronic device; the first verification data is generated by the first electronic device based on the interface calling request;

[0043] A second parameter determination module, used to determine parameter information corresponding to the interface call request;

[0044] A second data determination module, used to determine the data to be encrypted based on the first character encoding table and the parameter information;

[0045] A second key determination module, used to determine the key data based on a second character encoding table and target information selected from the parameter information;

[0046] A second conversion processing module, used for converting the data to be encrypted based on the second character encoding table and the secret key data to obtain second verification data;

[0047] A data verification processing module is used to determine a response result of the interface call request based on the first verification data and the second verification data.

[0048] According to a fifth aspect of the present invention, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and the computer program is used to execute the above-mentioned interface calling method.

[0049] According to a sixth aspect of the present invention, there is provided an electronic device, the electronic device comprising:

[0050] processor;

[0051] a memory for storing instructions executable by the processor;

[0052] The processor is used to read the executable instructions from the memory and execute the instructions to implement the above-mentioned interface calling method.

[0053] Compared with the prior art, the interface calling method, device, storage medium and electronic device provided by the present invention have at least the following beneficial effects:

[0054] The technical solution of the present invention determines the parameter information corresponding to the interface call request through the first electronic device, and then determines the data to be encrypted according to the first character encoding table and the parameter information, and determines the key data according to the target information selected from the second character encoding table and the parameter information. Further, according to the second character encoding table and the key data, the data to be encrypted is converted to obtain the first verification data. In other words, the first verification data is obtained by converting the parameter information multiple times, which is not easy to be cracked, effectively reducing the risk of the interface being illegally attacked by violent attacks, and saving the work cost of maintaining the security of the interface. After the first electronic device determines the first verification data, the interface call request and the first verification data are sent to the second electronic device. After the second electronic device receives the interface call request, it generates the second verification data based on the interface call request, and determines the response result to the interface call request according to the first verification data and the second verification data. In the technical solution provided by the present invention, when a first electronic device sends an interface call request to a second electronic device, it not only sends parameter information corresponding to the interface call request, but also sends first verification data, so that the second electronic device uses the second verification data to verify the first verification data, accurately identifies forged interface call requests, and ensures data security; and through effective identification of forged interface call requests, saves resources of the second electronic device and improves the processing efficiency of the second electronic device. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] In order to more clearly illustrate the technical solution of the present invention, the drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0056] Figure 1 is a schematic diagram of an application environment of an interface calling method provided by an exemplary embodiment of the present invention;

[0057] Figure 2 The following is a flow diagram of an interface calling method provided by an exemplary embodiment of the present invention. Figure 1 ;

[0058] Figure 3 The following is a flow diagram of an interface calling method provided by an exemplary embodiment of the present invention. Figure 2 ;

[0059] Figure 4 The following is a flow diagram of an interface calling method provided by an exemplary embodiment of the present invention. Figure 3 ;

[0060] Figure 5 The structure of the interface calling device provided by an exemplary embodiment of the present invention is shown in FIG. Figure 1;

[0061] Figure 6 The structure of the interface calling device provided by an exemplary embodiment of the present invention is shown in FIG. Figure 2 ;

[0062] Figure 7 is a structural diagram of an electronic device provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION

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

[0064] Exemplary Methods

[0065] See also Figure 1 , which is a schematic diagram of an application environment of an interface calling method according to an exemplary embodiment, the application environment may include a first electronic device 11 and a second electronic device 12, and the first electronic device 11 and the second electronic device 12 may be connected via a wired network or a wireless network.

[0066] The first electronic device 11 may be a terminal, which may include but is not limited to electronic devices such as smart phones, desktop computers, tablet computers, and laptop computers. Various applications or applets may be installed on the first electronic device 11, and interface calls may be initiated to the second electronic device 12 through various applications and applets. Optionally, the operating system running on the first electronic device 11 may include but is not limited to Android, IOS, Linux, Windows, etc. Of course, the first electronic device 11 may also be a server, which also needs to call the interface provided by the second electronic device 12 and initiate an interface call request to the second electronic device 12, wherein the first electronic device 11 and the second electronic device 12 may be the same or different servers.

[0067] The second electronic device 12 is an interface server, which is used to respond to the interface call request of the first electronic device 11. Specifically, the second electronic device 12 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Exemplarily, the second electronic device 12 provides an API (Application Programming Interface) for the first electronic device 11, which can be called by applications installed on the first electronic device 11.

[0068] Figure 2 1 is a flow chart of an interface calling method provided by an exemplary embodiment of the present invention. The method is applied to a first electronic device and at least includes the following steps:

[0069] Step 21, determining parameter information corresponding to the interface call request.

[0070] The parameter information is the data actually carried by the interface call request generated by the first electronic device.

[0071] In this step, the first electronic device is the requesting end, and the second electronic device is the requested end. When the first electronic device needs to call the interface of the second electronic device, it sends an interface calling request to the second electronic device.

[0072] Specifically, the first electronic device generates an interface call request, and then determines the parameter information carried by the interface call request; of course, the parameter information required for generating the interface call request can also be determined first, and then the interface call request is generated based on the parameter information. It should be noted that in this embodiment, there is no specific restriction on the order of determining the parameter information and generating the interface call request, and the determined parameter information can be the data actually carried by the interface call request.

[0073] For example, Figure 3 31 in the figure exemplarily shows a parameter information, and the specific content of the parameter information is: UserName=admin123&Number=2022030412&departmanetld=1101.

[0074] Among them, UserName represents the user name, which is a parameter name in the parameter information, and admin123 is the parameter value of the parameter name user name; Number represents the number information, which is another parameter name in the parameter information, and 2022030412 is the parameter value of the parameter name number information; departmanetld represents the identification information, which is another parameter name in the parameter information, and 1101 is the parameter value of the parameter name identification information.

[0075] Step 22: Determine the data to be encrypted based on the first character encoding table and the parameter information.

[0076] The first character encoding table is a pre-set encoding comparison table for character conversion. The first character encoding table can be written by the user, or a known encoding comparison table, such as an ASCII code comparison table, a Base64 encoding comparison table, etc., can be selected.

[0077] In one embodiment, the parameter information is character-converted using a first character encoding table, and the converted data is determined as the data to be encrypted.

[0078] In one embodiment, the step 22 includes:

[0079] Step 221, sorting the parameter information according to a preset rule to determine sorted parameter information.

[0080] Among them, the preset rules are pre-set sorting rules. The parameter information is sorted according to the preset rules, and the content of the parameter information is shuffled. The sorted parameter information obtained is significantly different from the original parameter information, which increases the difficulty of cracking and is conducive to ensuring data security.

[0081] In a possible implementation, the preset rule may be in KV format, where K represents the parameter name, V represents the parameter value, and the first character in each K in the parameter information that is at the first target position is sorted from small to large. Exemplarily, the order of lowercase letters is set to be smaller than the order of uppercase letters, and the order of numbers is set to be smaller than the order of lowercase letters. Among them, the KV format is to use the parameter name and the parameter value corresponding to the parameter name as a sorting unit. For the parameter information UserName=admin123&Number=2022030412&departmanetld=1101, there are three sorting units in KV format, namely UserName=admin123, Number=2022030412, and departmanetld=1101. When sorting, the sorting unit moves as a whole. The first target position can be any specified position in the parameter name, such as the first, second, third, etc.

[0082] For example, when the first target position is the first position, it is determined that the characters in the first target position of the three parameter names in the parameter information UserName=admin123&Number=2022030412&departmanetld=1101 are U, N, and d, respectively. They are sorted in KV form from small to large according to U, N, and d, and the sorted parameter information obtained can be departmanetld=1101&Number=2022030412&UserName=admin123.

[0083] In a possible implementation, the preset rule may be to sort the first characters in the first target position of each V in the parameter information in KV form from small to large. Exemplarily, the order of lowercase letters is set to be smaller than that of uppercase letters, and the order of numbers is set to be smaller than that of lowercase letters.

[0084] For example, when the first target position is the first position, it is determined that the characters at the first target position in the three parameter values ​​in the parameter information UserName=admin123&Number=2022030412&departmanetld=1101 are a, 2, and 1, respectively. They are sorted in KV form from small to large according to a, 2, and 1. The sorted parameter information can be departmanetld=1101&Number=2022030412&UserName=admin123.

[0085] In a possible implementation, the parameter information includes at least one parameter name and a parameter value corresponding to each of the at least one parameter name, the preset rule includes a first preset rule and a second preset rule, and step 221 includes:

[0086] Step 2211, determining the second character corresponding to the first character at the first target position in each of the parameter names in the first character code.

[0087] The first target position may be any specified position in the parameter name, such as the first position, the second position, the third position, etc. The first character at the first target position in each parameter name is determined, and then the second character corresponding to the first character is searched in the first character encoding table, that is, the second character is the result of converting the first character according to the first character encoding table.

[0088] For example, the first character encoding table is a decimal ASCII code comparison table, the first target position is the first position, and the first characters in the first position of the three parameter names in UserName=admin123&Number=2022030412&departmanetld=1101 are U, N, and d, respectively. The second character corresponding to U in the decimal ASCII code comparison table is 85, the second character corresponding to N in the decimal ASCII code comparison table is 78, and the second character corresponding to d in the decimal ASCII code comparison table is 100.

[0089] Step 2212: sort the parameter names and the parameter values ​​corresponding to the parameter names based on the second character corresponding to the first target position in each parameter name and the first preset rule to determine the parameter information after the initial sorting.

[0090] In this step, the first preset rule is a part of the preset rules, that is, the first preset rule is also a preset sorting rule. Exemplarily, the first preset rule can be in KV format, sorting from small to large according to the order of the second character; or the first preset rule can be in KV format, sorting from large to large according to the order of the second character.

[0091] For example, the first preset rule is to sort the parameter information in KV format according to the order of the second character from small to large:

[0092] UserName=admin123&Number=2022030412&departmanetld=1101, the second characters are 85, 78 and 100 respectively, and the parameters are sorted from small to large according to the second characters to obtain the parameter information after the initial sorting, as shown in the following figure. Figure 3 The decimal ASCII codes shown in 32 are sorted from small to large: Number=2022030412&UserName=admin123&departmanetld=1101.

[0093] Step 2213: sort the parameter information after the initial sorting according to the second preset rule to determine the sorted parameter information.

[0094] In this step, the second preset rule is a part of the preset rules, that is, the second preset rule is also a pre-set sorting rule. The parameter information after the initial sorting is sorted again using the second preset rule. By re-sorting, the data inside the parameter information is disrupted, which increases the difficulty of cracking and is conducive to ensuring the security of the data.

[0095] Exemplarily, the second preset rule may be to sort in the form of KVKKVVKKKVVV. For the parameter information after the initial sorting of Number=2022030412&UserName=admin123&departmanetld=1101, after sorting in the form of KVKKVVKKKVVV, the sorted parameter information obtained is as follows: Figure 3 The decimal ASCII code string to be converted shown in 33 is: Number2022030412UserNamedepartmanetldadmin1231101.

[0096] Exemplarily, the second preset rule may be to sort in the form of KKVVKVKKVV. For the parameter information after the initial sorting of Number=2022030412&UserName=admin123&departmanetld=1101, after sorting in accordance with KKVVKVKKVV, the sorted parameter information obtained is: NumberUserName2022030412admin123departmanetld1101.

[0097] Exemplarily, the second preset rule may be to sort in the form of KKKVVVKKVVKV. For the parameter information after the initial sorting of Number=2022030412&UserName=admin123&departmanetld=1101, after sorting in accordance with KKKVVVKKVVKV, the sorted parameter information obtained is: NumberUserNamedepartmanetld2022030412admin1231101.

[0098] It should be noted that different second preset rules are obtained by performing different combinations of K and V. Therefore, in this embodiment, no specific limitation is imposed on the second preset rule, and the user may set it according to actual needs.

[0099] Step 222: Determine the data to be encrypted based on the first character encoding table and the sorted parameter information.

[0100] In one embodiment, the sorted parameter information is converted into characters using the first character encoding table to obtain data to be encrypted. The data to be encrypted is difficult to crack, which is conducive to ensuring data security.

[0101] In one embodiment, the step 222 includes:

[0102] Step 2221: Use the first character encoding table to perform character conversion on the sorted parameter information to determine the converted parameter information.

[0103] Step 2222: Concatenate the converted parameter information with the timestamp corresponding to the interface call request to determine the data to be encrypted.

[0104] In this embodiment, the first character encoding table is used to perform character conversion on the sorted parameter information, the converted parameter information is determined, and the timestamp corresponding to the interface call request is determined, the converted parameter information is concatenated with the timestamp corresponding to the interface call request, and data conversion is further increased to determine the encrypted data that is more difficult to crack.

[0105] Specifically, the splicing position and splicing order of the timestamp are determined. The splicing position can be any specified position in the converted parameter information, such as before the converted parameter information, or after the converted parameter information, or between two adjacent characters specified in the converted parameter information. The splicing order can be either forward splicing or reverse splicing.

[0106] For example, Figure 3 The string of decimal ASCII code to be converted shown in 33: Number2022030412UserNamedepartmanetldadmin1231101 is converted according to the decimal ASCII code comparison table. The generated converted parameter information is as follows Figure 3 As shown in 34: 781171099810111450485050485148524950851151011147897109101100101112971141161099711010111673100971001091051104. The timestamp of the outbound interface call request is determined to be 20220427182430, which is 18:24:30 on April 27, 2022. The reverse order of the timestamp, 03428172402202, is concatenated before the converted parameter information to obtain the following: Figure 3 The character string to be encrypted shown in 35 is the data to be encrypted in this step: 03428172402202781171099810111450485050485148524950851151011147897109101100101112971141161099711010111673100971001091051104.

[0107] Step 23, determining key data based on the second character encoding table and the target information selected from the parameter information.

[0108] In this step, the target information is selected from the parameter information, and the key data is determined according to the second character encoding table and the target information. The key data is determined according to the parameter information of the interface call parameters. Different parameter information corresponds to different key data, which avoids the possible leakage of keys caused by pre-determined keys, and also avoids key data of a single form, effectively ensuring the security of the data.

[0109] In one embodiment, the step 23 includes:

[0110] Step 231: Select the parameter name at the second target position in the parameter information as the target information.

[0111] Step 232: Determine the key data based on the second character encoding table and the target information.

[0112] Among them, the second character encoding table is a pre-set encoding comparison table for character conversion. The first character encoding table can be written by the user, or a known character conversion table can be selected. Any specified position in the second target position parameter information, the second target position is the order of parameter names, such as the first parameter name, the second parameter name, the third parameter name, etc. After the parameter name at the second target position in the parameter information is determined as the target information, the target information is converted into characters using the second character encoding table to determine the key data. The key data is flexible and diverse, which is conducive to ensuring the security of the data.

[0113] For example, the second character encoding table is a self-defined password disk, as shown below:

[0114] A B C D E F G H I G K L M 0 1 2 3 4 5 6 7 8 9 10 11 12 N O P Q R S T U V W X Y Z 13 14 15 16 17 18 19 20 21 22 23 24 25

[0115] If the second target position is the first position, it is determined that the parameter name in the first position in the parameter information is Username, that is, Username is the target information, and the format of the target information is adjusted according to the second character encoding table to determine the adjusted target information, such as adjusting lowercase letters to uppercase letters, and the adjusted target information obtained is USERNAME. The second character encoding table is used to convert the obtained adjusted target information, that is, USERNAME is converted to obtain the secret key data K(20,18,4,17,13,0,12,4).

[0116] Step 24: based on the second character encoding table and the secret key data, convert the data to be encrypted to obtain first verification data.

[0117] In this step, the encrypted data is converted using the second character encoding table and key data to obtain first verification data. The first verification data is obtained after the parameter information has changed multiple times. The first verification data is less likely to be cracked, which is beneficial to ensuring data security.

[0118] In one embodiment, the step 24 includes:

[0119] Step 241, determining the number of keys corresponding to the key data.

[0120] In this step, the secret keys in the secret key data are counted to determine the number of secret keys. For example, for the secret key data K(20,18,4,17,13,0,12,4), the number of secret keys is determined to be 8.

[0121] Step 242: group the data to be encrypted according to the number of keys to obtain at least one group to be encrypted.

[0122] Specifically, data of adjacent secret key quantities in the data to be encrypted are grouped into one group, thereby obtaining at least one group to be encrypted, and the number of data in each group to be encrypted is the same as the number of secret keys.

[0123] For example, for the data to be encrypted as shown below:

[0124] 03428172402202781171099810111450485050485148524950851151011147897109101100101112971141161099711010111673100971001091051104. The encrypted data is grouped according to the number of secret keys, that is, every 8 adjacent data are a group, and the first group to be encrypted is 03428172, the second group to be encrypted is 40220278, the third group to be encrypted is 11710998, and so on.

[0125] Step 243, determining the calculation result of each of the to-be-encrypted groups and the key data.

[0126] In this step, the encryption operation is performed on each group to be encrypted using the secret key data, that is, the calculation result of each group to be encrypted and the secret key data is determined. Specifically, because the number of data in the group to be encrypted is the same as the number of secret keys in the secret key data, each secret key is used to encrypt the data with the same number of times in the group to be encrypted, and the calculation result of the group to be encrypted and the secret key data is obtained.

[0127] In a possible implementation, the calculation result of each of the to-be-encrypted groups and the key data is determined using the Virginia key principle.

[0128] Specifically, the encryption algorithm is expressed as: Enc k (m) = c;

[0129] Among them, Enc represents the encryption algorithm, k represents the secret key, m represents the plaintext input, and c represents the ciphertext output. That is to say, the encryption algorithm Enc takes the secret key k and the plaintext m as input and outputs the ciphertext c. The plaintext m belongs to P, P represents the plaintext space, which is a finite set of all possible plaintexts; the secret key k belongs to K, K represents the secret key space, which is a finite set of all possible secret keys k; the output c belongs to C, C represents the ciphertext space, which is a finite set of all possible ciphertexts, P=C=K=Z n 26 .

[0130] Furthermore, Enc k (m 1 ,m 2 ,...,m n )=(m 1 +k 1 ,m 2 +k 2 ,...,m n +k n );

[0131] Where m 1 Represents the first bit of data in each group to be encrypted, m 2 Represents the second bit of data in each group to be encrypted, m n Represents the nth bit of data in each group to be encrypted; k 1 Represents the first key in the key data, k 2 Represents the second key in the key data, k n Represents the nth key in the key data; m 1 +k 1 The ciphertext representing the first output is a calculation result, m 2 +k 2 The ciphertext representing the second output is a calculation result, m n +k n The ciphertext representing the nth output is a calculation result.

[0132] For example, the first group to be encrypted is 03428172, and the key data k is 20,18,4,17,13,0,12,4. Add the first bit of data 0 in the first group to be encrypted and the first bit of data 20 in the key data k to get 20. Add the second bit of data 3 in the first group to be encrypted and the second bit of data 18 in the key data k to get 21. And so on, the calculation result of the first group to be encrypted and the key data is: 2021819211196.

[0133] Step 244: Use the second character encoding table to perform character conversion on the calculation result to obtain the first verification data.

[0134] Specifically, the calculation results are converted into characters using the second character encoding table, and the first verification data is obtained according to the order of each calculation result in the data to be encrypted.

[0135] For example, the calculation result of the first group to be encrypted and the key data is converted into characters using the second character encoding table, that is, 20 is converted into U, 21 is converted into V, 8 is converted into I, 19 is converted into T, 21 is converted into V, 1 is converted into B, 19 is converted into T, and 6 is converted into G. Since the first group to be encrypted is the first part of the data to be encrypted, the first part of the first verification data, namely UVITVBTG, is obtained. The calculation result corresponding to each group to be encrypted is converted into characters using the second character encoding table to obtain the first verification data. The first verification data is a hash function generated according to the Virginia cipher principle. Figure 3 The character string to be encrypted shown in 35 is converted using the second character encoding table to generate Figure 3 The hash function described in 36 is the first verification data:

[0136] UVITVBTGYSGTNCTMVTLSNGVMVSFSOEREYAGRSAQMZTIZSCQNZSMWOBRFUTFSRHUNBTEAOANFUSFROBNGDZFSRBNKVSNAUBNEVSFSOGTHVSEAUBMEVSNSNFNFUW. In this embodiment, the generation method of the hash function is simple, the generated hash function is more secure, not easy to crack, and the security of the data is guaranteed.

[0137] Step 25, sending the interface call request and the first verification data to a second electronic device, so that the second electronic device generates second verification data based on the interface call request; and determines a response result to the interface call request based on the first verification data and the second verification data.

[0138] In this step, after the first electronic device generates an interface call request and determines the first verification data, the interface call request and the first verification data are sent to the second electronic device. After receiving the interface call request, the second electronic device generates second verification data based on the interface call request, verifies the first verification data using the second verification data, and determines a response result to the interface call request.

[0139] Specifically, the first electronic device and the second electronic device perform a protocol in advance, and determine the content of the protocol, that is, the way in which the first electronic device generates the first verification data based on the interface call request (that is, the content of steps 21 to 24) is the same as the way in which the second electronic device generates the second verification data based on the interface call request. That is to say, after receiving the interface call request, the second electronic device determines the parameter information corresponding to the interface call request, determines the data to be encrypted based on the first character encoding table and the parameter information; determines the secret key data based on the target information selected from the second character encoding table and the parameter information; converts the data to be encrypted based on the second character encoding table and the secret key data to obtain the second verification data; compares the first verification data with the second verification data, and when the first verification data and the second verification data are the same, the second electronic device determines that the interface call request is legal and responds to the interface call request; when the first verification data and the second verification data are not the same, the second electronic device does not respond to the interface call request to ensure the security of the data.

[0140] In the above embodiment, the parameter information corresponding to the interface call request is determined by the first electronic device, and then the data to be encrypted is determined according to the first character encoding table and the parameter information, and the key data is determined according to the target information selected from the second character encoding table and the parameter information. Further, the data to be encrypted is converted according to the second character encoding table and the key data to obtain the first verification data. In other words, the first verification data is obtained by converting the parameter information multiple times, which is not easy to be cracked, effectively reducing the risk of the interface being illegally attacked by violent attacks, and saving the work cost of maintaining the security of the interface. After the first electronic device determines the first verification data, the interface call request and the first verification data are sent to the second electronic device. After the second electronic device receives the interface call request, it generates the second verification data based on the interface call request, and determines the response result to the interface call request according to the first verification data and the second verification data. In the technical solution provided by the present invention, when a first electronic device sends an interface call request to a second electronic device, it not only sends parameter information corresponding to the interface call request, but also sends first verification data, so that the second electronic device uses the second verification data to verify the first verification data, accurately identifies forged interface call requests, and ensures data security; and through effective identification of forged interface call requests, saves resources of the second electronic device and improves the processing efficiency of the second electronic device.

[0141] Figure 4 1 is a flow chart of an interface calling method provided by an exemplary embodiment of the present invention. The method is applied to a second electronic device and at least comprises the following steps:

[0142] Step 41, receiving an interface calling request and first verification data sent by a first electronic device; the first verification data is generated by the first electronic device based on the interface calling request;

[0143] Step 42, determining parameter information corresponding to the interface call request;

[0144] Step 43, determining the data to be encrypted based on the first character encoding table and the parameter information;

[0145] Step 44, determining key data based on the second character encoding table and the target information selected from the parameter information;

[0146] Step 45, based on the second character encoding table and the secret key data, convert the data to be encrypted to obtain second verification data;

[0147] Step 46: Determine a response result of the interface call request based on the first verification data and the second verification data.

[0148] In this embodiment, the second electronic device receives the interface call request and the first verification data sent by the first electronic device, wherein the first verification data is determined by the first electronic device based on the interface call request (specifically corresponding to the contents of steps 21 to 24). The second electronic device determines the parameter information corresponding to the interface call request according to the received interface call request, determines the data to be encrypted based on the first character encoding table and the parameter information; determines the secret key data based on the target information selected from the second character encoding table and the parameter information; and converts the data to be encrypted based on the second character encoding table and the secret key data to obtain the second verification data. The first verification data is compared with the second verification data. If the first verification data is the same as the second verification data, the second electronic device determines that the interface call request is legal and responds to the interface call request; if the first verification data is different from the second verification data, the second electronic device does not respond to the interface call request to ensure the security of the data.

[0149] A flowchart of an interface calling method provided by an exemplary embodiment of the present invention is provided. The method is applied to an interface calling system. The interface calling system includes a first electronic device and a second electronic device, and at least includes the following steps:

[0150] The first electronic device determines parameter information corresponding to the interface call request;

[0151] The first electronic device determines the first data to be encrypted based on the first character encoding table and the parameter information;

[0152] The first electronic device determines the first key data based on the second character encoding table and the target information selected from the parameter information;

[0153] The first electronic device converts the first data to be encrypted based on the second character encoding table and the first secret key data to obtain first verification data;

[0154] The first electronic device sends the interface calling request and the first verification data to the second electronic device;

[0155] The second electronic device receives the interface calling request and the first verification data sent by the first electronic device;

[0156] The second electronic device determines parameter information corresponding to the interface call request;

[0157] The second electronic device determines the second data to be encrypted based on the first character encoding table and the parameter information;

[0158] The second electronic device determines the second key data based on the second character encoding table and the target information selected from the parameter information;

[0159] The second electronic device converts the second data to be encrypted based on the second character encoding table and the second secret key data to obtain second verification data;

[0160] The second electronic device determines a response result of the interface calling request based on the first verification data and the second verification data.

[0161] Exemplary Devices

[0162] Based on the same concept as the method embodiment of the present invention, the embodiment of the present invention also provides an interface calling device.

[0163] Figure 5 A schematic diagram of the structure of an interface calling device provided by an exemplary embodiment of the present invention is shown. The device is arranged in a first electronic device and includes:

[0164] A first parameter determination module 51, used to determine parameter information corresponding to the interface call request;

[0165] A first data determination module 52, used to determine the data to be encrypted based on the first character encoding table and the parameter information;

[0166] A first key determination module 53, configured to determine key data based on a second character encoding table and target information selected from the parameter information;

[0167] A first conversion processing module 54, configured to convert the data to be encrypted based on the second character encoding table and the key data to obtain first verification data;

[0168] The data sending processing module 55 is used to send the interface call request and the first verification data to the second electronic device, so that the second electronic device generates second verification data based on the interface call request; and determines the response result to the interface call request based on the first verification data and the second verification data.

[0169] In an exemplary embodiment of the present invention, the first data determination module includes:

[0170] A sorting processing unit, used to sort the parameter information according to a preset rule and determine the sorted parameter information;

[0171] A data determination unit is used to determine the data to be encrypted based on the first character encoding table and the sorted parameter information.

[0172] In an exemplary embodiment of the present invention, the parameter information includes at least one parameter name and a parameter value corresponding to each of the at least one parameter name, the preset rule includes a first preset rule and a second preset rule, and the sorting processing unit includes:

[0173] a character determination subunit, used for determining a second character corresponding to a first character at a first target position in each of the parameter names in the first character code;

[0174] A first sorting subunit, configured to sort each of the parameter names and the parameter values ​​corresponding to each of the parameter names based on the second character corresponding to the first target position in each of the parameter names and the first preset rule, to determine the parameter information after the initial sorting;

[0175] The second sorting subunit is used to sort the parameter information after the initial sorting according to the second preset rule to determine the sorted parameter information.

[0176] In an exemplary embodiment of the present invention, the data determination unit includes:

[0177] a conversion processing subunit, configured to perform character conversion on the sorted parameter information using the first character encoding table to determine the converted parameter information;

[0178] The splicing processing subunit is used to splice the converted parameter information with the timestamp corresponding to the interface call request to determine the data to be encrypted.

[0179] In an exemplary embodiment of the present invention, the first conversion processing module includes:

[0180] A quantity determination unit, used to determine the quantity of secret keys corresponding to the secret key data;

[0181] A group processing unit, used for grouping the data to be encrypted according to the number of secret keys to obtain at least one group to be encrypted;

[0182] A calculation processing unit, used to determine the calculation result of each of the to-be-encrypted groups and the key data;

[0183] The first conversion unit is used to perform character conversion on the calculation result by using the second character encoding table to obtain the first verification data.

[0184] In an exemplary embodiment of the present invention, it is characterized in that the first key determination module includes:

[0185] An information selection unit, configured to select a parameter name at a second target position in the parameter information as the target information;

[0186] The second conversion unit is used to determine the key data based on the second character encoding table and the target information.

[0187] Figure 6 A schematic diagram of the structure of an interface calling device provided by an exemplary embodiment of the present invention is shown. The device is arranged in a second electronic device and includes:

[0188] The data receiving processing module 61 is used to receive an interface calling request and first verification data sent by a first electronic device; the first verification data is generated by the first electronic device based on the interface calling request;

[0189] A second parameter determination module 62, used to determine parameter information corresponding to the interface call request;

[0190] A second data determination module 63, used to determine the data to be encrypted based on the first character encoding table and the parameter information;

[0191] A second key determination module 64, configured to determine key data based on a second character encoding table and target information selected from the parameter information;

[0192] A second conversion processing module 65, configured to convert the data to be encrypted based on the second character encoding table and the key data to obtain second verification data;

[0193] The data verification processing module 66 is used to determine the response result of the interface call request based on the first verification data and the second verification data.

[0194] An exemplary embodiment of the invention provides an interface calling system, the interface calling system comprising a first electronic device and a second electronic device;

[0195] A first electronic device, used to determine parameter information corresponding to the interface call request;

[0196] A first electronic device, configured to determine first data to be encrypted based on a first character encoding table and the parameter information;

[0197] A first electronic device, configured to determine first key data based on a second character encoding table and target information selected from the parameter information;

[0198] A first electronic device, configured to convert the first data to be encrypted based on the second character encoding table and the first secret key data to obtain first verification data;

[0199] The first electronic device is configured to send the interface call request and the first verification data to a second electronic device;

[0200] The second electronic device is used to receive the interface calling request and the first verification data sent by the first electronic device;

[0201] A second electronic device, used to determine parameter information corresponding to the interface call request;

[0202] A second electronic device, used to determine second data to be encrypted based on the first character encoding table and the parameter information;

[0203] A second electronic device, used to determine second key data based on a second character encoding table and target information selected from the parameter information;

[0204] A second electronic device, configured to convert the second data to be encrypted based on the second character encoding table and the second secret key data to obtain second verification data;

[0205] The second electronic device is used to determine a response result of the interface call request based on the first verification data and the second verification data.

[0206] Exemplary Electronic Devices

[0207] Figure 7 A block diagram of an electronic device according to an embodiment of the present invention is illustrated.

[0208] like Figure 7 As shown, the electronic device 70 includes one or more processors 71 and a memory 72 .

[0209] The processor 71 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 70 to perform desired functions.

[0210] The memory 72 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may include, for example, a read-only memory (ROM), a hard disk, a flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 71 may execute the program instructions to implement the interface calling method and / or other desired functions of the various embodiments of the present invention described above.

[0211] In one example, the electronic device 70 may further include: an input device 73 and an output device 74, and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).

[0212] Of course, to simplify, Figure 7 Only some of the components related to the present invention in the electronic device 70 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application conditions, the electronic device 70 may also include any other appropriate components.

[0213] Exemplary computer program products and computer-readable storage media

[0214] In the sixth aspect, in addition to the above-mentioned methods and devices, an embodiment of the present invention may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the interface calling method according to various embodiments of the present invention described in the above-mentioned "Exemplary Method" section of this specification.

[0215] The computer program product may be written in any combination of one or more programming languages ​​to write program code for performing the operations of the embodiments of the present invention, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0216] In addition, an embodiment of the present invention may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enable the processor to execute the steps of the interface calling method according to various embodiments of the present invention described in the above “Exemplary Method” section of this specification.

[0217] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable 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.

[0218] The basic principle of the present invention is described above in conjunction with specific embodiments. However, it should be pointed out that the advantages, strengths, effects, etc. mentioned in the present invention are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. must be possessed by each embodiment of the present invention. In addition, the specific details of the above invention are only for the purpose of illustration and facilitation of understanding, rather than limitation, and the above details do not limit the present invention to being implemented by adopting the above specific details.

[0219] The block diagrams of the devices, apparatuses, equipment, and systems involved in the present invention are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The word "such as" used here refers to the phrase "such as but not limited to", and can be used interchangeably with it.

[0220] It should also be noted that in the device, apparatus and method of the present invention, each component or each step can be decomposed and / or reassembled, and such decomposition and / or reassembly should be regarded as an equivalent solution of the present invention.

[0221] The above description of the invented aspects is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present invention. Therefore, the present invention is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features of the present invention.

[0222] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present invention to the form invented herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.

Claims

1. An interface calling method, characterized in that: Applicable to a first electronic device, comprising: Determine the parameter information corresponding to the interface call request; Determining the data to be encrypted based on the first character encoding table and the parameter information; Determining key data based on a second character encoding table and target information selected from the parameter information; Based on the second character encoding table and the secret key data, convert the data to be encrypted to obtain first verification data; Sending the interface call request and the first verification data to a second electronic device, so that the second electronic device generates second verification data based on the interface call request; and determining a response result to the interface call request based on the first verification data and the second verification data; The step of determining the data to be encrypted based on the first character encoding table and the parameter information includes: Sorting the parameter information according to a preset rule to determine the sorted parameter information; Performing character conversion on the sorted parameter information using the first character encoding table to determine converted parameter information; Concatenate the converted parameter information with the timestamp corresponding to the interface call request to determine the data to be encrypted; The converting the data to be encrypted based on the second character encoding table and the secret key data to obtain the first verification data includes: Determining the number of keys corresponding to the key data; Grouping the data to be encrypted according to the number of secret keys to obtain at least one group to be encrypted; Determine the calculation result of each of the to-be-encrypted groups and the secret key data; The calculation result is character-converted using the second character encoding table to obtain the first verification data.

2. The method according to claim 1, characterized in that The parameter information includes at least one parameter name and a parameter value corresponding to each of the at least one parameter name, the preset rule includes a first preset rule and a second preset rule, and the parameter information is sorted according to the preset rule to determine the sorted parameter information, including: Determine a second character corresponding to a first character at a first target position in each of the parameter names in the first character code; Based on the second character corresponding to the first target position in each of the parameter names and the first preset rule, sorting the parameter names and the parameter values ​​corresponding to each of the parameter names to determine the parameter information after the initial sorting; The parameter information after the initial sorting is sorted according to the second preset rule to determine the sorted parameter information.

3. The method according to any one of claims 1 to 2, characterized in that: The determining of the key data based on the second character encoding table and the target information selected from the parameter information includes: Selecting the parameter name at the second target position in the parameter information as the target information; The key data is determined based on the second character encoding table and the target information.

4. An interface calling method, characterized in that: Applicable to a second electronic device, comprising: Receiving an interface calling request and first verification data sent by a first electronic device; the first verification data is generated by the first electronic device based on the interface calling request; Determine parameter information corresponding to the interface call request; Determining the data to be encrypted based on the first character encoding table and the parameter information; Determining key data based on a second character encoding table and target information selected from the parameter information; Based on the second character encoding table and the secret key data, convert the data to be encrypted to obtain second verification data; Determining a response result of the interface call request based on the first verification data and the second verification data; The step of determining the data to be encrypted based on the first character encoding table and the parameter information includes: Sorting the parameter information according to a preset rule to determine the sorted parameter information; Performing character conversion on the sorted parameter information using the first character encoding table to determine converted parameter information; Concatenate the converted parameter information with the timestamp corresponding to the interface call request to determine the data to be encrypted; The converting the data to be encrypted based on the second character encoding table and the secret key data to obtain second verification data includes: Determining the number of keys corresponding to the key data; Grouping the data to be encrypted according to the number of secret keys to obtain at least one group to be encrypted; Determine the calculation result of each of the to-be-encrypted groups and the secret key data; The calculation result is character-converted using the second character encoding table to obtain the second verification data.

5. An interface calling device, characterized in that: Set in a first electronic device, comprising: A first parameter determination module, used to determine parameter information corresponding to the interface call request; A first data determination module, used to determine the data to be encrypted based on the first character encoding table and the parameter information; A first key determination module, configured to determine key data based on a second character encoding table and target information selected from the parameter information; A first conversion processing module, used for converting the data to be encrypted based on the second character encoding table and the secret key data to obtain first verification data; a data transmission processing module, configured to transmit the interface call request and the first verification data to a second electronic device, so that the second electronic device generates second verification data based on the interface call request; and determines a response result to the interface call request based on the first verification data and the second verification data; The step of determining the data to be encrypted based on the first character encoding table and the parameter information includes: Sorting the parameter information according to a preset rule to determine the sorted parameter information; Performing character conversion on the sorted parameter information using the first character encoding table to determine converted parameter information; Concatenate the converted parameter information with the timestamp corresponding to the interface call request to determine the data to be encrypted; The converting the data to be encrypted based on the second character encoding table and the secret key data to obtain the first verification data includes: Determining the number of keys corresponding to the key data; Grouping the data to be encrypted according to the number of secret keys to obtain at least one group to be encrypted; Determine the calculation result of each of the to-be-encrypted groups and the secret key data; The calculation result is character-converted using the second character encoding table to obtain the first verification data.

6. An interface calling device, characterized in that: The second electronic device includes: A data receiving and processing module, configured to receive an interface calling request and first verification data sent by a first electronic device; the first verification data is generated by the first electronic device based on the interface calling request; A second parameter determination module, used to determine parameter information corresponding to the interface call request; A second data determination module, used to determine the data to be encrypted based on the first character encoding table and the parameter information; A second key determination module, used to determine the key data based on a second character encoding table and target information selected from the parameter information; A second conversion processing module, used for converting the data to be encrypted based on the second character encoding table and the secret key data to obtain second verification data; A data verification processing module, used to determine a response result of the interface call request based on the first verification data and the second verification data; The step of determining the data to be encrypted based on the first character encoding table and the parameter information includes: Sorting the parameter information according to a preset rule to determine the sorted parameter information; Performing character conversion on the sorted parameter information using the first character encoding table to determine converted parameter information; Concatenate the converted parameter information with the timestamp corresponding to the interface call request to determine the data to be encrypted; The converting the data to be encrypted based on the second character encoding table and the secret key data to obtain second verification data includes: Determining the number of keys corresponding to the key data; Grouping the data to be encrypted according to the number of secret keys to obtain at least one group to be encrypted; Determine the calculation result of each of the to-be-encrypted groups and the secret key data; The calculation result is character-converted using the second character encoding table to obtain the second verification data.

7. A computer-readable storage medium, wherein the storage medium stores a computer program, wherein the computer program is used to execute the interface calling method described in any one of claims 1 to 4.

8. An electronic device, comprising: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the interface calling method described in any one of claims 1 to 4 above.

Citation Information

Patent Citations

  • Interface encryption method and device and set-top-box login system

    CN106303755A

  • Information encryption and decryption method and apparatus

    CN106506487A