Two-dimensional code timeliness verification method and device, equipment, storage medium and product
In the QR code verification in the civil aviation field, the initial and dynamic time offsets are used to correct the QR code generation time, and the problem of low verification accuracy caused by time drift is solved, and the accuracy of verification and system reliability are improved. .
Patent Information
- Application Number
- CN202411000110.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-11-22
AI Technical Summary
In offline QR code verification in the civil aviation field, time drift caused by the out-of-synchronization of timestamps reduces the accuracy of QR code validity verification and increases airport operation costs.
The initial time offset is determined by scanning time and cloud time, and the dynamic offset is determined by combining offline running time and historical average offset rate. The QR code generation time is corrected to determine whether it is within the valid time interval, and then determine The validity of QR code.
It improves the accuracy of QR code timeliness verification, reduces misjudgments caused by time drift, and enhances the reliability of the system and user satisfaction.
Smart Images

Figure CN119005225A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of two-dimensional code technology, and in particular to a two-dimensional code timeliness verification method, device, equipment, storage medium and product. Background Art
[0002] At present, the civil aviation field is gradually promoting online generated boarding QR codes at various airports, aiming to realize convenient travel voucher production through the Internet. In this process, the core verification steps are designed to be executed in a relatively closed airport intranet environment, giving rise to the demand and application of offline verification mechanisms. However, during offline verification, due to the asynchrony of the QR code timestamp, that is, the "time drift" problem, the accuracy of the QR code validity verification is low, which can easily affect passengers and increase the operating costs of the airport. Therefore, how to improve the accuracy of QR code validity verification has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] The main purpose of this application is to provide a method, device, equipment, storage medium and product for verifying the timeliness of a QR code, aiming to solve the technical problem of how to improve the accuracy of QR code validity verification.
[0004] To achieve the above purpose, the present application provides a method for verifying the timeliness of a QR code, the method comprising the following steps:
[0005] Determine an initial time offset according to the scanning time of the QR code to be verified and the cloud time corresponding to the scanning time;
[0006] Determine the dynamic offset based on the offline operation time and the historical average offset rate;
[0007] Based on the initial time offset and the dynamic offset, the generation time of the to-be-verified two-dimensional code is corrected to obtain the to-be-verified time;
[0008] If the time to be verified is within the valid time interval, it is determined that the QR code to be verified has passed the verification.
[0009] In one embodiment, before the step of determining the dynamic offset according to the offline operation time and the historical average offset rate, the step further includes:
[0010] Get the time when the server enters the offline state as the offline start time;
[0011] The difference between the current time and the offline start time is used as the offline running time;
[0012] Build a time offset model based on server clock data and standard time data;
[0013] The historical average drift rate is determined according to the time drift model.
[0014] In one embodiment, the step of constructing a time offset model based on the server clock data and the standard time data includes:
[0015] Regularly synchronizing the server clock data with the standard time data, and recording the time difference data of each synchronization;
[0016] Arrange the time difference data in chronological order;
[0017] The time offset model is constructed based on the sorted time difference data and a preset data fitting algorithm.
[0018] In one embodiment, before the step of correcting the generation time of the to-be-verified two-dimensional code based on the initial time offset and the dynamic offset to obtain the to-be-verified time, the step further includes:
[0019] Decoding the to-be-verified two-dimensional code to obtain decoding information;
[0020] Compare the verification data in the decoded information with the preset verification data, and determine whether the two-dimensional code to be verified has been tampered with according to the comparison result;
[0021] If not, the generation time of the two-dimensional code to be verified is extracted from the decoding information.
[0022] In one embodiment, before the step of determining that the to-be-verified QR code has passed the verification if the to-be-verified time is within the valid time interval, the method further includes:
[0023] Based on the initial time offset and the dynamic offset, correct the current offline time to obtain an offline correction time;
[0024] Determining the first closed interval endpoint according to the difference between the offline correction time and the preset effective time length;
[0025] Taking the offline correction time as the endpoint of the second closed interval;
[0026] The valid time interval is determined according to the first closed interval endpoint and the second closed interval endpoint.
[0027] In one embodiment, after the step of determining that the to-be-verified QR code has passed the verification if the to-be-verified time is within the valid time interval, the method further includes:
[0028] If the to-be-verified time is not within the valid time interval, the difference between the to-be-verified time and the endpoint of the first closed interval is taken as the first difference, and the difference between the to-be-verified time and the endpoint of the second closed interval is taken as the second difference;
[0029] Determine whether the absolute value of the first difference or the absolute value of the second difference is less than a preset error threshold;
[0030] If so, it is determined that the QR code to be verified has passed the verification.
[0031] In addition, to achieve the above purpose, the present application also proposes a QR code timeliness verification device, the QR code timeliness verification device comprising:
[0032] An initial offset determination module, used to determine an initial time offset according to a scanning time of the QR code to be verified and a cloud time corresponding to the scanning time;
[0033] A dynamic offset determination module is used to determine the dynamic offset according to the offline operation time and the historical average offset rate;
[0034] A generation correction module is used to correct the generation time of the to-be-verified two-dimensional code based on the initial time offset and the dynamic offset to obtain the to-be-verified time;
[0035] The verification module is used to determine whether the QR code to be verified has passed the verification if the time to be verified is within a valid time interval.
[0036] In addition, to achieve the above-mentioned purpose, the present application also proposes a QR code timeliness verification device, which includes: a memory, a processor, and a QR code timeliness verification program stored on the memory and executable on the processor, and the QR code timeliness verification program is configured to implement the steps of the QR code timeliness verification method described above.
[0037] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, on which a QR code timeliness verification program is stored. When the QR code timeliness verification program is executed by a processor, the steps of the QR code timeliness verification method described above are implemented.
[0038] In addition, to achieve the above-mentioned purpose, the present application also proposes a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the QR code timeliness verification method as described above.
[0039] This application determines the initial time offset based on the scanning time of the QR code to be verified and the cloud time corresponding to the scanning time; determines the dynamic offset based on the offline running time and the historical average offset rate; based on the initial time offset and the dynamic offset, corrects the generation time of the QR code to be verified to obtain the time to be verified; if the time to be verified is within the valid time interval, the QR code to be verified is determined to have passed the verification. This application determines the initial time offset based on the scanning time of the QR code to be verified and the corresponding cloud time to accurately obtain the time difference before offline; then determines the dynamic offset based on the offline running time and the historical average offset rate to compensate for the time drift during the offline period; based on these two offsets, corrects the generation time of the QR code to be verified to ensure that the corrected time accurately reflects the actual generation time of the QR code; finally, by comparing the corrected time to be verified with the valid time interval, accurately judges the validity of the QR code, thereby improving the accuracy of the QR code timeliness verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 This is a flowchart of the first embodiment of the method for verifying the timeliness of a QR code of this application;
[0041] Figure 2 This is a schematic diagram of a sub-flow in the second embodiment of the method for verifying the timeliness of a QR code of this application;
[0042] Figure 3 This is a schematic diagram of a sub-flow in the third embodiment of the method for verifying the timeliness of a QR code of this application;
[0043] Figure 4 This is a schematic diagram of the QR code validity verification process in an embodiment of the QR code validity verification method of this application;
[0044] Figure 5 This is a schematic diagram of the module structure of the device for verifying the timeliness of a two-dimensional code according to an embodiment of the present application;
[0045] Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the QR code timeliness verification method in the embodiment of the present application.
[0046] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0047] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0048] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0049] It should be noted that at present, the civil aviation field is gradually promoting the online generation of boarding QR codes in various airports, aiming to realize the convenient production of travel certificates through the Internet. In this process, the core verification steps are designed to be executed in a relatively closed airport intranet environment, which has given rise to the demand and application of offline verification mechanisms. However, during offline verification, due to the asynchrony of the QR code timestamp, that is, the "time drift" problem, the accuracy of the QR code validity verification is low, which can easily affect passengers and increase the operating costs of the airport. Therefore, how to improve the accuracy of QR code validity verification has become a technical problem that needs to be solved urgently.
[0050] The main solution of this application is: determine the initial time offset based on the scanning time of the QR code to be verified and the cloud time corresponding to the scanning time; determine the dynamic offset based on the offline running time and the historical average offset rate; based on the initial time offset and the dynamic offset, correct the generation time of the QR code to be verified to obtain the time to be verified; if the time to be verified is within the valid time interval, it is determined that the QR code to be verified has passed the verification.
[0051] This application determines the initial time offset by the scanning time of the QR code to be verified and the corresponding cloud time, and accurately obtains the time difference before offline; then determines the dynamic offset according to the offline running time and the historical average offset rate to compensate for the time drift during the offline period; based on these two offsets, the generation time of the QR code to be verified is corrected to ensure that the corrected time accurately reflects the actual generation time of the QR code; finally, by comparing the corrected time to be verified with the valid time interval, the validity of the QR code is accurately judged, thereby improving the accuracy of the QR code timeliness verification.
[0052] It should be noted that the execution subject of the method of this embodiment can be a computing service device with data processing, network communication and program running functions, or it can be the above-mentioned QR code time validity verification device with the same or similar functions. This embodiment and the following embodiments will be described by taking the QR code time validity verification device as an example.
[0053] Based on this, the first embodiment of the method for verifying the timeliness of the QR code of this application is proposed. Please refer to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the method for verifying the timeliness of a QR code of the present application.
[0054] In this embodiment, the QR code validity verification method includes the following steps:
[0055] S1: Determine an initial time offset according to the scanning time of the QR code to be verified and the cloud time corresponding to the scanning time;
[0056] It should be noted that the QR code to be verified refers to the QR code that needs to be verified for timeliness. This QR code contains information such as the time of generation, which is used to verify its validity. The scanning time refers to the specific time point when the QR code is scanned, that is, the timestamp when the QR code is scanned by a reading device (such as a barcode scanner or a mobile phone). The cloud time refers to the standard time (such as UTC time) corresponding to the scanning time. This is the timestamp recorded by the server and encrypted and stored in the QR code when the QR code is generated. The initial time offset refers to the time difference between the scanning time and the cloud time. This time difference reflects the offset between the offline server clock and the standard time before going offline.
[0057] Specifically, use a scanning device to read the QR code to be verified and obtain all the information contained in the QR code, including the generation time and the cloud time. At the moment the QR code is scanned, the local time on the scanning device is recorded, which is the scanning time. The cloud time is extracted from the QR code decoding information. The cloud time is the standard timestamp recorded by the server when the QR code is generated. By comparing the scanning time and the cloud time, the initial time offset is calculated. This offset represents the difference between the offline server time and the standard time before going offline.
[0058] The determination of the initial time offset can accurately reflect the time error of the offline server before it goes offline, providing an accurate basis for the subsequent dynamic offset calculation, effectively compensating for the time difference before going offline, and ensuring that the subsequent correction of the QR code generation time is more accurate, thereby improving the accuracy of the QR code timeliness verification. Through accurate time correction, the misjudgment of QR codes caused by time drift can be reduced, improving the reliability of the system and user satisfaction.
[0059] S2: Determine the dynamic offset based on the offline operation time and the historical average offset rate;
[0060] It should be noted that the offline operation time refers to the duration from the time the system enters the offline state to the current moment. During this period, the system cannot be synchronized with the standard time server. The historical average offset rate refers to the average drift rate of the system clock relative to the standard time per unit time calculated based on historical data. It reflects the average offset between the system clock and the standard time within a certain period of time. The dynamic offset refers to the time offset calculated based on the offline operation time and the historical average offset rate, which indicates the cumulative offset of the system clock relative to the standard time during the offline period.
[0061] Specifically, when the system enters the offline state, the system time at this moment is recorded as the offline start time. For example, if the system enters the offline state at 08:00:00 on July 9, 2024, this time point is the offline start time. When the QR code needs to be verified, the current system time is recorded, and the time difference between the current time and the offline start time is calculated. This difference is the offline running time. For example, if the current system time is 10:00:00 on July 9, 2024, and the offline start time is 08:00:00 on July 9, 2024, the offline running time is 2 hours.
[0062] Furthermore, the average drift rate of the system clock relative to the standard time is calculated using historical data. Assume that by analyzing the data over the past period of time, the average drift rate of the system clock is 0.5 seconds per hour. The dynamic offset is calculated by multiplying the offline operation time by the historical average drift rate. For example, if the offline operation time is 2 hours and the historical average drift rate is 0.5 seconds per hour, the dynamic offset is 1 second.
[0063] The time offset is dynamically calculated based on the offline operation time and the historical average offset rate, and the time drift during the offline period is compensated in real time. The precise calculation of the dynamic offset makes the correction of the QR code generation time more accurate, thereby improving the accuracy of the QR code timeliness verification. Even in long-term offline operation, the synchronization of the system clock and the standard time can be ensured through the analysis and application of historical data, thereby enhancing the robustness and reliability of the system.
[0064] S3: Based on the initial time offset and the dynamic offset, the generation time of the to-be-verified two-dimensional code is corrected to obtain the to-be-verified time;
[0065] It should be noted that the generation time of the QR code to be verified is the timestamp recorded when the QR code is generated in the cloud, and this timestamp is obtained by decoding the QR code. The verification time is the correction time obtained after time correction of the generation time of the QR code to be verified.
[0066] Specifically, the initial time offset is calculated before going offline by scanning the time and the corresponding cloud time. For example, assume that the initial time offset is 5 seconds. The dynamic offset is calculated during the offline period based on the offline running time and the historical average offset rate. For example, assume that the offline running time is 2 hours and the historical average offset rate is 0.5 seconds per hour, then the dynamic offset is 1 second.
[0067] Further, scan the QR code to be verified and decode it to obtain the time when the QR code was generated. For example, the time when the QR code was generated is 08:00:00 on July 9, 2024. Add the initial time offset and the dynamic offset to obtain the total offset. For example, the total offset is 5 seconds (initial time offset) + 1 second (dynamic offset) = 6 seconds. For example, the time when the QR code was generated is 08:00:00 on July 9, 2024, plus 6 seconds, the total offset is 08:00:06 on July 9, 2024.
[0068] The initial time offset and dynamic offset are combined to accurately correct the time when the QR code is generated, ensuring that the impact of the time offset is accurately compensated. Through accurate time correction, the timestamp used during verification is closer to the actual generation time, thereby improving the accuracy of the QR code timeliness verification. In an offline environment, the system can still accurately grasp the time when the QR code is generated by dynamically calculating and correcting the time offset, thereby enhancing the reliability of the system.
[0069] S4: If the time to be verified is within the valid time interval, it is determined that the QR code to be verified has passed the verification.
[0070] It needs to be explained that the valid time interval is the time period from the generation of the QR code to its expiration, which is usually determined by the time the QR code is generated and the length of the validity period.
[0071] Specifically, the validity period of the QR code is determined from the time when the QR code is generated. For example, if the validity period of the QR code is 2 hours, and the corrected QR code generation time (to be verified time) is 08:00:06 on July 9, 2024, then the valid time interval is: start time: 08:00:06 on July 9, 2024, end time: 10:00:06 on July 9, 2024. Record the correction time of the current offline server, for example, the current correction time is 09:00:00 on July 9, 2024. Check whether the corrected to be verified time is within the valid time interval. For example, if the current correction time is 09:00:00 on July 9, 2024, and the validity period is 2 hours, then the valid time interval is: start time: 07:00:00 on July 9, 2024, end time: 09:00:00 on July 9, 2024. If the corrected verification time (08:00:06, July 9, 2024) is within the above range, the QR code passes the verification. If the verification time is within the valid time range, the QR code passes the verification. If the verification time is not within the valid time range, the QR code fails the verification.
[0072] Through strict time interval judgment, we ensure that the QR code is used within its validity period to prevent expired QR codes from being mistakenly considered valid. By determining the effective time interval, we increase the security of the system, avoid misjudgment caused by time drift, ensure the verification process is rigorous and accurate, and improve the reliability and credibility of the system in processing QR code timeliness verification.
[0073] This embodiment determines the initial time offset based on the scanning time of the QR code to be verified and the cloud time corresponding to the scanning time; determines the dynamic offset based on the offline operation time and the historical average offset rate; based on the initial time offset and the dynamic offset, corrects the generation time of the QR code to be verified to obtain the time to be verified; if the time to be verified is within the valid time interval, it is determined that the QR code to be verified has passed the verification. This embodiment determines the initial time offset based on the scanning time of the QR code to be verified and the corresponding cloud time, accurately obtains the time difference before offline; then determines the dynamic offset based on the offline operation time and the historical average offset rate, and compensates for the time drift during the offline period; based on these two offsets, corrects the generation time of the QR code to be verified to ensure that the corrected time accurately reflects the real generation time of the QR code; finally, by comparing the corrected time to be verified with the valid time interval, accurately judges the validity of the QR code, thereby improving the accuracy of the timeliness verification of the QR code.
[0074] Based on the above first embodiment, a second embodiment of the method for verifying the timeliness of a QR code of this application is proposed. Figure 2 , Figure 2 This is a schematic diagram of a sub-process in the second embodiment of the QR code timeliness verification method of this application.
[0075] like Figure 2 As shown, in this embodiment, before step S2, the following is further included:
[0076] S2a: Obtain the time when the server enters the offline state as the offline start time;
[0077] S2b: taking the difference between the current time and the offline start time as the offline running time;
[0078] S2c: Build a time offset model based on server clock data and standard time data;
[0079] S2d: Determine the historical average offset rate according to the time offset model.
[0080] Step S2c includes:
[0081] S2c1: regularly synchronizing the server clock data with the standard time data, and recording the time difference data of each synchronization;
[0082] S2c2: Arranging the time difference data in chronological order;
[0083] S2c3: Based on the sorted time difference data and a preset data fitting algorithm, the time offset model is constructed.
[0084] It should be noted that the offline start time refers to the timestamp when entering the offline state, which records the server time at this time. The offline running time refers to the time difference between the current time and the offline start time, indicating the length of time the system runs in the offline state. The time drift model is a model built based on server clock data and standard time data, which is used to describe and predict time drift. The historical average drift rate is the average time drift rate per unit time calculated by the time drift model.
[0085] Specifically, when the system enters the offline state, the server time at this time is recorded as the offline start time. For example, the system enters the offline state at 08:00:00 on July 9, 2024, and this time point is the offline start time. When the QR code needs to be verified, the current server time is recorded, and the time difference between the current time and the offline start time is calculated, that is, the offline running time. For example, the current server time is 10:00:00 on July 9, 2024, and the offline start time is 08:00:00 on July 9, 2024, then the offline running time is 2 hours.
[0086] Furthermore, before the system enters the offline state, the server clock data and the standard time data are synchronized regularly, and the time difference data of each synchronization is recorded. Then, based on these time difference data, a time offset model is constructed. The specific steps of constructing the model are as follows: when the system is operating normally, the server clock and the standard time are synchronized regularly, and the time difference data of each synchronization is recorded; the time difference data recorded during each synchronization is sorted in chronological order; based on the sorted time difference data, a time offset model is constructed using a preset data fitting algorithm (such as linear regression). The model is used to describe the drift of the server clock relative to the standard time; the historical average offset rate is calculated through the constructed time offset model. The specific calculation process is: using linear regression or other suitable algorithms, the time offset model is fitted to determine the model parameters (such as slope); according to the fitted time offset model, the average time drift rate per unit time, that is, the historical average offset rate, is calculated. For example, assuming that the model indicates that the server clock offsets 0.5 seconds per hour, the historical average offset rate is 0.5 seconds / hour.
[0087] By accurately recording the offline start time and calculating the offline running time, the basic data of the time correction process is ensured to be accurate. The historical average offset rate can be used to dynamically compensate for the time drift during the offline period to ensure the accuracy of time correction in the offline environment. A time offset model is constructed to enable the system to maintain high-precision time correction capabilities during offline operation, thereby improving the robustness and reliability of the system. Through these steps, the time drift during the offline period can be accurately corrected to ensure the accuracy and reliability of the QR code timeliness verification.
[0088] Based on the first embodiment above, in this embodiment, before step S3, the following is further included:
[0089] S3a: Decode the two-dimensional code to be verified to obtain decoding information;
[0090] S3b: Compare the verification data in the decoded information with the preset verification data, and determine whether the two-dimensional code to be verified has been tampered with according to the comparison result;
[0091] S3c: If not, extract the generation time of the two-dimensional code to be verified from the decoding information.
[0092] It should be noted that the decoded information refers to the data extracted from the QR code, including the generation time, verification data, etc. Verification data is data used to verify the integrity and authenticity of the QR code, usually encrypted or encoded information. Preset verification data is pre-stored standard data for comparison and verification to check whether the QR code has been tampered with.
[0093] Specifically, use a code scanning device to read the QR code to be verified and obtain its coded information. Apply a decoding algorithm to decode the coded information in the QR code into human-readable data, which constitutes the decoded information. For example, the decoded information may include the generation time, flight number, seat number, and verification data. Extract the verification data from the decoded information. These verification data are usually used to ensure the integrity and authenticity of the QR code. Obtain preset verification data from the system. The preset verification data is standard data generated according to the algorithm and key when the QR code is generated.
[0094] Furthermore, the verification data in the decoded information is compared with the preset verification data to check whether they are consistent. The comparison result is used to determine whether the QR code has been tampered with. If the verification data is consistent with the preset verification data, it means that the QR code has not been tampered with. According to the comparison result of the verification data and the preset verification data, it is determined whether the QR code has been tampered with. If the QR code has not been tampered with, continue to extract the generation time. Extract the generation time of the QR code from the decoded information. This is the timestamp recorded when the QR code is generated in the cloud, which is used for subsequent timeliness verification.
[0095] Through the above steps, the integrity and authenticity of the QR code to be verified can be ensured, and its generation time can be accurately extracted. By comparing the verification data with the preset verification data, it is possible to effectively check whether the QR code has been tampered with, ensuring the integrity and authenticity of the data. Only when it is ensured that the QR code has not been tampered with, the generation time is extracted, which improves the accuracy of subsequent timeliness verification. Through strict verification steps, forged or tampered QR codes are prevented from passing the verification, enhancing the security and reliability of the system.
[0096] This embodiment determines the initial time offset based on the scanning time of the QR code to be verified and the cloud time corresponding to the scanning time; determines the dynamic offset based on the offline operation time and the historical average offset rate; based on the initial time offset and the dynamic offset, corrects the generation time of the QR code to be verified to obtain the time to be verified; if the time to be verified is within the valid time interval, it is determined that the QR code to be verified has passed the verification. This embodiment determines the initial time offset based on the scanning time of the QR code to be verified and the corresponding cloud time, accurately obtains the time difference before offline; then determines the dynamic offset based on the offline operation time and the historical average offset rate, and compensates for the time drift during the offline period; based on these two offsets, corrects the generation time of the QR code to be verified to ensure that the corrected time accurately reflects the real generation time of the QR code; finally, by comparing the corrected time to be verified with the valid time interval, accurately judges the validity of the QR code, thereby improving the accuracy of the timeliness verification of the QR code.
[0097] Based on the above second embodiment, a third embodiment of the method for verifying the timeliness of a QR code of this application is proposed. Figure 3 , Figure 3 This is a schematic diagram of a sub-process in the third embodiment of the method for verifying the timeliness of a QR code of this application.
[0098] In this embodiment, before step S4, the method further includes:
[0099] S4a: Correcting the current offline time based on the initial time offset and the dynamic offset to obtain an offline correction time;
[0100] S4b: determining the endpoint of the first closed interval according to the difference between the offline correction time and the preset effective time length;
[0101] S4c: taking the offline correction time as the endpoint of the second closed interval;
[0102] S4d: Determine the valid time interval according to the first closed interval endpoint and the second closed interval endpoint.
[0103] It should be noted that the current offline moment refers to the time recorded by the current server, that is, the current local time of the system. The offline correction moment refers to the correction time obtained after applying the initial time offset and the dynamic offset to the current offline moment, indicating the corrected current time. The preset effective time length is the preset validity period of the QR code, a period of time starting from the time the QR code is generated. The first closed interval endpoint refers to the time point obtained by subtracting the preset effective time length from the offline correction moment, indicating the start time of the effective time interval. The second closed interval endpoint refers to the offline correction moment, indicating the end time of the effective time interval. The effective time interval refers to the time range in which the QR code is considered valid, which is determined by the first closed interval endpoint and the second closed interval endpoint.
[0104] Specifically, record the time of the current server, that is, the current offline time. For example, the current offline time is 10:00:00 on July 9, 2024. Add the initial time offset and the dynamic offset to get the total offset. For example, if the initial time offset is 5 seconds and the dynamic offset is 1 second, the total offset is 6 seconds. Apply the total offset to the current offline time to get the offline correction time. For example, if the current offline time is 10:00:00 on July 9, 2024, plus the total offset of 6 seconds, the offline correction time is 10:00:06 on July 9, 2024.
[0105] Further, the preset effective time length is subtracted from the offline correction time to obtain the first closed interval endpoint. For example, the preset effective time length is 2 hours, and the offline correction time is 10:00:06 on July 9, 2024, then the first closed interval endpoint is 08:00:06 on July 9, 2024. The offline correction time is used as the second closed interval endpoint. For example, if the offline correction time is 10:00:06 on July 9, 2024, then the second closed interval endpoint is 10:00:06 on July 9, 2024. The effective time interval is determined by the first closed interval endpoint and the second closed interval endpoint. In this example, the effective time interval is from 08:00:06 on July 9, 2024 to 10:00:06 on July 9, 2024.
[0106] Through the above steps, the effective time interval of the QR code can be accurately determined, thereby improving the accuracy of timeliness verification. By correcting the current offline time, the effective time interval of the QR code is accurately calculated to ensure that the time data used in the verification process is accurate. By dynamically adjusting the time, the system can still accurately determine the validity of the QR code in an offline environment, improving the reliability and robustness of the system. The determination of the effective time interval eliminates the impact of time drift on the timeliness verification of the QR code, ensuring the accuracy of the verification results.
[0107] Based on the above second embodiment, in this embodiment, after step S4, the following is further included:
[0108] S4A: If the to-be-verified time is not within the valid time interval, the difference between the to-be-verified time and the endpoint of the first closed interval is taken as the first difference, and the difference between the to-be-verified time and the endpoint of the second closed interval is taken as the second difference;
[0109] S4B: Determine whether the absolute value of the first difference or the absolute value of the second difference is less than a preset error threshold;
[0110] S4C: If so, determine that the QR code to be verified has passed the verification.
[0111] It should be noted that the time to be verified refers to the time obtained after the generation time of the QR code to be verified is corrected, reflecting the actual generation time of the QR code after time compensation. The preset error threshold is a pre-set time deviation tolerance value, which is used to determine whether the difference between the time to be verified and the endpoint of the valid time interval is within an acceptable range. The first difference refers to the time difference between the time to be verified and the endpoint of the first closed interval. The second difference refers to the time difference between the time to be verified and the endpoint of the second closed interval.
[0112] Specifically, the time difference between the time to be verified and the endpoint of the first closed interval is calculated as the first difference. The time difference between the time to be verified and the endpoint of the second closed interval is calculated as the second difference. The absolute values of the first difference and the second difference are calculated. It is determined whether the absolute value of the first difference or the absolute value of the second difference is less than a preset error threshold. If the absolute value of any difference is less than or equal to the preset error threshold, it is determined that the QR code to be verified has passed the verification. If the absolute values of both differences are greater than the preset error threshold, it is determined that the QR code to be verified has not passed the verification.
[0113] Through the above steps, the verification of the QR code can be more flexible and fault-tolerant on the basis of considering the time error. By introducing a preset error threshold, time deviation within a certain range can be tolerated, reducing the misjudgment of the QR code due to slight time drift. The system is allowed to accurately judge the validity of the QR code even when there are slight errors in the time correction process, thereby improving the robustness of the system. It reduces the situation where the QR code is misjudged as invalid due to time error, and improves the user experience and satisfaction during use. Through these steps, the validity of the QR code can be accurately judged while allowing a certain time error, thereby improving the fault tolerance and user experience of timeliness verification.
[0114] This embodiment determines the initial time offset based on the scanning time of the QR code to be verified and the cloud time corresponding to the scanning time; determines the dynamic offset based on the offline operation time and the historical average offset rate; based on the initial time offset and the dynamic offset, corrects the generation time of the QR code to be verified to obtain the time to be verified; if the time to be verified is within the valid time interval, it is determined that the QR code to be verified has passed the verification. This embodiment determines the initial time offset based on the scanning time of the QR code to be verified and the corresponding cloud time, accurately obtains the time difference before offline; then determines the dynamic offset based on the offline operation time and the historical average offset rate, and compensates for the time drift during the offline period; based on these two offsets, corrects the generation time of the QR code to be verified to ensure that the corrected time accurately reflects the real generation time of the QR code; finally, by comparing the corrected time to be verified with the valid time interval, accurately judges the validity of the QR code, thereby improving the accuracy of the timeliness verification of the QR code.
[0115] For example, in order to help understand the technical concept or technical principle of the two-dimensional code time validity verification method of the above embodiment, please refer to Figure 4 , Figure 4 This is a schematic diagram of the QR code timeliness verification process in one embodiment of the QR code timeliness verification method of the present application.
[0116] like Figure 4 As shown, in this embodiment, it is deployed on the cloud server and is responsible for generating a civil aviation boarding QR code containing an encrypted timestamp and other information. The timestamp uses the international standard time UTC and adds anti-tampering measures. Record the cloud server time T server , and record the timestamp T of the terminal's internal clock local , calculate the difference between the two as the initial time offset Offset init =T server -T local . init The time drift threshold and other necessary configuration parameters are saved to the local storage of the terminal for use during offline time. The internal clock of the offline verification server continues to count. Since all clocks have a certain amount of drift, the time displayed by the internal clock will gradually differ from the real Internet online time over time. Based on the recorded historical data, a time drift model is established. The offline verification server records the offline time as t offline , the historical drift rate β (the average value of the time offset per unit time), the dynamic offset Δoffset can be estimated as ΔOffset = β × t offline Add the initial offset to the dynamic offset to get the total offset TotalOffset = Offset init +ΔOffset. Correct the current offline server time T based on the total offsetcorrected′ =T local +TotalOffset, use this as the current time for verification. Scan the QR code and decode it to get the timestamp T when the QR code was generated qrcode Correct the QR code timestamp according to the total offset T qrcode ′=T qrcode +TotalOffset to eliminate the effect of time drift. Check the corrected timestamp T qrcode ′ falls within the validity period. corrected ′-T validity <=T qrcode ′<=T ccorrected ′, where Tvalidity is the effective time length of the QR code. In order to increase the robustness of the verification, an error tolerance range ∈ is set. When judging the validity of the QR code, it is also necessary to confirm |T corrected ′-T qrcode ′|<=∈, ensuring that even if there is a small time deviation, the QR code is still considered valid as long as it is within an acceptable range.
[0117] The present application also provides a device for verifying the timeliness of a QR code. Figure 5 , Figure 5 This is a schematic diagram of the module structure of the two-dimensional code time validity verification device of the embodiment of the present application, and the two-dimensional code time validity verification device includes:
[0118] An initial offset determination module 501, configured to determine an initial time offset according to a scanning time of the QR code to be verified and a cloud time corresponding to the scanning time;
[0119] A dynamic offset determination module 502, used to determine a dynamic offset according to the offline operation time and the historical average offset rate;
[0120] A generation correction module 503 is used to correct the generation time of the to-be-verified two-dimensional code based on the initial time offset and the dynamic offset to obtain the to-be-verified time;
[0121] The verification module 504 is used to determine whether the QR code to be verified has passed the verification if the time to be verified is within the valid time interval.
[0122] The QR code time validity verification device provided in the embodiment of the present application adopts the QR code time validity verification method in the above embodiment, which can solve the technical problem of how to improve the accuracy of QR code validity verification. Compared with the prior art, the beneficial effects of the QR code time validity verification device provided in the embodiment of the present application are the same as the beneficial effects of the QR code time validity verification method provided in the above embodiment, and the other technical features in the QR code time validity verification device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0123] The present application provides a QR code timeliness verification device, which includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the QR code timeliness verification method in the above-mentioned embodiment.
[0124] Reference below Figure 6 , which shows a schematic diagram of the structure of a two-dimensional code time validity verification device suitable for implementing the embodiment of the present application. The two-dimensional code time validity verification device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The QR code timeliness verification device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0125] like Figure 6As shown, the two-dimensional code time validity verification device may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM: Read Only Memory) 1002 or the program loaded from the storage device 1003 to the random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the two-dimensional code time validity verification device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. The input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the two-dimensional code time validity verification device to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a two-dimensional code time validity verification device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or provided alternatively.
[0126] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0127] The QR code time validity verification device provided by the present application adopts the QR code time validity verification method in the above embodiment, which can solve the technical problem of how to improve the accuracy of QR code validity verification. Compared with the prior art, the beneficial effects of the QR code time validity verification device provided by the present application are the same as the beneficial effects of the QR code time validity verification method provided by the above embodiment, and the other technical features in the QR code time validity verification device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0128] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0129] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0130] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the QR code timeliness verification method in the above-mentioned embodiment.
[0131] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0132] The above-mentioned computer-readable storage medium may be included in the QR code timeliness verification device; or it may exist independently without being assembled into the QR code timeliness verification device.
[0133] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the QR code timeliness verification device, the QR code timeliness verification device determines the initial time offset according to the scanning time of the QR code to be verified and the cloud time corresponding to the scanning time; determines the dynamic offset according to the offline running time and the historical average offset rate; based on the initial time offset and the dynamic offset, the generation time of the QR code to be verified is corrected to obtain the time to be verified; if the time to be verified is within the valid time interval, it is determined that the QR code to be verified passes the verification. The computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, and the programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" language or similar programming languages. The program code can be executed completely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or it can be connected to an external computer (for example, through the Internet using an Internet service provider).
[0134] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0135] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0136] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned two-dimensional code validity verification method, and can solve the technical problem of how to improve the accuracy of two-dimensional code validity verification. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the two-dimensional code validity verification method provided in the above-mentioned embodiment, and will not be repeated here.
[0137] An embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned QR code timeliness verification method.
[0138] The computer program product provided in this application can solve the technical problem of how to improve the accuracy of the validity verification of the QR code. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiment of this application are the same as the beneficial effects of the QR code validity verification method provided in the above embodiment, which will not be repeated here.
[0139] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.
Claims
1. A method for verifying the timeliness of a QR code, characterized in that: The method comprises: Determine an initial time offset according to the scanning time of the QR code to be verified and the cloud time corresponding to the scanning time; Determine the dynamic offset based on the offline operation time and the historical average offset rate; Based on the initial time offset and the dynamic offset, the generation time of the to-be-verified two-dimensional code is corrected to obtain the to-be-verified time; If the time to be verified is within the valid time interval, it is determined that the QR code to be verified has passed the verification.
2. The method according to claim 1, characterized in that Before the step of determining the dynamic offset according to the offline operation time and the historical average offset rate, the method further includes: Get the time when the server enters the offline state as the offline start time; The difference between the current time and the offline start time is used as the offline running time; Build a time offset model based on server clock data and standard time data; The historical average drift rate is determined according to the time drift model.
3. The method according to claim 2, characterized in that The step of constructing a time offset model based on the server clock data and the standard time data includes: Regularly synchronizing the server clock data with the standard time data, and recording the time difference data of each synchronization; Arrange the time difference data in chronological order; The time offset model is constructed based on the sorted time difference data and a preset data fitting algorithm.
4. The method according to claim 1, characterized in that Before the step of correcting the generation time of the to-be-verified two-dimensional code based on the initial time offset and the dynamic offset to obtain the to-be-verified time, the step further includes: Decoding the to-be-verified two-dimensional code to obtain decoding information; Compare the verification data in the decoded information with the preset verification data, and determine whether the two-dimensional code to be verified has been tampered with according to the comparison result; If not, the generation time of the two-dimensional code to be verified is extracted from the decoding information.
5. The method according to claim 1, characterized in that Before the step of determining that the to-be-verified two-dimensional code has passed the verification if the to-be-verified time is within the valid time interval, the method further includes: Based on the initial time offset and the dynamic offset, correct the current offline time to obtain an offline correction time; Determining the first closed interval endpoint according to the difference between the offline correction time and the preset effective time length; Taking the offline correction time as the endpoint of the second closed interval; The valid time interval is determined according to the first closed interval endpoint and the second closed interval endpoint.
6. The method according to claim 5, characterized in that After the step of determining that the to-be-verified QR code has passed the verification if the to-be-verified time is within the valid time interval, the method further includes: If the to-be-verified time is not within the valid time interval, the difference between the to-be-verified time and the endpoint of the first closed interval is taken as the first difference, and the difference between the to-be-verified time and the endpoint of the second closed interval is taken as the second difference; Determine whether the absolute value of the first difference or the absolute value of the second difference is less than a preset error threshold; If so, it is determined that the QR code to be verified has passed the verification.
7. A device for verifying the timeliness of a two-dimensional code, characterized in that: The device comprises: An initial offset determination module, used to determine an initial time offset according to a scanning time of the QR code to be verified and a cloud time corresponding to the scanning time; A dynamic offset determination module is used to determine the dynamic offset according to the offline operation time and the historical average offset rate; A generation correction module is used to correct the generation time of the to-be-verified two-dimensional code based on the initial time offset and the dynamic offset to obtain the to-be-verified time; The verification module is used to determine whether the QR code to be verified has passed the verification if the time to be verified is within a valid time interval.
8. A computer device, characterized in that: The device includes: a memory, a processor, and a QR code timeliness verification program stored in the memory and executable on the processor, wherein the QR code timeliness verification program is configured to implement the steps of the QR code timeliness verification method as described in any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium stores a QR code timeliness verification program, which, when executed by a processor, implements the steps of the QR code timeliness verification method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that The computer program product includes a computer program, and when the computer program is executed by a processor, the steps of the two-dimensional code time verification method as described in any one of claims 1 to 6 are implemented.
