Method, device and system for downgrading token generation service
By using the client to start the local token generation service when the token server is abnormal, and synchronizing the data when the service is restored, the problem of the abnormality of the token server affecting the business is solved and the high availability of the token service is improved.
Patent Information
- Application Number
- CN202111229586.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-21
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-10-21
AI Technical Summary
When the centrally deployed token service system is abnormal when generating token values, it will affect the business process and the high availability of the token service, causing the client to be unable to use sensitive information normally.
The client continuously detects whether the token generation service of the token server is normal. If it is abnormal, it starts the local token generation service, generates the ciphertext data and token value corresponding to the plaintext data, and sends the data back to the token server when the service is restored, closing the local service. .
This ensures that even if the token generation service on the token server is abnormal, the client can still generate token values to avoid affecting the business process, and synchronize the generated data back to the token server when the service is restored, improving the high availability of the token service.
Smart Images

Figure CN113986572B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device and system for downgrading a token generation service. Background Art
[0002] With the rapid development of computer technology, the security of sensitive information has received more and more attention, and the tokenization solution of sensitive information has also emerged. The tokenization solution is: a unique identification information is randomly generated for each plain text of sensitive information. The unique identification information is the token value corresponding to the plain text of the sensitive information. When the data is transmitted in various business systems, the token value can be used to replace the plain text transmission of sensitive information to avoid the leakage of sensitive information as much as possible. For example, in a consumer application, the user's phone number, bank card number, etc. are all sensitive information. When the user enters this sensitive information in the application for the first time, the token service system of the application will encrypt the plain text of this sensitive information to generate ciphertext, and generate the token value and hash value corresponding to the sensitive information, and store these three types of data in the database. When these sensitive information are needed for business processing later, the token value can be directly transmitted in each business system instead of the plain text of the sensitive information, thereby improving the security of sensitive information.
[0003] Since the token service system is centrally deployed, if the token generation service in the token service system is abnormal, that is, the token value corresponding to the sensitive information cannot be generated, then a series of clients corresponding to the token service system will not be able to call it, affecting the business and the high availability of the token service. Summary of the invention
[0004] The embodiment of the present application provides a method for downgrading a token generation service, which can solve the problem in the prior art that affects the progress of business and the high availability of token services.
[0005] In a first aspect, a method for downgrading a token generation service is provided, the method comprising:
[0006] Continuously check whether the token generation service on the token server is normal;
[0007] When an abnormality in the token generation service of the token server is detected, the local token generation service is started;
[0008] During the operation of the local token generation service, whenever plaintext data to be stored is obtained, ciphertext data and a first token value corresponding to the plaintext data are generated, and the ciphertext data and the first token value corresponding to the plaintext data are stored;
[0009] When it is detected that the token generation service of the token server is restored to normal, the stored ciphertext data and the first token value are sent to the token server, and the local token generation service is closed.
[0010] In a possible implementation, the continuously detecting whether the token generation service of the token server is normal includes:
[0011] Periodically sending sample plaintext data to the token server;
[0012] Calculate the ratio of the number of second token values corresponding to the sample plaintext data received within the preset time length to the number of sample plaintext data sent to the token server within the preset time length, as the success rate of the token generation service of the token server within the preset time length;
[0013] When the success rate is greater than the preset success rate threshold, it is determined that the token generation service of the token server is normal;
[0014] When the success rate is less than or equal to the preset success rate threshold, it is determined that the token generation service of the token server is abnormal.
[0015] In a possible implementation, the local includes a token-SDK (Software Development Kit), and the token-SDK has a token generation service;
[0016] When the token generation service of the token server is detected to be abnormal, starting the local token generation service includes: when the token generation service of the token server is detected to be abnormal, starting the token-SDK.
[0017] In a possible implementation manner, before generating the ciphertext data corresponding to the plaintext data and the first token value, the method further includes:
[0018] Sending a token value query request to the token server, wherein the token value query request carries the plaintext data;
[0019] Receive a non-query notification sent by the token server, wherein the non-query notification is used to indicate that the first token value or the second token value of the plaintext data is not queried at the token server.
[0020] In a possible implementation, generating the ciphertext data and the first token value corresponding to the plaintext data includes:
[0021] Encrypt the plaintext data based on a plaintext encryption algorithm to obtain ciphertext data corresponding to the plaintext data;
[0022] A hash calculation is performed on the plaintext data based on a first hash algorithm to obtain a first hash value corresponding to the plaintext data as a first token value corresponding to the plaintext data.
[0023] In a possible implementation, when it is detected that the token generation service of the token server is restored to normal, sending the stored ciphertext data and the first token value to the token server includes:
[0024] When it is detected that the token generation service of the token server has returned to normal, determining the abnormal period of the token generation service of the token server based on the time point at which the token generation service of the token server was detected to be abnormal and the time point at which the token generation service of the token server was detected to be normal;
[0025] The stored ciphertext data generated during the abnormal period and the first token value are sent to the token server.
[0026] In a second aspect, a method for downgrading a token generation service is provided, the method comprising:
[0027] Receiving ciphertext data and a first token value sent by a client, wherein the ciphertext data and the first token value are generated by the client during an abnormal period of a token generation service of the token server;
[0028] Based on the ciphertext data generated by the client, determining a second hash value corresponding to the ciphertext data;
[0029] The ciphertext data, the first token value and the second hash value are stored.
[0030] In a possible implementation, determining, based on the ciphertext data generated by the client, a second hash value corresponding to the ciphertext data includes:
[0031] Decompressing the ciphertext data based on a ciphertext decompression algorithm to obtain plaintext data corresponding to the ciphertext data;
[0032] A hash calculation is performed on the plaintext data corresponding to the ciphertext data based on a second hash algorithm to obtain a second hash value corresponding to the ciphertext data.
[0033] In a possible implementation, the method further includes:
[0034] Receiving sample plaintext data sent by the client;
[0035] Generate a second token value corresponding to the sample plaintext data based on the token generation service;
[0036] Send a second token value corresponding to the sample plaintext data to the client.
[0037] In a possible implementation, the method further includes:
[0038] Receive a token value query request sent by the client, wherein the token value query request carries plaintext data;
[0039] Performing a hash calculation on the plaintext data based on a second hash algorithm to obtain a second hash value corresponding to the plaintext data;
[0040] Based on the second hash value corresponding to the plaintext data, detecting whether the second hash value exists in the token server;
[0041] If it exists, the first token value or the second token value corresponding to the second hash value is sent to the client; if it does not exist, a notification of not finding the query is sent to the client.
[0042] In a third aspect, a downgrade device for a token generation service is provided, the device comprising:
[0043] The detection module is used to continuously detect whether the token generation service of the token server is normal;
[0044] A startup module, used to start the local token generation service when detecting that the token generation service of the token server is abnormal;
[0045] A generation module, configured to generate ciphertext data and a first token value corresponding to the plaintext data and store the ciphertext data and the first token value corresponding to the plaintext data whenever obtaining plaintext data to be stored during the operation of the local token generation service;
[0046] The sending module is used to send the stored ciphertext data and the first token value to the token server and close the local token generation service when it is detected that the token generation service of the token server is restored to normal.
[0047] In a possible implementation, the detection module is used to:
[0048] Periodically sending sample plaintext data to the token server;
[0049] Calculate the ratio of the number of second token values corresponding to the sample plaintext data received within the preset time length to the number of sample plaintext data sent to the token server within the preset time length, as the success rate of the token generation service of the token server within the preset time length;
[0050] When the success rate is greater than the preset success rate threshold, it is determined that the token generation service of the token server is normal;
[0051] When the success rate is less than or equal to the preset success rate threshold, it is determined that the token generation service of the token server is abnormal.
[0052] In a possible implementation, the local includes a token-SDK, and the token-SDK has a token generation service;
[0053] The startup module is used to: when it is detected that the token generation service of the token server is abnormal, start the token-SDK.
[0054] In a possible implementation, the generating module is further used to:
[0055] Sending a token value query request to the token server, wherein the token value query request carries the plaintext data;
[0056] Receive a non-query notification sent by the token server, wherein the non-query notification is used to indicate that the first token value or the second token value of the plaintext data is not queried at the token server.
[0057] In a possible implementation, the generating module is used to:
[0058] Encrypt the plaintext data based on a plaintext encryption algorithm to obtain ciphertext data corresponding to the plaintext data;
[0059] A hash calculation is performed on the plaintext data based on a first hash algorithm to obtain a first hash value corresponding to the plaintext data as a first token value corresponding to the plaintext data.
[0060] In a possible implementation, the sending module is used to:
[0061] When it is detected that the token generation service of the token server has returned to normal, determining the abnormal period of the token generation service of the token server based on the time point at which the token generation service of the token server was detected to be abnormal and the time point at which the token generation service of the token server was detected to be normal;
[0062] The stored ciphertext data generated during the abnormal period and the first token value are sent to the token server.
[0063] In a fourth aspect, a downgrading device for a token generation service is provided, the device comprising:
[0064] A receiving module, configured to receive ciphertext data and a first token value sent by a client, wherein the ciphertext data and the first token value are generated by the client during an abnormal period of a token generation service of the token server;
[0065] A determination module, configured to determine a second hash value corresponding to the ciphertext data based on the ciphertext data generated by the client;
[0066] A storage module is used to store the ciphertext data, the first token value and the second hash value.
[0067] In a possible implementation manner, the determining module is used to:
[0068] Decompressing the ciphertext data based on a ciphertext decompression algorithm to obtain plaintext data corresponding to the ciphertext data;
[0069] A hash calculation is performed on the plaintext data corresponding to the ciphertext data based on a second hash algorithm to obtain a second hash value corresponding to the ciphertext data.
[0070] In a possible implementation, the device further includes a sample detection module, which is used to:
[0071] Receiving sample plaintext data sent by the client;
[0072] Generate a second token value corresponding to the sample plaintext data based on the token generation service;
[0073] Send a second token value corresponding to the sample plaintext data to the client.
[0074] In a possible implementation manner, the device further includes a query module, configured to:
[0075] Receive a token value query request sent by the client, wherein the token value query request carries plaintext data;
[0076] Performing a hash calculation on the plaintext data based on a second hash algorithm to obtain a second hash value corresponding to the plaintext data;
[0077] Based on the second hash value corresponding to the plaintext data, detecting whether the second hash value exists in the token server;
[0078] If it exists, the first token value or the second token value corresponding to the second hash value is sent to the client; if it does not exist, a notification of not finding the query is sent to the client.
[0079] In a fifth aspect, a token generation service downgrade system is provided, the system comprising a client and a token server, wherein:
[0080] The client is used to continuously detect whether the token generation service of the token server is normal; when the token generation service of the token server is detected to be abnormal, the local token generation service is started; during the operation of the local token generation service, whenever the plaintext data to be stored is obtained, the ciphertext data and the first token value corresponding to the plaintext data are generated, and the ciphertext data and the first token value corresponding to the plaintext data are stored; when it is detected that the token generation service of the token server is restored to normal, the stored ciphertext data and the first token value are sent to the token server, and the local token generation service is closed;
[0081] The token server is used to receive ciphertext data and a first token value sent by the client, wherein the ciphertext data and the first token value are generated by the client during an abnormal period of the token generation service of the token server; determine a second hash value corresponding to the ciphertext data based on the ciphertext data generated by the client; and store the ciphertext data, the first token value, and the second hash value.
[0082] In a sixth aspect, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one instruction, and the instruction is loaded and executed by the processor to implement the operations performed by the downgrading method of the token generation service.
[0083] In a seventh aspect, a computer-readable storage medium is provided, wherein at least one instruction is stored in the storage medium, and the instruction is loaded and executed by a processor to implement the operations performed by the method for downgrading a token generation service.
[0084] The beneficial effect of the technical solution provided by the embodiment of the present application is as follows: the solution mentioned in the embodiment of the present application can detect that the token generation service of the token server is abnormal, and the client starts the local token generation service. When the plaintext data to be stored is obtained, the token generation service of the client generates the ciphertext data and the first token value corresponding to the plaintext data, so that even if the token generation service of the token server is abnormal, the client can still generate the first token value corresponding to the plaintext data, without affecting the continuation of the business. When the token generation service of the token server returns to normal, the client will send the generated ciphertext data and the first token value to the token server, and the token server will generate the second hash value corresponding to the ciphertext data according to the received ciphertext data, and then store the ciphertext data, the first token value and the second hash value accordingly, so that the token server can still store the data generated by the client during the abnormality after returning to normal, so that the subsequent business of the token server will not be affected. Therefore, by adopting this solution, the business will not be affected by the abnormality of the token generation service of the token server, and the high availability of the token service is effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0086] Figure 1 is a schematic diagram of a network architecture provided in an embodiment of the present application;
[0087] Figure 2 It is a flowchart of a method for downgrading a token generation service provided in an embodiment of the present application;
[0088] Figure 3 It is a schematic diagram of an abnormal period of a token generation service of a token server provided in an embodiment of the present application;
[0089] Figure 4It is a schematic diagram of an abnormal period of a token generation service of a token server provided in an embodiment of the present application;
[0090] Figure 5 It is a flow chart of a method for detecting whether a token generation service of a token server is normal, provided in an embodiment of the present application;
[0091] Figure 6 It is a flowchart of a method for detecting whether a token generation service of a token server is normal, provided in an embodiment of the present application;
[0092] Figure 7 It is a flow chart of a method for determining whether a token server stores a token value corresponding to plaintext data provided by an embodiment of the present application;
[0093] Figure 8 It is a schematic diagram of a process of a client sending ciphertext data and a first token value to a token server provided in an embodiment of the present application;
[0094] Fig. 9 It is a schematic diagram of a process of a client sending ciphertext data and a first token value to a token server provided in an embodiment of the present application;
[0095] Fig.10 It is a structural schematic diagram of a downgrading device for a token generation service provided in an embodiment of the present application;
[0096] Fig.11 It is a structural schematic diagram of a downgrading device for a token generation service provided in an embodiment of the present application;
[0097] Fig.12 It is a structural block diagram of a terminal provided in an embodiment of the present application;
[0098] Fig.13 It is a structural block diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0099] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0100] An embodiment of the present application provides a method for downgrading a token generation service, which can be jointly completed by multi-side computer devices. The multi-side computer devices may include a client side and a token server side. The client may be a terminal and a server, etc. The terminal may be a desktop computer, a basic computer, a tablet computer, a mobile phone, etc. The server may be a single server or a server cluster, etc. The token server may be a server. Figure 1A possible network architecture provided by an embodiment of the present invention is shown. Figure 1 As shown, data can be transmitted between the client and the token server.
[0101] A computer device may include a processor, memory, communication components, etc.
[0102] The processor can be a CPU (central processing unit), which can be used to read instructions and process data. For example, as a processor on the client side, it can detect whether the token generation service of the token server is normal, can start the local token generation service, can generate ciphertext data and a first token value corresponding to the plaintext data, and so on; as a processor on the token server side, it can determine the second hash value corresponding to the ciphertext data based on the ciphertext data generated by the client, and can generate ciphertext data corresponding to the plaintext data, a second token value and a second hash value based on the received plaintext data, and so on.
[0103] The memory may include ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic disk, optical data storage device, etc. The memory may be used for data storage. For example, as a memory on the client side, it may store data for starting a local token generation service, may store ciphertext data and a first token value corresponding to the generated plaintext data, etc.; as a memory on the token server side, it may store ciphertext data and a first token value sent by the client, may store a second hash value corresponding to the ciphertext data determined based on the ciphertext data sent by the client, may store ciphertext data, a second token value, and a second hash value determined based on the plaintext data, etc.
[0104] The communication component may be a wired network connector, a WiFi (wireless fidelity) module, a Bluetooth module, a cellular network communication module, etc. The communication component may be used to receive and send signals. For example, as a communication component on the client side, it may receive plaintext data, send ciphertext data and a first token value to the token server, etc.; as a communication component on the token server side, it may receive plaintext data, receive ciphertext data and a first token value sent by the client, etc.
[0105] The plaintext data in the embodiments of the present application may be sensitive information of a user on an application or website, for example, the user's mobile phone number or bank card number, etc. The plaintext data of sensitive information refers to the specific content of the sensitive information, that is, the sensitive information when it is not encrypted, for example, the clear number of a mobile phone number or the clear card number of a bank card number, etc. The ciphertext data corresponding to the plaintext data refers to the encrypted data obtained by compressing and encrypting the plaintext data based on the plaintext encryption algorithm.
[0106] After receiving the plaintext data to be stored sent by the client, the token server can generate the ciphertext data, the second token value and the second hash value corresponding to the plaintext data, that is, encrypt the plaintext data based on the plaintext encryption algorithm to obtain the ciphertext data corresponding to the plaintext data, generate the second token value corresponding to the plaintext data based on the token generation algorithm, and perform hash calculation on the plaintext data based on the second hash algorithm to obtain the second token value corresponding to the plaintext data. Since the second token value is randomly generated and has nothing to do with the plaintext data, the security of sensitive information can be improved.
[0107] In order to ensure that each sensitive information corresponds to only one token value, a corresponding second hash value will also be generated for the plaintext data. The second hash value is obtained based on the plaintext data. The same plaintext data can only obtain the same second hash value, and different plaintext data correspond to different second hash values. Therefore, the ciphertext data, the second token value and the second hash value corresponding to the plaintext data can be stored accordingly. When the token server receives a plaintext data to be stored sent by the client, it can first perform a hash calculation on the plaintext data based on the second hash algorithm to obtain a second hash value corresponding to the plaintext data, and then search in the database of the token server whether the second hash value exists. If so, it means that a token value corresponding to the plaintext data has been generated before (the token value in the embodiment of the present application may be the first token value or the second token value), and the token value corresponding to the plaintext data can be directly sent to the client; if the second hash value does not exist in the database, it means that the token value corresponding to the plaintext data has not been generated before, and the corresponding second token value can be generated for the plaintext data based on the token generation service, and then the second token value corresponding to the plaintext data is sent to the client, and the ciphertext data and the second hash value corresponding to the plaintext data are generated, and then the ciphertext data, the second token value and the second hash value corresponding to the plaintext data are stored in the database accordingly.
[0108] The above is the processing when the token generation service of the token server is normal. When the token server encounters network failure, CPU full load, etc., the token generation service of the token server will be abnormal and unable to generate the second token value corresponding to the plaintext data. At this time, the token generation service can be implemented according to the downgrade method of the token generation service provided in this application. The following is a detailed description of this application.
[0109] Figure 2 This is a flowchart of a token generation service downgrade method provided in an embodiment of the present application. Figure 2 , the embodiment comprises:
[0110] 201. The client continuously detects whether the token generation service of the token server is normal.
[0111] In implementation, no matter whether the token generation service of the token server is normal or abnormal, the client will continuously detect the token generation service of the token server to determine whether the token generation service of the token server is normal.
[0112] 202. When the token generation service of the token server is detected to be abnormal, the client starts the local token generation service.
[0113] In implementation, when the token generation service of the token server is abnormal, the token server can no longer generate the second token value corresponding to the plaintext data. At this time, the client no longer needs to send the plaintext data to the token server, but can start the local token generation service to perform token generation processing on the stored plaintext data.
[0114] The specific setting of the token generation service of the client may be: the client includes a token-SDK, and the token-SDK has a token generation service. When an abnormality of the token generation service of the token server is detected, the client starts the token-SDK.
[0115] In practice, the communication between the client and the token server requires the client to introduce the SDK of the token server, namely, token-SDK. In the embodiment of the present application, the token-SDK has a token generation service. When the client detects that the token generation service of the token server is abnormal, the token-SDK can be started.
[0116] 203. During the operation of the local token generation service, whenever the client obtains plaintext data to be stored, the client generates ciphertext data and a first token value corresponding to the plaintext data, and stores the ciphertext data and the first token value corresponding to the plaintext data.
[0117] In implementation, during the operation of the client's token generation service, when a plaintext data to be stored is received, the client needs to first determine whether the token server has stored the token value (first token value or second token value) corresponding to the plaintext data. If it is found that the token value corresponding to the plaintext data has been stored, the token value can be directly obtained by the token server and stored in the client. If it is found that the token value corresponding to the plaintext data is not stored in the token server, the client can locally generate the ciphertext data and the first token value corresponding to the plaintext data, and store them in the local database. The method by which the client determines whether the token server stores the token value corresponding to the plaintext data will be described in detail in the subsequent content, and will not be repeated here.
[0118] Optionally, the method for generating ciphertext data and the first token value corresponding to the plaintext data on the client may be: compressing the plaintext data based on a plaintext compression algorithm to obtain the ciphertext data corresponding to the plaintext data. Performing hash calculation on the plaintext data based on a first hash algorithm to obtain a first hash value corresponding to the plaintext data as the first token value corresponding to the plaintext data.
[0119] In implementation, since the token server is centrally deployed, it can connect to multiple clients. When two different clients perform token generation services for the same plaintext data at the same time, in order to ensure that the same plaintext data only corresponds to a unique token value, the token generation service set up locally on the client can use a first hash algorithm to generate a corresponding first hash value, and use the first hash value as the first token value corresponding to the plaintext data. Since the first hash value is generated based on the specific content of the plaintext data, the same plaintext data will only generate the same first hash value. Therefore, the first hash value is used as the first token value corresponding to the plaintext data, and the same plaintext data will only correspond to the same first token value, thereby ensuring the uniqueness of the token value.
[0120] It can be understood that the first hash algorithm and the second hash algorithm used in the token server are both algorithms based on hash algorithms, but for the same plaintext data, the first hash value obtained based on the first hash algorithm and the second hash value obtained based on the second hash algorithm are different.
[0121] 204. When it is detected that the token generation service of the token server is restored to normal, the client sends the stored ciphertext data and the first token value to the token server and closes the local token generation service.
[0122] In implementation, when the client detects that the token generation service of the token server has returned to normal, the client will send the ciphertext data and the first token value corresponding to the plaintext data generated during the abnormal period of the token generation service of the token server to the token server, and close the token generation service of the client. When the client subsequently obtains the plaintext data to be stored, it directly sends the plaintext data to be stored to the token server that has returned to normal. The token server generates the ciphertext data, the second token value and the second hash value corresponding to the plaintext data, and stores them in the database of the token server.
[0123] The corresponding processing for the client to determine the abnormal period of the token generation service of the token server can be: when it is detected that the token generation service of the token server has returned to normal, the abnormal period of the token generation service of the token server is determined based on the time point when the token generation service of the token server was detected to be abnormal and the time point when the token generation service of the token server was detected to be restored to normal.
[0124] In implementation, the client needs to obtain the time point when the token generation service of the token server is abnormal and the time point when the token generation service of the token server is restored to normal. These two time points can be directly used as the lower limit and upper limit of the abnormal period, respectively, to determine the abnormal period, such as Figure 3 Alternatively, an extended duration may be pre-set, and the time point at which the token generation service of the token server is determined to be abnormal minus the extended duration, and the time point after the extended duration is subtracted is used as the lower limit of the abnormal period. At the same time, the time point at which the token generation service of the token server is determined to be restored to normal is added with the extended duration, and the time point after the extended duration is added is used as the upper limit of the abnormal period, thereby obtaining the abnormal period, as shown in FIG. Figure 4 Optionally, the preset extension period may be any reasonable value, for example, 1 minute, etc.
[0125] 205. The token server receives the ciphertext data and the first token value sent by the client.
[0126] The ciphertext data and the first token value are generated by the client during an abnormal period of the token generation service of the token server.
[0127] 206. Based on the ciphertext data generated by the client, the token server determines a second hash value corresponding to the ciphertext data.
[0128] In implementation, it is necessary to store the ciphertext data and the first token value corresponding to the plaintext data generated by the client when the token generation service of the token server is abnormal in the database of the token server, and when storing, it is also necessary to store the second hash value corresponding to the plaintext data. Therefore, before storing the ciphertext data and the first token value, it is also necessary to generate the second hash value corresponding to the plaintext data. At this time, the second hash value corresponding to the plaintext data can be obtained based on the ciphertext data corresponding to the plaintext data.
[0129] Optionally, the process of obtaining the second hash value corresponding to the plaintext data based on the ciphertext data may be: decompressing the ciphertext data based on a ciphertext decompression algorithm to obtain the plaintext data corresponding to the ciphertext data. Performing hash calculation on the plaintext data corresponding to the ciphertext data based on a second hash algorithm to obtain the second hash value corresponding to the ciphertext data.
[0130] In implementation, the token server can decompress the ciphertext data corresponding to the received plaintext data based on the ciphertext decompression algorithm to obtain the plaintext data, and then perform hash calculation on the plaintext data based on the second hash algorithm to obtain the second hash value corresponding to the plaintext data (that is, the second hash value corresponding to the above-mentioned ciphertext data).
[0131] 207. The token server stores the ciphertext data, the first token value, and the second hash value.
[0132] In implementation, after obtaining the second hash value, the ciphertext data, the first token value and the second hash value may be correspondingly stored in a database of the token server.
[0133] In step 201, the method for detecting whether the token generation service of the token server is normal can be as follows: Figure 5 and Figure 6 As shown, the detection process corresponds to the following:
[0134] 201a. The client periodically sends sample plaintext data to the token server.
[0135] The sample plaintext data may be plaintext data generated according to a preset algorithm. The period of sending the sample plaintext data may be preset by a technician, for example, an average of 20 sample plaintext data may be sent per second.
[0136] 201b. The token server receives the sample plaintext data sent by the client.
[0137] 201c. The token server generates a second token value corresponding to the sample plaintext data based on the token generation service.
[0138] 201d. The token server sends the second token value corresponding to the sample plaintext data to the client.
[0139] 201e. The client calculates the ratio of the number of second token values corresponding to the sample plaintext data received within the preset time and the number of sample plaintext data sent to the token server within the preset time as the success rate of the token generation service of the token server within the preset time.
[0140] If the client can receive the second token value corresponding to the sample plaintext data within a certain period of time after sending sample plaintext data to the token server, it means that the token generation service of the token server is normal; if the client does not receive the second token value corresponding to the sample plaintext data within a certain period of time after sending sample plaintext data to the token server, or receives a network failure notification, generation exception notification, etc., it means that the token generation service of the token server is abnormal.
[0141] In implementation, technicians can pre-set the preset time. The client can determine the number of second token values corresponding to the sample plaintext data sent by the token server and received within the most recent preset time, and the number of sample plaintext data sent by the client to the token server within the most recent preset time, and then use the ratio between the two as the success rate of the token generation service of the token server in the time period corresponding to the preset time.
[0142] Optionally, the preset duration may be set to any reasonable value, for example, 10s or 20s, etc., which is not limited in the embodiments of the present application.
[0143] 201f. When the success rate is greater than the preset success rate threshold, the client determines that the token generation service of the token server is normal; when the success rate is less than or equal to the preset success rate threshold, the client determines that the token generation service of the token server is abnormal.
[0144] Optionally, after the client detects an abnormality in the token generation service of the token server, when the client detects that the token generation service of the token server is normal for the first time (that is, when the success rate is greater than a preset success rate threshold), the time point when the normal state is detected can be recorded. At this time, the token generation service of the token server is still not defined as restored to normal, but continues to be detected. If the token generation service of the token server remains normal within the preset reference time period after the normal time point is detected, it can be determined that the token generation service of the token server has returned to normal.
[0145] Optionally, the preset success rate threshold may be any reasonable value, for example, 60%, etc., which is not limited in the embodiment of the present application.
[0146] Optionally, the client may be provided with a detector, which may be used to execute the processing of 201a, 201e and 201f. The detector may be a software program provided in the token-SDK.
[0147] In step 203, the client determines whether the token server stores the token value corresponding to the plaintext data. Figure 7 As shown, the corresponding ones are as follows:
[0148] 203a. The client sends a token value query request to the token server, wherein the token value query request carries plaintext data.
[0149] 203b. The token server receives the token value query request sent by the client.
[0150] The token value query request carries plain text data.
[0151] 203c. The token server performs hash calculation on the plaintext data based on the second hash algorithm to obtain a second hash value corresponding to the plaintext data.
[0152] 203d. The token server detects whether the second hash value exists in the token server based on the second hash value corresponding to the plaintext data. In implementation, it may be detected whether the calculated second hash value exists in the database of the token server.
[0153] 203e. If it exists, the token server sends the first token value or the second token value corresponding to the second hash value to the client; if it does not exist, the token server sends a non-query notification to the client. The non-query notification is used to indicate that the first token value or the second token value of the plaintext data is not queried at the token server.
[0154] In implementation, if the token server has a second hash value corresponding to the plaintext data, it means that the ciphertext data, token value and second hash value corresponding to the plaintext data have been generated before. At this time, the token value corresponding to the stored second hash value can be directly sent to the client.
[0155] If the second hash value corresponding to the plaintext data is not detected in the token server, it means that the ciphertext data, token value and second hash value corresponding to the plaintext data have not been generated before. At this time, the token server can send a notification of no query to the client.
[0156] 203f. The client receives the first token value corresponding to the plaintext data or the second token value corresponding to the plaintext data sent by the token server, or a notification that no query was found.
[0157] In implementation, if the client receives the first token value or the second token value corresponding to the plaintext data sent by the token server, it means that the token server stores the token value corresponding to the plaintext data. If the client receives a notification sent by the token server that no query was found, it means that the token server does not store the token value corresponding to the plaintext data.
[0158] In step 204, there are many possible ways to trigger the client to send the ciphertext data and the first token value to the token server, and the following are two of them:
[0159] The first
[0160] like Figure 8 As shown, when the client detects that the token generation service of the token server has returned to normal, it can directly trigger the sending of the ciphertext data generated by the client during the abnormal period of the token generation service of the token server and the corresponding first token value to the token server.
[0161] The second
[0162] like Fig. 9As shown, when it is detected that the token generation service of the token server has returned to normal, the client sends a token storage notification to the token server, wherein the token storage notification carries the abnormal period of the token server. The token server receives the token storage notification sent by the client. The token server sends a storage acquisition request to the client, wherein the storage acquisition request carries the abnormal period of the token server. The client receives the storage acquisition request sent by the token server. The client sends the ciphertext data generated during the abnormal period and the first token value to the token server.
[0163] In implementation, when the client detects that the token generation service of the token server has returned to normal, it will first determine the abnormal period of the token generation service of the token server (the process of determining the abnormal period is described in detail in the above content and will not be repeated here), and then send a token storage notification to the token server, where the token storage notification carries the abnormal period of the token server.
[0164] The token server receives the token storage notification sent by the client, and then triggers a storage acquisition request to the client, wherein the storage acquisition request also carries the abnormal period of the token server. After receiving the storage acquisition request, the client will send the ciphertext data and the first token value generated during the abnormal period to the token server based on the abnormal period carried in the storage acquisition request.
[0165] Optionally, in addition to the above two triggering modes, other triggering modes may also be used, which are not limited in the embodiments of the present application.
[0166] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0167] The scheme mentioned in the embodiment of the present application can detect that the token generation service of the token server is abnormal, and the client starts the local token generation service. When the plaintext data to be stored is obtained, the token generation service of the client generates the ciphertext data and the first token value corresponding to the plaintext data, so that even if the token generation service of the token server is abnormal, the client can still generate the first token value corresponding to the plaintext data, without affecting the continuation of the business. When the token generation service of the token server returns to normal, the client will send the generated ciphertext data and the first token value to the token server, and the token server will generate the second hash value corresponding to the ciphertext data according to the received ciphertext data, and then store the ciphertext data, the first token value and the second hash value accordingly, so that the token server can still store the data generated by the client during the abnormality after returning to normal, so that the subsequent business of the token server will not be affected. Therefore, by adopting this scheme, the business will not be affected by the abnormality of the token generation service of the token server, and the high availability of the token service is effectively improved.
[0168] The present application embodiment provides a token generation service downgrade device, which may be the computer device in the above embodiment, such as Fig.10 As shown, the device comprises:
[0169] The detection module 1010 is used to continuously detect whether the token generation service of the token server is normal;
[0170] A starting module 1020, configured to start a local token generation service when an abnormality in the token generation service of the token server is detected;
[0171] A generating module 1030, configured to generate ciphertext data and a first token value corresponding to the plaintext data and store the ciphertext data and the first token value corresponding to the plaintext data whenever obtaining plaintext data to be stored during the operation of the local token generating service;
[0172] The sending module 1040 is used to send the stored ciphertext data and the first token value to the token server and close the local token generation service when it is detected that the token generation service of the token server is restored to normal.
[0173] In a possible implementation, the detection module 1010 is used to:
[0174] Periodically sending sample plaintext data to the token server;
[0175] Calculate the ratio of the number of second token values corresponding to the sample plaintext data received within the preset time length to the number of sample plaintext data sent to the token server within the preset time length, as the success rate of the token generation service of the token server within the preset time length;
[0176] When the success rate is greater than the preset success rate threshold, it is determined that the token generation service of the token server is normal;
[0177] When the success rate is less than or equal to the preset success rate threshold, it is determined that the token generation service of the token server is abnormal.
[0178] In a possible implementation, the local includes a token-SDK, and the token-SDK has a token generation service;
[0179] The startup module 1020 is used to start the token-SDK when it is detected that the token generation service of the token server is abnormal.
[0180] In a possible implementation, the generating module 1030 is further configured to:
[0181] Sending a token value query request to the token server, wherein the token value query request carries the plaintext data;
[0182] Receive a non-query notification sent by the token server, wherein the non-query notification is used to indicate that the first token value or the second token value of the plaintext data is not queried at the token server.
[0183] In a possible implementation, the generating module 1030 is used to:
[0184] Encrypt the plaintext data based on a plaintext encryption algorithm to obtain ciphertext data corresponding to the plaintext data;
[0185] A hash calculation is performed on the plaintext data based on a first hash algorithm to obtain a first hash value corresponding to the plaintext data as a first token value corresponding to the plaintext data.
[0186] In a possible implementation, the sending module 1040 is configured to:
[0187] When it is detected that the token generation service of the token server has returned to normal, determining the abnormal period of the token generation service of the token server based on the time point at which the token generation service of the token server was detected to be abnormal and the time point at which the token generation service of the token server was detected to be normal;
[0188] The stored ciphertext data generated during the abnormal period and the first token value are sent to the token server.
[0189] The present application embodiment provides a token generation service downgrade device, which may be the computer device in the above embodiment, such as Fig.11 As shown, the device comprises:
[0190] The receiving module 1110 is configured to receive ciphertext data and a first token value sent by a client, wherein the ciphertext data and the first token value are generated by the client during an abnormal period of a token generation service of the token server;
[0191] A determination module 1120, configured to determine a second hash value corresponding to the ciphertext data based on the ciphertext data generated by the client;
[0192] The storage module 1130 is used to store the ciphertext data, the first token value and the second Hash value.
[0193] In a possible implementation, the determining module 1120 is configured to:
[0194] Decompressing the ciphertext data based on a ciphertext decompression algorithm to obtain plaintext data corresponding to the ciphertext data;
[0195] A hash calculation is performed on the plaintext data corresponding to the ciphertext data based on a second hash algorithm to obtain a second hash value corresponding to the ciphertext data.
[0196] In a possible implementation, the device further includes a sample detection module, which is used to:
[0197] Receiving sample plaintext data sent by the client;
[0198] Generate a second token value corresponding to the sample plaintext data based on the token generation service;
[0199] Send a second token value corresponding to the sample plaintext data to the client.
[0200] In a possible implementation manner, the device further includes a query module, configured to:
[0201] Receive a token value query request sent by the client, wherein the token value query request carries plaintext data;
[0202] Performing a hash calculation on the plaintext data based on a second hash algorithm to obtain a second hash value corresponding to the plaintext data;
[0203] Based on the second hash value corresponding to the plaintext data, detecting whether the second hash value exists in the token server;
[0204] If it exists, the first token value or the second token value corresponding to the second hash value is sent to the client; if it does not exist, a notification of not finding the query is sent to the client.
[0205] The embodiment of the present application provides a token generation service downgrade system, the system comprising a client and a token server, wherein:
[0206] The client is used to continuously detect whether the token generation service of the token server is normal; when the token generation service of the token server is detected to be abnormal, the local token generation service is started; during the operation of the local token generation service, whenever the plaintext data to be stored is obtained, the ciphertext data and the first token value corresponding to the plaintext data are generated, and the ciphertext data and the first token value corresponding to the plaintext data are stored; when it is detected that the token generation service of the token server is restored to normal, the stored ciphertext data and the first token value are sent to the token server, and the local token generation service is closed;
[0207] The token server is used to receive ciphertext data and a first token value sent by the client, wherein the ciphertext data and the first token value are generated by the client during an abnormal period of the token generation service of the token server; determine a second hash value corresponding to the ciphertext data based on the ciphertext data generated by the client; and store the ciphertext data, the first token value, and the second hash value.
[0208] It should be noted that: the downgrading device for the token generation service provided in the above embodiment only uses the division of the above functional modules as an example when downgrading the token generation service. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the downgrading device for the token generation service provided in the above embodiment and the downgrading method embodiment of the token generation service belong to the same concept. The specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0209] Fig.12 The structural block diagram of a terminal 1200 provided by an exemplary embodiment of the present application is shown. The terminal may be the client in the above-mentioned embodiment. The terminal 1200 may be: a smart phone, a tablet computer, an MP3 player (moving picture experts group audio layer III, dynamic image expert compression standard audio layer 3), an MP4 (moving picture experts group audio layer IV, dynamic image expert compression standard audio layer 4) player, a notebook computer or a desktop computer. The terminal 1200 may also be called a user device, a portable terminal, a laptop terminal, a desktop terminal or other names.
[0210] Typically, the terminal 1200 includes: a processor 1201 and a memory 1202 .
[0211] The processor 1201 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1201 may be implemented in at least one hardware form of DSP (digital signal processing), FPGA (field-programmable gate array), and PLA (programmable logic array). The processor 1201 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (central processing unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1201 may be integrated with a GPU (graphics processing unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1201 may also include an AI (artificial intelligence) processor, which is used to process computing operations related to machine learning.
[0212] The memory 1202 may include one or more computer-readable storage media, which may be non-transitory. The memory 1202 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1202 is used to store at least one instruction, which is used to be executed by the processor 1201 to implement the token generation service degradation method provided in the method embodiment of the present application.
[0213] In some embodiments, the terminal 1200 may also optionally include: a peripheral device interface 1203 and at least one peripheral device. The processor 1201, the memory 1202 and the peripheral device interface 1203 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 1203 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 1204, a display screen 1205, a camera 1206, an audio circuit 1207, a positioning component 1208 and a power supply 1209.
[0214] The peripheral device interface 1203 may be used to connect at least one peripheral device related to I / O (input / output) to the processor 1201 and the memory 1202. In some embodiments, the processor 1201, the memory 1202, and the peripheral device interface 1203 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1201, the memory 1202, and the peripheral device interface 1203 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
[0215] The radio frequency circuit 1204 is used to receive and transmit RF (radio frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1204 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1204 converts the electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1204 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The radio frequency circuit 1204 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes, but is not limited to: a metropolitan area network, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (wireless fidelity) network. In some embodiments, the radio frequency circuit 1204 may also include circuits related to NFC (near field communication), which is not limited in this application.
[0216] The display screen 1205 is used to display a UI (user interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1205 is a touch display screen, the display screen 1205 also has the ability to collect touch signals on the surface or above the surface of the display screen 1205. The touch signal can be input as a control signal to the processor 1201 for processing. At this time, the display screen 1205 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 1205 can be one, and the front panel of the terminal 1200 is set; in other embodiments, the display screen 1205 can be at least two, which are respectively set on different surfaces of the terminal 1200 or are folded; in some other embodiments, the display screen 1205 can be a flexible display screen, which is set on the curved surface or folded surface of the terminal 1200. Even, the display screen 1205 can also be set as a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 1205 can be made of materials such as LCD (liquid crystal display), OLED (organic light-emitting diode), etc.
[0217] The camera assembly 1206 is used to capture images or videos. Optionally, the camera assembly 1206 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (virtual reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1206 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0218] The audio circuit 1207 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 1201 for processing, or input them into the radio frequency circuit 1204 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 1200. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 1201 or the radio frequency circuit 1204 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1207 may also include a headphone jack.
[0219] The positioning component 1208 is used to locate the current geographical location of the terminal 1200 to implement navigation or LBS (location based service). The positioning component 1208 can be a positioning component based on the US GPS (global positioning system), China's Beidou system, Russia's Grenas system or the European Union's Galileo system.
[0220] The power supply 1209 is used to power various components in the terminal 1200. The power supply 1209 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 1209 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0221] In some embodiments, the terminal 1200 further includes one or more sensors 1210 , including but not limited to: an acceleration sensor 1211 , a gyroscope sensor 1212 , a pressure sensor 1213 , a fingerprint sensor 1214 , an optical sensor 1215 , and a proximity sensor 1216 .
[0222] The acceleration sensor 1211 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 1200. For example, the acceleration sensor 1211 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1201 can control the display screen 1205 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 1211. The acceleration sensor 1211 can also be used to collect motion data of games or users.
[0223] The gyro sensor 1212 can detect the body direction and rotation angle of the terminal 1200, and the gyro sensor 1212 can cooperate with the acceleration sensor 1211 to collect the user's 3D actions on the terminal 1200. The processor 1201 can implement the following functions based on the data collected by the gyro sensor 1212: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0224] The pressure sensor 1213 can be set on the side frame of the terminal 1200 and / or the lower layer of the display screen 1205. When the pressure sensor 1213 is set on the side frame of the terminal 1200, the user's holding signal of the terminal 1200 can be detected, and the processor 1201 performs left and right hand recognition or shortcut operations according to the holding signal collected by the pressure sensor 1213. When the pressure sensor 1213 is set on the lower layer of the display screen 1205, the processor 1201 controls the operability controls on the UI interface according to the user's pressure operation on the display screen 1205. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0225] The fingerprint sensor 1214 is used to collect the user's fingerprint, and the processor 1201 identifies the user's identity based on the fingerprint collected by the fingerprint sensor 1214, or the fingerprint sensor 1214 identifies the user's identity based on the collected fingerprint. When the user's identity is identified as a trusted identity, the processor 1201 authorizes the user to perform relevant sensitive operations, which include unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings. The fingerprint sensor 1214 can be set on the front, back, or side of the terminal 1200. When a physical button or a manufacturer logo is set on the terminal 1200, the fingerprint sensor 1214 can be integrated with the physical button or the manufacturer logo.
[0226] The optical sensor 1215 is used to collect the ambient light intensity. In one embodiment, the processor 1201 can control the display brightness of the display screen 1205 according to the ambient light intensity collected by the optical sensor 1215. Specifically, when the ambient light intensity is high, the display brightness of the display screen 1205 is increased; when the ambient light intensity is low, the display brightness of the display screen 1205 is reduced. In another embodiment, the processor 1201 can also dynamically adjust the shooting parameters of the camera assembly 1206 according to the ambient light intensity collected by the optical sensor 1215.
[0227] The proximity sensor 1216, also called a distance sensor, is usually arranged on the front panel of the terminal 1200. The proximity sensor 1216 is used to collect the distance between the user and the front of the terminal 1200. In one embodiment, when the proximity sensor 1216 detects that the distance between the user and the front of the terminal 1200 is gradually decreasing, the processor 1201 controls the display screen 1205 to switch from the screen-on state to the screen-off state; when the proximity sensor 1216 detects that the distance between the user and the front of the terminal 1200 is gradually increasing, the processor 1201 controls the display screen 1205 to switch from the screen-off state to the screen-on state.
[0228] Those skilled in the art will understand that Fig.12 The structure shown in the figure does not constitute a limitation on the terminal 1200, and the terminal 1200 may include more or fewer components than those shown in the figure, or combine certain components, or adopt a different component arrangement.
[0229] Fig.13 It is a structural diagram of a server provided in an embodiment of the present application. The server can be the client in the above embodiment, or the token server in the above embodiment. The server 1300 may have relatively large differences due to different configurations or performances, and may include one or more processors 1301 and one or more memories 1302, wherein the memory 1302 stores at least one instruction, and the at least one instruction is loaded and executed by the processor 1301 to implement the methods provided in the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The server may also include other components for implementing device functions, which will not be described here.
[0230] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including instructions, which can be executed by a processor in a terminal to complete the method for downgrading the token generation service in the above embodiment. The computer-readable storage medium can be non-transient. For example, the computer-readable storage medium can be a ROM, RAM, CD-ROM, tape, floppy disk, optical data storage device, etc.
[0231] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0232] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for downgrading a token generation service, characterized in that: The method comprises: Continuously check whether the token generation service on the token server is normal; When an abnormality of the token generation service of the token server is detected, a local token generation service is started, wherein the local includes a token-software development kit token-SDK, and the token-SDK has a token generation service, and starting the local token generation service also includes starting the token-SDK; During the operation of the local token generation service, whenever plaintext data to be stored is obtained, it is first determined whether the token server has stored the first token value corresponding to the plaintext data. If it is found that the first token value corresponding to the plaintext data has been stored, the token server can directly obtain the first token value and store it locally. If it is found that the first token value corresponding to the plaintext data is not stored in the token server, ciphertext data and the first token value corresponding to the plaintext data are generated, and the ciphertext data and the first token value corresponding to the plaintext data are stored; the generating of the ciphertext data and the first token value corresponding to the plaintext data includes: encrypting the plaintext data based on a plaintext encryption algorithm to obtain the ciphertext data corresponding to the plaintext data, performing hash calculation on the plaintext data based on a first hash algorithm to obtain the first hash value corresponding to the plaintext data as the first token value corresponding to the plaintext data; When it is detected that the token generation service of the token server is restored to normal, the stored ciphertext data and the first token value are sent to the token server, and the local token generation service is closed.
2. The method according to claim 1, characterized in that The continuous detection of whether the token generation service of the token server is normal includes: Periodically sending sample plaintext data to the token server; Calculate the ratio of the number of second token values corresponding to the sample plaintext data received within the preset time length to the number of sample plaintext data sent to the token server within the preset time length, as the success rate of the token generation service of the token server within the preset time length; When the success rate is greater than a preset success rate threshold, it is determined that the token generation service of the token server is normal; When the success rate is less than or equal to a preset success rate threshold, it is determined that the token generation service of the token server is abnormal.
3. The method according to claim 1, characterized in that: Before generating the ciphertext data and the first token value corresponding to the plaintext data, the method further includes: Sending a token value query request to the token server, wherein the token value query request carries the plaintext data; Receive a non-query notification sent by the token server, wherein the non-query notification is used to indicate that the first token value or the second token value of the plaintext data is not queried at the token server.
4. The method according to claim 1, characterized in that: When it is detected that the token generation service of the token server is restored to normal, the stored ciphertext data and the first token value are sent to the token server, including: When it is detected that the token generation service of the token server has returned to normal, determining the abnormal period of the token generation service of the token server based on the time point at which the token generation service of the token server was detected to be abnormal and the time point at which the token generation service of the token server was detected to be normal; The stored ciphertext data generated during the abnormal period and the first token value are sent to the token server.
5. A method for downgrading a token generation service, characterized in that: The method comprises: Receive ciphertext data and a first token value sent by a client, wherein the ciphertext data and the first token value are generated by the client during an abnormal period of a token generation service of the token server; the client includes a token-software development kit token-SDK, and the token-SDK has a local token generation service; during the operation of the local token generation service of the client, whenever plaintext data to be stored is obtained, first determine whether the token server has stored the first token value corresponding to the plaintext data; if it is found that the first token value corresponding to the plaintext data has been stored, the first token value can be directly obtained by the token server and stored in the client; if it is found that the first token value corresponding to the plaintext data has been stored in the token server, the first token value can be directly obtained by the token server and stored in the client; The first token value corresponding to the plaintext data generates ciphertext data and a first token value corresponding to the plaintext data, and the client stores the ciphertext data and the first token value corresponding to the plaintext data; the generating of the ciphertext data and the first token value corresponding to the plaintext data includes: encrypting the plaintext data based on a plaintext encryption algorithm to obtain the ciphertext data corresponding to the plaintext data, performing hash calculation on the plaintext data based on a first hash algorithm to obtain the first hash value corresponding to the plaintext data as the first token value corresponding to the plaintext data; when it is detected that the token generation service of the token server has returned to normal, sending the stored ciphertext data and the first token value to the token server, and closing the local token generation service; Based on the ciphertext data generated by the client, determining a second hash value corresponding to the ciphertext data; The ciphertext data, the first token value and the second hash value are stored.
6. The method according to claim 5, characterized in that The determining, based on the ciphertext data generated by the client, a second hash value corresponding to the ciphertext data includes: Decompressing the ciphertext data based on a ciphertext decompression algorithm to obtain plaintext data corresponding to the ciphertext data; A hash calculation is performed on the plaintext data corresponding to the ciphertext data based on a second hash algorithm to obtain a second hash value corresponding to the ciphertext data.
7. The method according to claim 5, characterized in that The method further comprises: Receiving sample plaintext data sent by the client; Generate a second token value corresponding to the sample plaintext data based on the token generation service; Send a second token value corresponding to the sample plaintext data to the client.
8. The method according to claim 5, characterized in that The method further comprises: Receive a token value query request sent by the client, wherein the token value query request carries plaintext data; Performing a hash calculation on the plaintext data based on a second hash algorithm to obtain a second hash value corresponding to the plaintext data; Based on the second hash value corresponding to the plaintext data, detecting whether the second hash value exists in the token server; If it exists, the first token value or the second token value corresponding to the second hash value is sent to the client; if it does not exist, a notification of not finding the query is sent to the client.
9. A downgrading device for a token generation service, characterized in that: The device comprises: The detection module is used to continuously detect whether the token generation service of the token server is normal; A startup module, used for starting a local token generation service when detecting that the token generation service of the token server is abnormal, wherein the local includes a token-software development kit token-SDK, the token-SDK has a token generation service, and starting the local token generation service also includes starting the token-SDK; A generation module, used for, during the operation of the local token generation service, whenever obtaining plaintext data to be stored, first determining whether the token server has stored the first token value corresponding to the plaintext data; if it is found that the first token value corresponding to the plaintext data has been stored, the token server can directly obtain the first token value and store it locally; if it is found that the first token value corresponding to the plaintext data is not stored on the token server, generating ciphertext data and the first token value corresponding to the plaintext data, and storing the ciphertext data and the first token value corresponding to the plaintext data; the generating the ciphertext data and the first token value corresponding to the plaintext data comprises: encrypting the plaintext data based on a plaintext encryption algorithm to obtain the ciphertext data corresponding to the plaintext data, performing hash calculation on the plaintext data based on a first hash algorithm to obtain the first hash value corresponding to the plaintext data as the first token value corresponding to the plaintext data; The sending module is used to send the stored ciphertext data and the first token value to the token server and close the local token generation service when it is detected that the token generation service of the token server is restored to normal.
10. A downgrading device for a token generation service, characterized in that: The device comprises: A receiving module, for receiving ciphertext data and a first token value sent by a client, wherein the ciphertext data and the first token value are generated by the client during an abnormal period of a token generation service of the token server; the client includes a token-software development kit token-SDK, and the token-SDK has a local token generation service; during the operation of the local token generation service of the client, whenever plaintext data to be stored is obtained, it is first determined whether the token server has stored the first token value corresponding to the plaintext data; if it is found that the first token value corresponding to the plaintext data has been stored, the first token value can be directly obtained by the token server and stored in the client; if it is found that the first token value corresponding to the plaintext data has been stored on the token server, the first token value can be directly obtained by the token server and stored in the client; If the first token value corresponding to the plaintext data is not stored, ciphertext data and the first token value corresponding to the plaintext data are generated, and the client stores the ciphertext data and the first token value corresponding to the plaintext data; the generating of the ciphertext data and the first token value corresponding to the plaintext data includes: encrypting the plaintext data based on a plaintext encryption algorithm to obtain the ciphertext data corresponding to the plaintext data, performing hash calculation on the plaintext data based on a first hash algorithm to obtain the first hash value corresponding to the plaintext data as the first token value corresponding to the plaintext data; when it is detected that the token generation service of the token server is restored to normal, the stored ciphertext data and the first token value are sent to the token server, and the local token generation service is closed; A determination module, configured to determine a second hash value corresponding to the ciphertext data based on the ciphertext data generated by the client; A storage module is used to store the ciphertext data, the first token value and the second hash value.
11. A token generation service downgrade system, characterized in that: The system includes a client and a token server, wherein: The client is used to continuously detect whether the token generation service of the token server is normal; when it is detected that the token generation service of the token server is abnormal, the local token generation service is started, and the local includes a token-software development kit token-SDK, and the token-SDK has a token generation service. The starting of the local token generation service also includes starting the token-SDK; during the operation of the local token generation service, whenever the plaintext data to be stored is obtained, it is first determined whether the token server has stored the first token value corresponding to the plaintext data. If it is found that the first token value corresponding to the plaintext data has been stored, the first token value can be directly obtained by the token server and stored locally. If it is found that the first token value corresponding to the plaintext data has been stored, the token server can directly obtain the first token value and store it locally. Now the token server does not store the first token value corresponding to the plaintext data, generates ciphertext data and the first token value corresponding to the plaintext data, and stores the ciphertext data and the first token value corresponding to the plaintext data; when it is detected that the token generation service of the token server is restored to normal, sends the stored ciphertext data and the first token value to the token server, and closes the local token generation service; the generating of the ciphertext data and the first token value corresponding to the plaintext data includes: encrypting the plaintext data based on a plaintext encryption algorithm to obtain the ciphertext data corresponding to the plaintext data, performing hash calculation on the plaintext data based on a first hash algorithm to obtain the first hash value corresponding to the plaintext data as the first token value corresponding to the plaintext data; The token server is used to receive ciphertext data and a first token value sent by the client, wherein the ciphertext data and the first token value are generated by the client during an abnormal period of the token generation service of the token server; determine a second hash value corresponding to the ciphertext data based on the ciphertext data generated by the client; and store the ciphertext data, the first token value, and the second hash value.
12. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the operation performed by the method for downgrading a token generation service as described in any one of claims 1-4 or claims 5-8.
13. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the operation performed by the downgrading method of the token generation service as described in any one of claims 1-4 or claims 5-8.
