Service token verification method and device, electronic equipment and readable storage medium
By receiving the token to be verified from the client on the server and determining its target business environment identity, and directly using the token of the target business environment for verification, the problem of inefficient token verification in the prior art is solved, and a more efficient token verification process is achieved.
Patent Information
- Application Number
- CN202411913759.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2044-12-24
AI Technical Summary
After receiving the token entered by the user on the client, the server needs to compare it with the tokens corresponding to multiple business environments, resulting in low efficiency in verification of the token.
By receiving the service token to be verified sent by the client and determining the corresponding target service environment identifier based on the token and the first user key, the target service token corresponding to the target service environment is used for verification, and comparison with multiple service environment tokens is avoided.
It improves the verification efficiency of business tokens, reduces the number of comparisons, and improves the processing speed of the server.
Smart Images

Figure CN119853976A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of information technology, and specifically relates to a method, device, electronic device and readable storage medium for verifying a business token. Background Art
[0002] In the related art, after the user enters a token on the client and submits it to the server, since the server includes multiple business environments, the server needs to generate a token for each business environment and compare the multiple generated tokens to see whether they contain the token entered by the user on the client. If so, the token passes the verification.
[0003] However, after the server receives the token entered by the user on the client, it cannot determine which business environment the user needs to authenticate, so it needs to compare the received token with the token corresponding to each generated business environment, resulting in low token verification efficiency. Summary of the invention
[0004] The embodiments of the present application provide a method, device, electronic device and readable storage medium for verifying a business token, which can solve the problem that after the server receives the token input by the user on the client, it needs to compare the received token with the token corresponding to each generated business environment, resulting in low token verification efficiency.
[0005] In the first aspect, an embodiment of the present application provides a method for verifying a business token, which is applied to a server, and the method includes: receiving a business token to be verified sent by a client; determining a target business environment identifier corresponding to the business token to be verified based on the business token to be verified and a first user key; wherein the target business environment identifier is used to identify a target business environment; and verifying the business token to be verified based on the target business token corresponding to the target business environment.
[0006] In the second aspect, an embodiment of the present application provides a method for verifying a business token, which is applied to a client, and the method includes: generating a first random number in response to an input user account and user password; receiving a second random number sent by a server and a business environment identifier corresponding to each business environment; wherein the second random number is generated by the server when the user account and the user password are successfully verified; generating a business token to be verified based on the first random number, the second random number and the target business environment identifier; wherein the target business environment identifier is one of the business environment identifiers corresponding to each business environment; and sending the business token to be verified to the server.
[0007] In the third aspect, an embodiment of the present application provides a business token verification device, which includes: a receiving module for receiving a business token to be verified sent by a client; a determination module for determining a target business environment identifier corresponding to the business token to be verified based on the business token to be verified and a first user key; wherein the target business environment identifier is used to identify a target business environment; and a verification module for verifying the business token to be verified based on a target business token corresponding to the target business environment.
[0008] In the fourth aspect, an embodiment of the present application provides a business token verification device, which includes: a generation module, which is used to generate a first random number in response to an input user account and a user password; a receiving module, which is used to receive a second random number sent by a server and a business environment identifier corresponding to each business environment; wherein the second random number is generated by the server based on the successful verification of the received user account and the user password; the generation module is also used to generate a business token to be verified based on the first random number, the second random number and the target business environment identifier; wherein the target business environment identifier is one of the business environment identifiers corresponding to the each business environment; a sending module, which is used to send the business token to be verified to the server.
[0009] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect, or implements the steps of the method described in the second aspect.
[0010] In a sixth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented, or the steps of the method described in the second aspect are implemented.
[0011] In the seventh aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the steps of the method described in the first aspect, or to implement the steps of the method described in the second aspect.
[0012] In an eighth aspect, an embodiment of the present application provides a computer program product, comprising a computer program stored on a non-transitory computer-readable storage medium, wherein the computer program comprises a program or instructions, and when the program or instructions are executed, the steps of the method described in the first aspect are implemented, or the steps of the method described in the second aspect are implemented.
[0013] In an embodiment of the present application, the server receives the business token to be verified sent by the client, and determines the target business environment identifier corresponding to the business token to be verified based on the business token to be verified and the first user key, and can determine the target business environment based on the target business environment identifier, thereby accurately verifying the business token to be verified based on the target business token corresponding to the target business environment, without having to compare the business token to be verified with tokens corresponding to multiple business environments, thereby improving the verification efficiency of business tokens. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 It is a flowchart of a method for verifying a business token provided in an embodiment of the present application; Figure 2 It is a flowchart of another method for verifying a business token provided in an embodiment of the present application; Figure 3 It is a flowchart of another method for verifying a business token provided in an embodiment of the present application; Figure 4 It is a structural diagram of a business token verification device provided in an embodiment of the present application; Figure 5 It is a structural diagram of another business token verification device provided in an embodiment of the present application; Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0015] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0016] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0017] The following, in conjunction with the accompanying drawings, describes in detail the verification method, device, electronic device and readable storage medium of the business token provided in the embodiments of the present application through specific embodiments and their application scenarios.
[0018] Figure 1 The flowchart of a method for verifying a business token provided by an embodiment of the present application is shown. The method is applied to a server and can be executed by an electronic device. Figure 1 , the method may include the following steps.
[0019] Step 102: Receive the service token to be verified sent by the client.
[0020] Among them, the business token to be verified is generated by the client. Based on the target business environment currently required for authentication, the client adds the identification information corresponding to the target business environment when generating the business token to be verified, so that the server can analyze and determine the target business environment currently required for authentication when receiving the business token to be verified.
[0021] Step 104: Determine the target business environment identifier corresponding to the business token to be verified according to the business token to be verified and the first user key; wherein the target business environment identifier is used to identify the target business environment.
[0022] The business token to be verified carries identification information corresponding to the target business environment. The server analyzes the business token to be verified to determine the target business environment identification corresponding to the business token to be verified, so as to know the target business environment of the business token to be verified that the client currently needs to verify. The first user key is generated by the server to assist in determining the target business environment identification carried by the business token to be verified.
[0023] Step 106: verify the service token to be verified according to the target service token corresponding to the target service environment.
[0024] In an embodiment of the present application, the server receives the business token to be verified sent by the client, analyzes the business token to be verified, and determines the target business environment identifier corresponding to the business token to be verified based on the business token to be verified and the first user key. The server can determine the target business environment based on the target business environment identifier, and then accurately verify the business token to be verified based on the target business token corresponding to the target business environment. There is no need to compare the business token to be verified with tokens corresponding to multiple business environments, thereby improving the verification efficiency of business tokens.
[0025] In one implementation, the above step 104 determines the target business environment identifier corresponding to the business token to be verified according to the business token to be verified and the first user key, and includes the following steps.
[0026] Step 1041: extract the original business token and the target business environment number from the business token to be verified.
[0027] Among them, the business token to be verified generated by the client carries the original business token and the target business environment number corresponding to the target business environment identifier. In one implementation method, based on the generation method of the business token to be verified, the value of the first preset position of the business token to be verified is the original business token, and the value of the second preset position of the business token to be verified is the target business environment number, so that the original business token and the target business environment number can be extracted by intercepting the value of the preset position of the business token to be verified.
[0028] Step 1042: Determine the target business environment identifier according to the first user key, the original business token, and the target business environment number.
[0029] In an embodiment of the present application, the server analyzes the received business token to be verified, extracts the original business token and the target business environment number carried in the business token to be verified, and determines the target business environment identifier based on the obtained original business token, the target business environment number and the first user key. The target business environment identifier can be used to determine the target business environment of the business token to be verified that the client currently needs to verify, so that the target business token corresponding to the target business environment is used to verify the business token to be verified. There is no need to compare the business token to be verified with tokens corresponding to multiple business environments, thereby improving the verification efficiency of business tokens.
[0030] In one implementation, the above step 1042 determines the target business environment identifier according to the first user key, the original business token, and the target business environment number, and includes the following steps.
[0031] Step 1042a, concatenate the original business token and the first user key to obtain a first result.
[0032] Step 1042b, adding the value of each bit in the first result after hash processing to obtain a second result.
[0033] Among them, the first result after hash processing is a hash value of fixed length. By adding the value of each bit, a numerical value can be obtained, which is the second result.
[0034] Step 1042c, performing modulo processing on the second result and the token length of the original business token to obtain a third result.
[0035] Among them, the token length of the original business token is a preset value, which can be 6 bits.
[0036] Step 1042d: Determine the target business environment identifier according to the target business environment number and the third result.
[0037] Among them, according to the target business environment number and the third result, it is determined that the target business environment identifier corresponds to the way in which the client generates the business token to be verified. In one implementation, the way in which the client generates the business token to be verified is: the original business token is concatenated with the second user key to obtain a first result, and the second user key is also generated by the client. Then, the value of each bit in the first result after hash processing is added to obtain a second result, and then the second result is modulo the token length of the original business token to obtain a third result, and the target business environment number is obtained by subtracting the third result from the target business environment identifier. Therefore, according to the target business environment number and the third result, the server determines that the target business environment identifier can be: the target business environment identifier can be obtained by adding the target business environment number to the third result.
[0038] In an embodiment of the present application, after the server extracts the original business token and the target business environment number from the business token to be verified, the server obtains a first result by concatenating the original business token with the first user key, and then hashes the first result, adds the value of each bit in the first result after hashing to obtain a second result, and then modulo-processes the second result and the token length of the original business token to obtain a third result, and determines the target business environment identifier based on the target business environment number and the third result, thereby determining the target business environment identifier based on the first user key, the original business token, and the target business environment number, so that the target business environment of the business token to be verified that the client currently needs to verify is determined through the target business environment identifier.
[0039] In one implementation, the above step 106 verifies the to-be-verified business token according to the target business token corresponding to the target business environment, and includes the following steps.
[0040] Step 1061: Acquire a target user key corresponding to the target business environment according to the target business environment identifier.
[0041] Among them, the server stores different business environment identifiers and user keys under different business environments. According to the target business environment identifier, the target user key corresponding to the target business environment can be determined to generate the target business token under the target business environment and verify the business token to be verified.
[0042] Step 1062: Generate business token information corresponding to the target business environment according to the target user key and the timestamp of the target user key.
[0043] One way to generate the business token information corresponding to the target business environment is to concatenate the target user key and the timestamp of the target user key to obtain the business token information. The timestamp of the target user key is the time when the server obtains the target user key according to the target business environment identifier.
[0044] Step 1063: Determine the target business token corresponding to the target business environment according to the target user key and the business token information.
[0045] Among them, the target user key and business token information can be processed respectively by the SM3 hash algorithm to generate a hash value corresponding to the target user key and a hash value corresponding to the business token information. Then, the values of the corresponding positions of the hash value corresponding to the target user key and the hash value corresponding to the business token information are processed by OR operation, and the result is modulo the preset token length to obtain the target business token. In addition, when the length of the target business token is less than the preset token length, zero padding is performed so that the length of the target business token meets the preset token length, that is, the final target business token is obtained for verification of the business token to be verified.
[0046] Step 1064: Verify the to-be-verified business token by comparing the value of the target business token with the value of the original business token.
[0047] In an embodiment of the present application, after the server determines the target business environment identifier corresponding to the business token to be verified based on the business token to be verified and the first user key, it obtains the target user key corresponding to the target business environment based on the target business environment identifier, and then generates the business token information corresponding to the target business environment based on the target user key and the timestamp of the target user key, and then determines the target business token corresponding to the target business environment based on the business token information and the target user key, thereby verifying the business token to be verified by comparing the value of the target business token with the value of the original business token, thereby achieving accurate verification of the business token to be verified based on the target business token corresponding to the target business environment, without the need to compare the business token to be verified with tokens corresponding to multiple business environments, thereby improving the verification efficiency of business tokens.
[0048] In one implementation, the above-mentioned step 1064 verifies the business token to be verified by comparing the value of the target business token with the value of the original business token, and may include: when the value of the target business token is the same as the value of the original business token, determining that the business token to be verified has passed the verification.
[0049] In an embodiment of the present application, the server compares the value of the target business token with the value of the original business token. When the value of the target business token is the same as the value of the original business token, the server determines that the business token to be verified has passed the verification, thereby achieving accurate and efficient verification of the business token to be verified through the target business token corresponding to the target business environment.
[0050] In one implementation, before receiving the service token to be verified sent by the client in the above step 102, the method further includes the following steps.
[0051] Step 1011, receiving the user account, user password and first random number sent by the client.
[0052] The server receives the user account and password sent by the client and verifies the identity of the user who logs in to the client. The first random number of the client and the second random number of the server are used to generate user keys, including the first user key of the server, the second user key of the client, and the user keys of each business environment of the server.
[0053] Step 1012: if the user account and the user password are successfully verified, generate a second random number.
[0054] Wherein, if the user account and the user password are successfully verified, the account and password entered by the current user on the client are verified, and further verification of the business token can be performed. The second random number and the first random number are used to generate user keys, including the first user key of the server, the second user key of the client, and the user keys under various business environments of the server.
[0055] Step 1013: Generate the first user key according to the first random number and the second random number.
[0056] In the embodiment of the present application, the server receives the user account and user password sent by the client to verify the identity of the user who logged in to the client. If the user account and user password verification is successful, the account and password entered by the current user on the client are verified, and further verification of the business token can be performed by generating a second random number, and generating a first user key based on the second random number and the first random number sent by the client. The first user key is stored on the server and is used to assist in determining the target business environment identifier carried by the business token to be verified.
[0057] In one implementation, in the above step 1012, when the user account and the user password are successfully verified, after generating a second random number, the method further includes: sending the second random number and a business environment identifier corresponding to each business environment to the client.
[0058] In the embodiment of the present application, when the user account and the user password are successfully verified, the server generates a second random number and sends the second random number to the client, so that the client generates a second user key based on the second random number and the first random number generated by it. The server also sends the business environment identifiers corresponding to each business environment to the client, so that the client can select the target business environment currently required, and then generate a business token to be verified based on the target business environment identifier, the first random number and the second random number corresponding to the target business environment. The server analyzes the business token to be verified and determines to use the target business token corresponding to the target business environment to accurately verify the business token to be verified, without comparing the business token to be verified with tokens corresponding to multiple business environments, thereby improving the verification efficiency of business tokens.
[0059] Figure 2 The present invention provides another method for verifying a service token, which is applied to a client and can be executed by an electronic device. Figure 2 , the method may include the following steps.
[0060] Step 202: Generate a first random number in response to the input user account and user password.
[0061] The user logs in to the client by entering the user account and user password. The client sends the user account and user password to the server, and the server verifies the user account and user password to determine the user's identity. The first random number of the client and the second random number of the server are used to generate user keys, including the first user key of the server, the second user key of the client, and the user keys of each business environment of the server.
[0062] Step 204: Receive a second random number sent by the server and a business environment identifier corresponding to each business environment.
[0063] Among them, the second random number is generated by the server based on the successful verification of the received user account and the user password, and is used to generate user keys together with the first random number, including the first user key of the server, the second user key of the client, and the user keys under various business environments of the server.
[0064] Step 206: Generate a service token to be verified according to the first random number, the second random number and the target service environment identifier.
[0065] The target business environment identifier is one of the business environment identifiers corresponding to the business environments. The generated business token to be verified carries the target business environment identifier, so that the server analyzes the business token to be verified and determines to use the target business token corresponding to the target business environment to verify the business token to be verified.
[0066] Step 208: Send the service token to be verified to the server.
[0067] In an embodiment of the present application, the client generates a first random number in response to an input user account and user password, and sends the user account, user password and the first random number to the server. The server receives the user account and user password sent by the client to verify the identity of the user who logs in to the client. When the user account and user password are successfully verified, a second random number is generated, and the second random number and the business environment identifier corresponding to each business environment are sent to the client. The client receives the second random number sent by the server and the business environment identifier corresponding to each business environment, and then generates a business token to be verified based on the first random number, the second random number and the target business environment identifier, and sends the business token to be verified to the server. The server analyzes the business token to be verified and determines to use the target business token corresponding to the target business environment to accurately verify the business token to be verified, without comparing the business token to be verified with tokens corresponding to multiple business environments, thereby improving the verification efficiency of the business token.
[0068] In one implementation, the above step 206 generates a service token to be verified according to the first random number, the second random number and the target service environment identifier, and includes the following steps.
[0069] Step 2061: Generate a second user key according to the first random number and the second random number.
[0070] The second user key may be generated by performing hash processing on the concatenated first random number and the second random number.
[0071] Step 2062: Generate original business token information according to the second user key and the timestamp of the second user key.
[0072] One way to generate the original service token information is to concatenate the second user key and the timestamp of the second user key to obtain the original service token information. The timestamp of the second user key is the time when the client generates the second user key.
[0073] Step 2063: Determine the original business token according to the second user key and the original business token information.
[0074] The original business token can be determined by using the SM3 hash algorithm on the second user key and the original business token information.
[0075] Step 2064: Determine the business token to be verified according to the second user key, the original business token, and the target business environment number corresponding to the target business environment identifier.
[0076] In an embodiment of the present application, the client generates a second user key by generating a first random number and receiving a second random number sent by the server, and then generates original business token information with the timestamp of the second user key, determines the original business token based on the original business token information and the second user key, and then determines the final business token to be verified based on the original business token, the second user key and the target business environment number corresponding to the target business environment identifier. The business token to be verified carries the target business environment number corresponding to the target business environment identifier, so that the server can analyze the business token to be verified and determine that the target business token corresponding to the target business environment can be used to accurately verify the business token to be verified.
[0077] In one implementation, the above-mentioned step 2063 of determining the original business token according to the second user key and the original business token information may include the following steps.
[0078] Step 2063a: Process the second user key and the original business token information respectively through the SM3 hash algorithm to generate a first hash value and a second hash value.
[0079] Among them, the SM3 hash algorithm can process the second user keys and original business token information of different lengths into hash values of fixed length, so that the generated first hash value and second hash value can be subsequently processed by OR operation.
[0080] Step 2063b: Perform an OR operation on the values at corresponding positions of the first Hash value and the second Hash value to obtain a first numerical value.
[0081] The first Hash value and the second Hash value have the same length, so that an OR operation can be performed on the values at corresponding positions of the first Hash value and the second Hash value.
[0082] Step 2063c, performing modulo processing on the first value and the preset token length to obtain a second value.
[0083] Among them, the preset token length is the token length of the preset generated original business token, which can be 6 bits.
[0084] Step 2063d: When the length of the second value is less than the preset token length, the second value is padded with zeros to obtain the original business token.
[0085] In an embodiment of the present application, the client processes the generated second user key and original business token information respectively through the SM3 hash algorithm to generate a first hash value corresponding to the second user key and a second hash value corresponding to the original business token information, so that the second user key and the original business token information are processed into hash values of the same length, and then the values at the corresponding positions of the first hash value and the second hash value are processed by OR operation to obtain a first numerical value with the same length as the first hash value and the second hash value, and the first numerical value is modulo the preset token length to obtain a second numerical value, and when the length of the second numerical value is less than the preset token length, the second numerical value is padded with zeros to obtain the original business token, thereby realizing the determination of the original business token. The original business token is used as the core part of the business token to be verified, and the target environment business number corresponding to the target business environment identifier is added to constitute the business token to be verified, so that the server can analyze the business token to be verified and determine that the target business token corresponding to the target business environment can be used to accurately verify the business token to be verified.
[0086] Figure 3 A flow chart of another method for verifying a business token provided in an embodiment of the present application is shown, which is applied to a client and a server, see Figure 3 , the method may include the following steps.
[0087] Step 301: The client generates a random seed a in response to the user account and user password input by the user, and sends the user account, user password and random seed a to the server.
[0088] The random seed a can be generated by using the MD5 algorithm.
[0089] Step 302: The server receives the user account, the user key, and the random seed a, verifies the user account and the user key, and generates a random seed b if the verification is successful.
[0090] Step 303: The server concatenates random seed a and random seed b, generates a first user key using the concatenated a and b through the SM3 hash algorithm, and stores the first user key.
[0091] Step 304: The server sends the random seed b and the business environment identifier corresponding to each business environment to the client.
[0092] The business environment identifier corresponding to each business environment can be represented by numbers 0-9.
[0093] Step 305: The client concatenates random seed a and random seed b, and generates a second user key using the concatenated a and b through the SM3 hash algorithm.
[0094] Step 306: Concatenate the second user key and the current timestamp to generate original business token information.
[0095] Among them, it can be generated through JSON Web Tokens (JWT).
[0096] Step 307: Use the second user key as the key and the original business token information as the value, and process them through the SM3 hash algorithm to obtain the corresponding hash value.
[0097] Step 308, perform an OR operation on each bit of the hash value, and perform a modulus operation with the preset token length to obtain the original business token.
[0098] Among them, the preset token length can be 6 bits.
[0099] Wherein, when the token length of the obtained original service token is less than the preset token length, zeros are added to the front of the original service token to make the token length of the original service token equal to the preset token length.
[0100] Step 309: concatenate the second user key with the obtained original business token to obtain result 1.
[0101] For example, the second user key is 19badaa78a3aced541e4f6c15fc12ade, the generated original business token is 007788, and the result 1 is 00778819badaa78a3aced541e4f6c15fc12ade.
[0102] Step 310, add the value of each bit of the hashed result 1 to obtain the result 2.
[0103] For example, the hash value of result 1 is 002700, and result 2 is 0+0+2+7+0+0 = 9.
[0104] Step 311, perform modulo processing on result 2 and the token length of the original business token to obtain result 3.
[0105] For example, result 2 is 45, the token length of the original business token is 6, and result 3 is 45%6=3.
[0106] Step 312: subtract the result 3 from the target business environment identifier to obtain the target business environment number corresponding to the target business environment identifier.
[0107] For example, the target business environment identifier is 6, and the target business environment number is 6-3 = 3.
[0108] Step 313: append the target business environment number to the original business token to obtain the business token to be verified.
[0109] For example, the target business environment number is 3, the original business token is 007788, and the final business token to be verified is 3007788.
[0110] The above steps 305 to 313 are steps for the client to generate a service token to be verified.
[0111] Step 314: the user inputs the service token to be verified in the output window of the client, and the client sends the service token to be verified to the server.
[0112] In an optional implementation, the user can log in to applications in different business environments in one client by inputting the business token to be verified generated based on different business environment identifiers. This can not only improve the efficiency of the server in verifying the business token to be verified, but also improve the user experience and reduce the client development cost. There is no need to install the corresponding client for each business environment.
[0113] Step 315: The server extracts the original service token and the target service environment number from the service token to be verified.
[0114] For example, the business token to be verified is 3007788, 007788 is extracted as the original business token, and 3 is extracted as the target business environment number.
[0115] Step 316, concatenate the first user key with the original business token to obtain result 1.
[0116] For example, the first user key is 19badaa78a3aced541e4f6c15fc12ade, the original business token is 007788, and the result 1 is 00778819badaa78a3aced541e4f6c15fc12ade.
[0117] Step 317, add the value of each bit of the hashed result 1 to obtain the result 2.
[0118] For example, the hash value of result 1 is 002700, and result 2 is 0+0+2+7+0+0 = 9.
[0119] Step 318, perform modulo processing on result 2 and the token length of the original business token to obtain result 3.
[0120] For example, result 2 is 45, the token length of the original business token is 6, and result 3 is 45%6=3.
[0121] Step 319, add the target business environment number to the result 3 to obtain the target business environment identifier.
[0122] Among them, the target business environment identifier is hidden in the business token to be verified, and can only be obtained using the second user key, thereby improving the security of the target business environment identifier.
[0123] For example, the target business environment number is 3, the result 3 is 3, and the target business environment identifier is 3+3 = 6.
[0124] Step 320: Concatenate the first user key and the current timestamp to generate target business token information.
[0125] Step 321, according to the target business environment identifier, obtain the target user key corresponding to the target business environment, use the target user key as the key and the target business token information as the value, process through the SM3 hash algorithm, and obtain its corresponding hash value.
[0126] Step 322, perform an OR operation on each bit of the hash value, and perform a modulus operation on the value with the token length of the original business token to obtain the target business token.
[0127] When the token length of the obtained target service token is smaller than the token length of the original service token, zeros are added to the front of the target service token to make the token length of the target service token consistent with that of the original service token.
[0128] Step 323: compare the value of the target business token with the value of the original business token. If the value of the target business token is the same as the value of the original business token, it is determined that the business token to be verified has passed the verification.
[0129] When the service token to be verified passes the verification, the user successfully logs in and can use the service of the server in the target service environment.
[0130] The above steps 315 to 323 are steps for the server to verify the service token to be verified, at least some of which correspond to the steps for the client to generate the service token to be verified.
[0131] In an embodiment of the present application, the client generates a business token to be verified that carries a target business environment identifier for a target business environment, so that after the server receives the business token to be verified, the server analyzes the business token to be verified and determines the target business environment identifier corresponding to the business token to be verified. The target business environment identifier can be used to determine the target business environment of the business token to be verified that the client currently needs to verify, and then the target business token corresponding to the target business environment is used to verify the business token to be verified. There is no need to compare the business token to be verified with tokens corresponding to multiple business environments, thereby improving the verification efficiency of business tokens.
[0132] It should be noted that the verification method for the business token provided in the embodiment of the present application can be executed by a verification device for the business token, or a control module in the verification device for the business token for executing the verification method for the business token. In the embodiment of the present application, the verification device for the business token provided in the embodiment of the present application is described by taking the execution of the verification method for the business token by the verification device for the business token as an example.
[0133] Figure 4 The schematic diagram of the structure of a business token verification device provided by an embodiment of the present application is shown. Figure 4 As shown, the device 400 includes: a receiving module 41, a determining module 42 and a verifying module 43.
[0134] Among them, the receiving module 41 is used to receive the business token to be verified sent by the client; the determination module 42 is used to determine the target business environment identifier corresponding to the business token to be verified based on the business token to be verified and the first user key; wherein the target business environment identifier is used to identify the target business environment; the verification module 43 is used to verify the business token to be verified according to the target business token corresponding to the target business environment.
[0135] In one implementation, the above-mentioned determination module 42 may include an extraction unit and a determination unit, wherein the extraction unit is used to extract the original business token and the target business environment number from the business token to be verified; and the determination unit is used to determine the target business environment identifier based on the first user key, the original business token, and the target business environment number.
[0136] In one implementation, the above-mentioned determination unit can be specifically used to concatenate the original business token and the first user key to obtain a first result; add the value of each bit in the first result after hash processing to obtain a second result; perform modulo processing on the second result and the token length of the original business token to obtain a third result; determine the target business environment identifier based on the target business environment number and the third result.
[0137] In one implementation, the above-mentioned verification module 43 can be used to obtain the target user key corresponding to the target business environment based on the target business environment identifier; generate the business token information corresponding to the target business environment based on the target user key and the timestamp of the target user key; determine the target business token corresponding to the target business environment based on the target user key and the business token information; and verify the business token to be verified by comparing the value of the target business token with the value of the original business token.
[0138] In an implementation, the verification module 43 may be configured to determine that the to-be-verified business token passes verification when the value of the target business token is the same as the value of the original business token.
[0139] In one implementation, the above-mentioned device 400 may also include a generation module for receiving a user account, a user password and a first random number sent by the client; generating a second random number when the user account and the user password are successfully verified; and generating the first user key based on the first random number and the second random number.
[0140] In an implementation manner, the above-mentioned apparatus 400 may further include a sending module, configured to send the second random number and a business environment identifier corresponding to each business environment to the client.
[0141] Figure 5 FIG. 2 shows a schematic diagram of the structure of another service token verification device provided by an embodiment of the present application. Figure 5 As shown, the device 500 includes: a generating module 51, a receiving module 52 and a sending module 53.
[0142] Among them, the generating module 51 is used to generate a first random number in response to the input user account and user password; the receiving module 52 is used to receive the second random number sent by the server and the business environment identifier corresponding to each business environment; wherein the second random number is generated by the server based on the successful verification of the received user account and the user password; the generating module 51 is also used to generate a business token to be verified based on the first random number, the second random number and the target business environment identifier; wherein the target business environment identifier is one of the business environment identifiers corresponding to each business environment; the sending module 53 is used to send the business token to be verified to the server.
[0143] In one implementation, the above-mentioned generation module 51 can be specifically used to generate a second user key based on the first random number and the second random number; generate original business token information based on the second user key and the timestamp of the second user key; determine the original business token based on the second user key and the original business token information; determine the business token to be verified based on the second user key, the original business token, and the target business environment number corresponding to the target business environment identifier.
[0144] In one implementation, the above-mentioned generation module 51 can be specifically used to process the second user key and the original business token information respectively through the SM3 hash algorithm to generate a first hash value and a second hash value; perform an OR operation on the values at corresponding positions of the first hash value and the second hash value to obtain a first value; perform modulo processing on the first value and the preset token length to obtain a second value; when the length of the second value is less than the preset token length, perform zero padding on the second value to obtain the original business token.
[0145] The verification device of the service token in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device, and exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., and the embodiment of the present application does not make specific limitations.
[0146] The verification device of the service token in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0147] The verification device for the service token provided in the embodiment of the present application can realize Figures 1 to 3 To avoid repetition, the various processes implemented in the illustrated method embodiment will not be described again here.
[0148] The embodiment of the present application also provides an electronic device, which is used to execute the above-mentioned service token verification method. Figure 6 A schematic diagram of the structure of an electronic device for implementing various embodiments of the present application. The electronic device may have relatively large differences due to different configurations or performances, and may include a processor (processor) 601, a communication interface (Communications Interface) 602, a memory (memory) 603 and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604. The processor 601 can call a computer program stored in the memory 603 and can be run on the processor 601 to execute the various steps of the above-mentioned business token verification method embodiment, and can achieve the same technical effect, so it will not be repeated here to avoid repetition.
[0149] It should be noted that the electronic devices in the embodiments of the present application include: servers, terminals, or other devices except terminals.
[0150] The above electronic device structure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, the input unit may include a graphics processing unit (GPU) and a microphone, and the display unit may be configured with a display panel in the form of a liquid crystal display, an organic light-emitting diode, etc. The user input unit includes a touch panel and at least one of other input devices. The touch panel is also called a touch screen. Other input devices may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0151] The memory can be used to store software programs and various data. The memory may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory may include a volatile memory or a non-volatile memory, or the memory may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DRRAM).
[0152] The processor may include one or more processing units; optionally, the processor integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to the operating system, user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor.
[0153] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned business token verification method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0154] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0155] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned business token verification method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0156] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0157] An embodiment of the present application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes a program or instructions. When the program or instructions are executed, the various processes of the above-mentioned business token verification method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they will not be repeated here.
[0158] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0159] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0160] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A method for verifying a business token, characterized in that: Applied to the server, including: Receive the business token to be verified sent by the client; Determine the target business environment identifier corresponding to the business token to be verified according to the business token to be verified and the first user key; wherein the target business environment identifier is used to identify the target business environment; The service token to be verified is verified according to the target service token corresponding to the target service environment.
2. The method according to claim 1, characterized in that The step of determining, according to the service token to be verified and the first user key, a target service environment identifier corresponding to the service token to be verified includes: Extracting the original business token and the target business environment number from the business token to be verified; The target business environment identifier is determined according to the first user key, the original business token, and the target business environment number.
3. The method according to claim 2, characterized in that The step of determining the target business environment identifier according to the first user key, the original business token, and the target business environment number includes: Concatenate the original business token with the first user key to obtain a first result; Add the values of each bit in the first result after hash processing to obtain a second result; Perform modulo processing on the second result and the token length of the original business token to obtain a third result; The target business environment identifier is determined according to the target business environment number and the third result.
4. The method according to claim 2, characterized in that: The verifying the to-be-verified business token according to the target business token corresponding to the target business environment includes: According to the target business environment identifier, obtaining a target user key corresponding to the target business environment; Generate business token information corresponding to the target business environment according to the target user key and the timestamp of the target user key; Determine a target service token corresponding to the target service environment according to the target user key and the service token information; The service token to be verified is verified by comparing the value of the target service token with the value of the original service token.
5. The method according to claim 4, characterized in that The verifying the to-be-verified business token by comparing the value of the target business token with the value of the original business token includes: When the value of the target service token is the same as the value of the original service token, it is determined that the service token to be verified passes the verification.
6. The method according to claim 1, characterized in that Before receiving the service token to be verified sent by the client, the method further includes: Receiving a user account, a user password and a first random number sent by the client; If the user account and the user password are successfully verified, generating a second random number; The first user key is generated according to the first random number and the second random number.
7. The method according to claim 6, characterized in that When the verification of the user account and the user password succeeds, after generating the second random number, the method further includes: The second random number and the business environment identifier corresponding to each business environment are sent to the client.
8. A method for verifying a business token, characterized in that: Applied to the client, including: In response to the input user account and user password, generate a first random number; Receiving a second random number and a business environment identifier corresponding to each business environment sent by the server; wherein the second random number is generated by the server based on a successful verification of the received user account and the received user password; Generate a business token to be verified according to the first random number, the second random number and the target business environment identifier; wherein the target business environment identifier is one of the business environment identifiers corresponding to each of the business environments; The business token to be verified is sent to the server.
9. The method according to claim 8, characterized in that The generating a service token to be verified according to the first random number, the second random number and the target service environment identifier includes: Generate a second user key according to the first random number and the second random number; Generate original business token information according to the second user key and the timestamp of the second user key; Determine the original service token according to the second user key and the original service token information; The business token to be verified is determined according to the second user key, the original business token, and the target business environment number corresponding to the target business environment identifier.
10. The method according to claim 9, characterized in that The determining the original service token according to the second user key and the original service token information includes: The second user key and the original business token information are processed respectively by the SM3 hash algorithm to generate a first hash value and a second hash value; Perform an OR operation on the values at corresponding positions of the first hash value and the second hash value to obtain a first value; Perform modulo processing on the first value and a preset token length to obtain a second value; When the length of the second value is less than the preset token length, the second value is padded with zeros to obtain the original service token.
11. A business token verification device, characterized in that: include: A receiving module, used for receiving a business token to be verified sent by a client; A determination module, configured to determine a target business environment identifier corresponding to the business token to be verified according to the business token to be verified and a first user key; wherein the target business environment identifier is used to identify a target business environment; The verification module is used to verify the business token to be verified according to the target business token corresponding to the target business environment.
12. The device according to claim 11, characterized in that The determination module comprises: An extraction unit, used to extract the original service token and the target service environment number from the service token to be verified; A determination unit is used to determine the target business environment identifier according to the first user key, the original business token, and the target business environment number.
13. The device according to claim 12, characterized in that The determining unit is specifically used for: Concatenate the original business token with the first user key to obtain a first result; Add the values of each bit in the first result after hash processing to obtain a second result; Perform modulo processing on the second result and the token length of the original business token to obtain a third result; The target business environment identifier is determined according to the target business environment number and the third result.
14. A business token verification device, characterized in that: include: A generating module, used for generating a first random number in response to an input user account and a user password; A receiving module, used to receive a second random number sent by a server and a business environment identifier corresponding to each business environment; wherein the second random number is generated by the server based on a successful verification of the received user account and the received user password; The generating module is further used to generate a to-be-verified business token according to the first random number, the second random number and the target business environment identifier; wherein the target business environment identifier is one of the business environment identifiers corresponding to the respective business environments; A sending module is used to send the service token to be verified to the server.
15. The device according to claim 14, characterized in that The generation module is specifically used for: Generate a second user key according to the first random number and the second random number; Generate original business token information according to the second user key and the timestamp of the second user key; Determine the original service token according to the second user key and the original service token information; The business token to be verified is determined according to the second user key, the original business token, and the target business environment number corresponding to the target business environment identifier.
16. An electronic device, characterized in that: It includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor. When the program or instruction is executed by the processor, it implements the steps of the business token verification method as described in any one of claims 1 to 7, or implements the steps of the business token verification method as described in any one of claims 8 to 10.
17. A readable storage medium, characterized in that: The readable storage medium stores programs or instructions, and when the programs or instructions are executed by the processor, the steps of the business token verification method as described in any one of claims 1 to 7 are implemented, or the steps of the business token verification method as described in any one of claims 8 to 10 are implemented.
18. A computer program product, characterized in that The computer program product includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes a program or instructions, which, when executed, implements the steps of the business token verification method as described in any one of claims 1 to 7, or implements the steps of the business token verification method as described in any one of claims 8 to 10.
Citation Information
Patent Citations
Method, system and device for processing terminal application request
CN102572815A
Login access method and device for service system, storage medium and processor
CN108881232A
Information verification method, related device, equipment and storage medium
CN112733107A
Verification method and device of verification code token, electronic equipment and storage medium
CN114143027A
Data access method and device, storage medium and electronic equipment
CN115987650A