Password generation method, offline password verification method, electronic device, and storage medium

By generating and returning a preset password on the server, the device performs encryption operations based on the validity period and the current time, which solves the problems of low efficiency and high energy consumption of offline verification on the device and realizes fast and low-energy password verification.

CN115883083BActive Publication Date: 2026-01-30SHANGHAI MXCHIP INFORMATION TECHN
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211557570.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-06
Publication Date
2026-01-30
Estimated Expiration
2042-12-06

AI Technical Summary

Technical Problem

The device needs to interact with the server to verify the validity of the password entered by the user, which takes a long time, affects the user experience, and increases energy consumption.

Method used

The server generates and returns a preset password. The device determines the target time period for encryption based on the password's validity period and the current time. If the encryption results match, the verification is successful, thus achieving offline verification.

Benefits of technology

It improves the efficiency of password verification on the device side, reduces the interaction time with the server, and lowers energy consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115883083B_ABST
    Figure CN115883083B_ABST
Patent Text Reader

Abstract

This application discloses a password generation method, an offline password verification method, an electronic device, and a storage medium, belonging to the technical field of information security technology. The password generation method, applied to a server, includes: if a password generation request is received from an APP, encrypting the time of receipt of the password generation request to obtain a first string; concatenating the first string with a second string to obtain a preset password; returning the preset password to the APP so that the user can enter the password on the device; wherein, the device determines a target time period based on the password's validity period and the current time, and encrypts the times within the target time period to obtain a third string; if the third string matches the first string, the device determines that the preset password verification is successful. This application can generate passwords that can be verified offline by the device, improving the password verification efficiency of the device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information security technology, and in particular to a password generation method, an offline password verification method, an electronic device, and a storage medium. Background Technology

[0002] With the development of technology, electronic devices such as smart door locks, smart TVs, and smart storage cabinets have brought great convenience to people's lives and work. To improve the security of these devices, passwords are usually set on the device itself. When the user enters the correct password, the device can operate normally or provide the corresponding services.

[0003] In related technologies, the device must connect to the server to verify the validity of the password entered by the user. However, the interaction process between the device and the server takes a long time, which affects the user experience and increases the device's energy consumption.

[0004] Therefore, how to generate passwords that enable offline verification on the device side and improve the password verification efficiency on the device side is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this application is to provide a password generation method, a password generation system, an offline password verification method, an offline password verification system, an electronic device, and a storage medium, which can generate passwords that can be verified offline by the device, thereby improving the password verification efficiency of the device.

[0006] To address the aforementioned technical problems, this application provides a password generation method applied to a server, the password generation method comprising:

[0007] If a password generation request is received from the APP, an encryption operation is performed on the moment the password generation request is received to obtain the first string;

[0008] The first string and the second string are concatenated to obtain the preset password; wherein, the second string is determined according to the password validity period Δt;

[0009] The preset password is returned to the APP so that the user can enter the password on the device. The device is used to determine the target time period [T0-Δt, T0] based on the password validity period Δt and the current time T0, and to perform an encryption operation on the time within the target time period to obtain a third string. If the third string is consistent with the first string, the device determines that the preset password has been successfully verified.

[0010] Optionally, before performing the encryption operation upon receiving the password generation request, the method further includes:

[0011] The time base value is synchronized between the APP and the device.

[0012] Accordingly, an encryption operation is performed on the moment the password generation request is received to obtain a first string, including:

[0013] Calculate the difference between the time of receiving the password generation request and the time base value to obtain the target time difference;

[0014] An encryption operation is performed based on the target time difference to obtain the first string.

[0015] Optionally, before performing the encryption operation based on the target time difference, the method further includes:

[0016] Query the encryption key corresponding to the device identity information on the device side;

[0017] The encryption key is synchronized between the APP and the device.

[0018] Accordingly, an encryption operation is performed based on the target time difference to obtain the first string, including:

[0019] The target time difference is encrypted using the encryption key to obtain the first string.

[0020] Optionally, an encryption operation is performed based on the target time difference to obtain the first string, including:

[0021] Divide the target time difference by the password generation cycle and round the result to obtain the target text;

[0022] The target text is encrypted to obtain the first string.

[0023] Optionally, before performing the encryption operation upon receiving the password generation request, the method further includes:

[0024] The timestamps are synchronized between the APP and the device.

[0025] Optionally, before concatenating the first string and the second string to obtain the preset password, the method further includes:

[0026] Query the validity period Δt of the password corresponding to the device identity information on the device side;

[0027] Alternatively, the validity period Δt of the password can be determined by parsing the password generation request.

[0028] This application also provides an offline password verification method, applied to a device, including:

[0029] Receive a preset password; wherein the preset password is obtained by the server concatenating a first string and a second string, the first string is obtained by the server performing an encryption operation on the moment the password generation request is received, and the second string is determined by the server according to the password validity period Δt;

[0030] Extract the second string from the preset password, and determine the password validity period Δt based on the second string;

[0031] The target time period [T0-Δt, T0] is determined based on the password validity period Δt and the current time T0;

[0032] Encryption is performed on the times within the target time period to obtain a third string;

[0033] If the third string matches the first string, then the preset password verification is successful.

[0034] Optionally, an encryption operation is performed on the times within the target time period to obtain a third string, including:

[0035] Encryption operations are performed on multiple target moments within the target time period to obtain multiple third strings;

[0036] Correspondingly, it also includes:

[0037] Construct a password pool that includes multiple of the aforementioned third strings;

[0038] Determine whether the third string exists in the password pool; if yes, determine that a third string that matches the first string exists; if no, determine that a third string that matches the first string does not exist.

[0039] Optionally, before performing the encryption operation on the time points within the target time period, the method further includes:

[0040] Receive the time base value synchronized by the server via the APP;

[0041] Accordingly, an encryption operation is performed on the time points within the target time period to obtain a third string, including:

[0042] Select a target time point from the target time period;

[0043] Calculate the difference between the target time and the time base value to obtain alternative time differences;

[0044] An encryption operation is performed based on the alternative time difference to obtain the third string.

[0045] Optionally, before performing the encryption operation based on the alternative time difference, the method further includes:

[0046] Receive the encryption key synchronized by the server via the APP;

[0047] Accordingly, an encryption operation is performed based on the alternative time difference to obtain the third string, including:

[0048] The third string is obtained by encrypting the alternative time difference using the encryption key.

[0049] Optionally, an encryption operation is performed based on the alternative time difference to obtain the third string, including:

[0050] Divide the candidate time difference by the password generation cycle and round the result to obtain the candidate text;

[0051] The candidate text is encrypted to obtain the third string.

[0052] This application also provides a password generation system for use on a server, including:

[0053] The string determination module is used to perform an encryption operation on the moment the password generation request is received if a password generation request is received from the APP, so as to obtain a first string;

[0054] The concatenation module is used to concatenate the first string and the second string to obtain a preset password; wherein the second string is determined according to the password validity period Δt;

[0055] The password return module is used to return the preset password to the APP so that the user can enter the password on the device. The device is used to determine a target time period [T0-Δt, T0] based on the password validity period Δt and the current time T0, and to perform an encryption operation on the time within the target time period to obtain a third string. If the third string is consistent with the first string, the device determines that the preset password has been successfully verified.

[0056] This application also provides an offline password verification system for use on a device, including:

[0057] A password receiving module is used to receive a preset password; wherein the preset password is obtained by the server concatenating a first string and a second string, the first string is obtained by the server performing an encryption operation on the moment the password generation request is received, and the second string is determined by the server according to the password validity period Δt;

[0058] The effective duration determination module is used to extract the second string from the preset password and determine the effective duration Δt of the password based on the second string.

[0059] The time period determination module is used to determine the target time period [T0-Δt, T0] based on the password validity duration Δt and the current time T0;

[0060] The encryption module is used to perform encryption operations on the time within the target time period to obtain a third string;

[0061] The verification module is used to determine that the preset password verification is successful if the third string is consistent with the first string.

[0062] This application also provides a storage medium storing a computer program thereon, which, when executed, implements the steps of the above-described password generation method or offline password verification method.

[0063] This application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor invokes the computer program in the memory to implement the steps of the above-described password generation method or offline password verification method.

[0064] This application provides a password generation method applied to a server, comprising: if a password generation request is received from an APP, performing an encryption operation on the time of receiving the password generation request to obtain a first string; concatenating the first string with a second string to obtain a preset password; wherein the second string is determined according to the password validity period Δt; returning the preset password to the APP so that the user can enter the password on the device; wherein the device is used to determine a target time period [T0-Δt, T0] according to the password validity period Δt and the current time T0, and performing an encryption operation on the time within the target time period to obtain a third string; if the third string is consistent with the first string, the device determines that the preset password has been successfully verified.

[0065] In this application, the server performs an encryption operation on the received time of the password generation request to obtain a first string related to the received time and encrypted therewith. A second string related to the password validity period Δt is then concatenated with the first string to obtain a preset password. The server returns the preset password to the APP, allowing the user to input the password on the device based on the preset password received by the APP. The device can use the password validity period Δt and the current time T0 to determine a target time period [T0-Δt, T0], and then perform an encryption operation on the times within the target time period to obtain a third string. If the received time is within the target time period, the device can generate a third string identical to the first string. If the third string matches the first string, it indicates that the current time is within the valid time period corresponding to the preset password, and the device can then determine that the preset password verification is successful. This application generates passwords that enable offline verification by the device, improving the password verification efficiency of the device. This application also provides a password generation system, an offline password verification method, an offline password verification system, an electronic device, and a storage medium, all with the aforementioned beneficial effects, which will not be elaborated further here. Attached Figure Description

[0066] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0067] Figure 1 A flowchart illustrating a password generation method provided in an embodiment of this application;

[0068] Figure 2 A flowchart illustrating an offline password verification method provided in an embodiment of this application;

[0069] Figure 3 This is a schematic diagram illustrating the principle of an offline time-limited password generation method provided in an embodiment of this application;

[0070] Figure 4 This is a schematic diagram of the structure of a password generation system provided in an embodiment of this application;

[0071] Figure 5 This is a schematic diagram of the structure of a password generation system provided in an embodiment of this application. Detailed Implementation

[0072] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0073] Please see below. Figure 1 , Figure 1 This is a flowchart of a password generation method provided in an embodiment of this application.

[0074] Specific steps may include:

[0075] S101: If a password generation request is received from the APP, an encryption operation is performed on the moment the password generation request is received to obtain a first string;

[0076] This embodiment can be applied to a server connected to an APP. The APP can assist users in obtaining the password of the device. The APP can be a mobile APP, a tablet APP, etc., and the device can be a smart door lock, a smart TV, a smart storage cabinet, etc.

[0077] Upon receiving a password generation request, the server can determine the time when the request was received and perform an encryption operation on the received time to obtain a first string, which is an encrypted string related to the received time.

[0078] The aforementioned app can be bound to a device, allowing users to send password generation requests to the server via the app. These requests can include the device's identity information, enabling the server to identify the device requiring password generation. As a possible implementation, the server can determine the device's security level based on the device identity information and select an appropriate encryption algorithm to encrypt the received data. Correspondingly, the device uses the same encryption algorithm as the server for encrypting the received data.

[0079] To improve the standardization and convenience of the password, this embodiment can extract a portion of the encryption result at the moment of reception to obtain the first string, so that the number of bits of the first string is a fixed value N1 (e.g., 6 bits).

[0080] S102: Concatenate the first string and the second string to obtain the preset password;

[0081] Prior to this step, the password validity period Δt can be obtained, and the second string can be determined based on the password validity period. The aforementioned password validity period Δt describes the duration for which the preset password can be verified on the device. For example, if the server generates a preset password based on the time T1 when the password generation request is received and the validity period Δt, then the validity period of the password is within the range of [T1, T1+Δt].

[0082] This step maps the password validity period Δt to obtain the second string. To improve the standardization and convenience of the password, the number of digits in the second string can be a fixed value N² (e.g., 1 digit). The mapping algorithm that maps the password validity period Δt to the second string is a reversible algorithm, and the device can recover the password validity period Δt from the second string.

[0083] After obtaining the first string and the second string, the first string and the second string can be concatenated according to the preset concatenation rules to obtain the preset password. The preset password can be [first string] + [second string] or [second string] + [first string].

[0084] S103: Return the preset password to the APP so that the user can enter the password on the device;

[0085] After receiving the preset password, the server can return it to the app. Users on the app can then enter the preset password on their devices. Specifically, the app can display the received preset password, allowing users to enter it on their devices according to the app's instructions.

[0086] After receiving the password entered by the user, the device can determine the first string and the second string from the password based on preset concatenation rules, and determine the password validity period Δt based on the second string. The device can then determine a target time period [T0-Δt, T0] based on the password validity period Δt and the current time T0, and perform encryption operations on multiple moments within the target time period to obtain a third string. If the third string matches the first string, it means that the current time T0 is within the preset password validity period range [T1, T1+Δt], and the device can then determine that the preset password verification was successful.

[0087] In this embodiment, the server performs an encryption operation on the received time of the password generation request, obtaining an encrypted first string. A second string related to the password validity period Δt is then concatenated with the first string to obtain a preset password. The server returns the preset password to the APP, allowing the user to input the password on the device based on the preset password received on the APP. The device can use the password validity period Δt and the current time T0 to determine a target time period [T0-Δt, T0], and then perform an encryption operation on the times within the target time period to obtain a third string. If the received time is within the target time period, the device can generate a third string identical to the first string. If the third string matches the first string, it indicates that the current time is within the valid time period corresponding to the preset password, and the device can then determine that the preset password verification is successful. This embodiment generates a password that enables offline verification on the device, improving the password verification efficiency on the device.

[0088] As for Figure 1 As further described in the embodiment, before performing the encryption operation at the moment of receiving the password generation request, the server can also synchronize the time base value with the device through the APP client;

[0089] Accordingly, the server can obtain the first string by performing encryption operations as follows: calculating the difference between the receiving time of the password generation request and the time base value to obtain a target time difference; performing encryption operations based on the target time difference to obtain the first string. The target time difference is the absolute value of the difference between the receiving time and the time base value.

[0090] Furthermore, before performing the encryption operation based on the target time difference, the encryption key corresponding to the device identity information on the device side can be queried; the encryption key can be synchronized between the APP and the device side; accordingly, the server can use the encryption key to perform the encryption operation on the target time difference to obtain the first string.

[0091] Furthermore, the server can be set with a password generation period (e.g., 60 seconds). The target time difference is divided by the password generation period and rounded to obtain the target text. Encryption is then performed on the target text to obtain the first string. The rounding operation can be rounding up, rounding down, or rounding based on a rounding function.

[0092] By combining the above-described methods for determining the first string, the following approach can also be obtained: calculate the difference between the time of receiving the password generation request and the time base value to obtain the target time difference; divide the target time difference by the password generation period and round the result to obtain the target text; use the encryption key to perform an encryption operation on the target text to obtain the first string.

[0093] As for Figure 1 Further, before receiving the password generation request from the APP, the server can synchronize timestamps with the device via the APP to ensure time synchronization between the server and the device. Since information transmission takes time, the server can send its current timestamp and a timestamp compensation value to the APP for synchronization with the device. The timestamp compensation value is determined based on the information transmission delay between the APP and the server, and between the APP and the device.

[0094] As for Figure 1 Further, before concatenating the first string and the second string to obtain the preset password, the password validity period can be determined using either method 1 or method 2:

[0095] Method 1: Query the validity period Δt of the password corresponding to the device identity information on the device side;

[0096] Method 2: Determine the password validity period Δt by parsing the password generation request.

[0097] In method 1 above, the server can store the mapping between device identity information and password validity period for each device, and the required password validity period can be determined based on this mapping. In method 2 above, the APP can add the password validity period to the password generation request sent to the server, and the server can determine the password validity period by parsing the password generation request.

[0098] Please see below. Figure 2 , Figure 2 This is a flowchart illustrating an offline password verification method provided in an embodiment of this application. This offline password verification method can be applied to a device, and its specific steps may include:

[0099] S201: Receive preset password;

[0100] The preset password is obtained by the server concatenating a first string and a second string. The first string is obtained by the server performing an encryption operation at the moment the password generation request is received, and the second string is determined by the server based on the password validity period Δt.

[0101] As a feasible implementation method, the server described above can be a server capable of implementing the password generation method described above. The process of generating the preset password includes: if a password generation request is received from the APP, an encryption operation is performed on the time of receiving the password generation request to obtain a first string; the first string is concatenated with a second string to obtain a preset password; wherein, the second string is determined according to the password validity period Δt; the preset password is returned to the APP so that the user can enter the password on the device.

[0102] After receiving the preset password on the device, it determines whether the number of digits of the preset password is the preset value (e.g., 7 digits). If yes, the subsequent steps of this embodiment are executed; otherwise, the normal password verification process is executed.

[0103] S202: Extract the second string from the preset password, and determine the password validity duration Δt based on the second string;

[0104] The preset password is obtained by the server by concatenating the first string and the second string according to the preset concatenation rules. The device can divide the preset password into the first string and the second string based on the above preset concatenation rules, and then extract the first string and the second string from the preset password.

[0105] Specifically, the server can use a reversible mapping algorithm to map the above password validity period Δt to obtain the second string, and the device can perform the inverse operation of the mapping algorithm on the second string to obtain the password validity period Δt.

[0106] S203: Determine the target time period [T0-Δt, T0] based on the password validity duration Δt and the current time T0;

[0107] After obtaining the password validity period Δt and the current time T0, we can trace back from the current time T0 to obtain the target time period [T0-Δt, T0].

[0108] S204: Perform an encryption operation on the time within the target time period to obtain a third string;

[0109] The device can use the encryption algorithm used by the server to encrypt the time within the target time period to obtain a third string; when the selected time within the target time period is the same as the receiving time, the first string and the third string are the same.

[0110] As a feasible implementation method, the device can perform encryption operations on multiple moments within the target time period at preset intervals (60 seconds) to obtain a third string.

[0111] In this embodiment, after each generation of a third string, the first string is compared with the currently generated third string; if they do not match, the next third string is generated again, until the first string and the third string match or the time points selected according to the preset interval within the target time period are traversed.

[0112] This embodiment can generate multiple third strings, and then compare the first string with all the third strings.

[0113] S205: If the third string is consistent with the first string, then the preset password verification is determined to be successful.

[0114] This embodiment determines the password validity period Δt based on the received preset password, and determines the target time period [T0-Δt, T0] based on the password validity period Δt and the current time T0. Encryption is performed on the times within the target time period to obtain a third string. The first string is related to the received time. If the received time is within the target time period, the device can generate a third string identical to the first string. If the third string matches the first string, it indicates that the current time is within the valid time period corresponding to the preset password, and the device can then determine that the preset password has been successfully verified. This process does not require interaction between the device and the server, enabling offline password verification on the device and improving password verification efficiency.

[0115] As for Figure 1 In a further description of the corresponding embodiment, the device can also perform encryption operations on multiple target times within the target time period to obtain multiple third strings; construct a password pool including multiple third strings; determine whether the third string is in the password pool; if yes, determine that there is a third string consistent with the first string; if no, determine that there is no third string consistent with the first string.

[0116] As for Figure 1 In a further description of the corresponding embodiment, before performing the encryption operation on the time within the target time period, the device can also receive a time base value synchronized by the server through the APP. The process of the server generating the first string includes: calculating the difference between the time of receiving the password generation request and the time base value to obtain a target time difference; performing an encryption operation based on the target time difference to obtain the first string.

[0117] Accordingly, the process of encrypting the time within the target time period to obtain the third string on the device side includes: selecting a target time from the target time period; calculating the difference between the target time and the time base value to obtain a candidate time difference; and performing an encryption operation based on the candidate time difference to obtain the third string. The aforementioned candidate time difference is the absolute value of the difference between the target time and the time base value. Specifically, in this embodiment, multiple target times can be selected from the target time period with a password generation cycle as the step size. For example, if the target time period is [15:49, 15:53] and the password generation cycle is 1 minute, then the target times are 15:49, 15:50, 15:51, 15:52, and 15:53 ​​respectively.

[0118] As for Figure 1 In a further description of the corresponding embodiment, before performing the encryption operation based on the alternative time difference, the server can also receive an encryption key synchronized via the APP. The process by which the server performs the encryption operation based on the target time difference to obtain the first string includes: using the encryption key to perform an encryption operation on the target time difference to obtain the first string.

[0119] Accordingly, the process of the device performing an encryption operation based on the alternative time difference to obtain the third string includes: using the encryption key to perform an encryption operation on the alternative time difference to obtain the third string.

[0120] The server can divide the target time difference by the password generation period and round the result to obtain the target text; then, it performs an encryption operation on the target text to obtain the first string. Correspondingly, the device can divide the alternative time difference by the password generation period and round the result to obtain the alternative text; then, it performs an encryption operation on the alternative text to obtain the third string. The rounding operation can be an up-rounding operation, a down-rounding operation, or a rounding operation based on a rounding function.

[0121] In addition, the server can determine the first string by: calculating the difference between the time of receiving the password generation request and the time base value to obtain the target time difference; dividing the target time difference by the password generation period and rounding the result to obtain the target text; and using the encryption key to perform an encryption operation on the target text to obtain the first string.

[0122] Accordingly, the device can determine the third string in the following way: select a target time from the target time period; calculate the difference between the target time and the time base value to obtain a candidate time difference; divide the candidate time difference by the password generation period and round the result to obtain a candidate text; use the encryption key to perform an encryption operation on the candidate text to obtain the third string.

[0123] The process described in the above embodiments is illustrated below through examples in practical applications.

[0124] In related technologies, devices typically rely on a connection to a server to verify the validity of a password. The specific interaction process is as follows: The app initiates a request to bind and initialize the device; the device responds, indicating successful binding and initialization; the app sends a request to the server to generate a password; the server responds, returning the password; the user enters the password on the device, which then connects to the server via Wi-Fi / Ethernet to request password verification; the server returns the verification result to the device; and the device displays the password verification result to the user.

[0125] The above-mentioned device-side password verification process is quite cumbersome. Taking the device-side interaction with the server using a Wi-Fi module as an example, the verification process of the Wi-Fi module is divided into the following steps: (1) The Wi-Fi module is powered on by the door lock board (about 0.5 seconds); (2) The Wi-Fi module connects to the router (about 3-5 seconds); (3) The Wi-Fi module connects to the server (about 1-2 seconds); (4) The Wi-Fi module sends a verification request to the server (about 0.5 seconds); (5) The server returns the verification result (about 0.5 seconds).

[0126] In the aforementioned conventional device-side password verification process, each specific step increases the time it takes for the user to obtain the verification result, greatly impacting the user experience; furthermore, during the Wi-Fi connection process, the device's power consumption is very high (instantaneous transmission power of 500mA@3.3V), reducing the overall usage time of the device.

[0127] To address the shortcomings of the aforementioned related technologies, this application provides an offline time-limited password generation scheme. Please refer to [link to relevant documentation]. Figure 3 , Figure 3 This is a schematic diagram illustrating the principle of an offline time-limited password generation method provided in an embodiment of this application. The method includes the following steps:

[0128] Step 1: The APP initiates a request to bind and initialize the device;

[0129] Step 2: The device responds, indicating successful binding and initialization;

[0130] Step 3: The app synchronizes the server's timestamp with the device.

[0131] Step 4: The device responds, and the timestamp synchronization is successful;

[0132] Step 5: The APP requests the device key from the server;

[0133] In this embodiment, the server determines the device key based on the device's identity information. The device in this embodiment may have an RTC clock (Real-time clock) and flash storage capabilities. Synchronizing the timestamp and device key enables the device to generate passwords offline.

[0134] Step 6: The server returns the device key;

[0135] Step 7: The APP synchronizes the device key with the device.

[0136] Step 8: Device response: Device key synchronization successful;

[0137] The operations in steps 1 to 8 above can be the initialization process of the device when it is used for the first time. In the subsequent password generation process, the operations in steps 1 to 8 do not need to be repeated.

[0138] Step 9: The app sends a request to the server to generate a preset password;

[0139] Step 10: The server responds and returns the preset password to the APP.

[0140] After step 10, the subsequent password verification process can be completed without the device being connected to the internet.

[0141] Step 11: The user enters the password on the device;

[0142] Step 12: Verify the password's validity locally on the device;

[0143] Step 13: The device displays the password verification result.

[0144] As a feasible implementation, if the device is a smart lock, it can perform an unlocking operation and display the unlocking result after successful password verification. During this process, the device can verify the password without an internet connection, resulting in fast verification and improved user experience. The device only needs to synchronize timestamps during the initial pairing and binding with the app; no further internet connection is required. This solution saves on device power consumption and has significant advantages in low-power applications.

[0145] The following example illustrates the specific process of a server generating an offline preset password:

[0146] In this embodiment, all times are converted to Unix timestamp format, and the letters have the following meanings:

[0147] Δt represents the password validity period in minutes, for example: 10, 20, 30, 40, 50, 60;

[0148] T 基This represents the time base value, for example, 1546272000 (Beijing time 2019-01-01 00:00:00);

[0149] T1 represents the server's current Unix timestamp, in seconds;

[0150] T0 represents the current Unix timestamp on the device, in seconds;

[0151] T 周 T represents the password generation period. 周 This is a preset variable, for example, with a value of 60 seconds;

[0152] K represents the device key that the device synchronizes with the server during the initialization phase. Each device has its own unique device key.

[0153] Truncate represents a string generation algorithm, and its implementation process is as follows:

[0154] <1> HMAC-SHA-512 encryption (K as the encryption key and C as the content to be encrypted) yields a 64-byte encrypted string.

[0155] <2> Take the last byte of this 64-byte encrypted string, and take the lower 4 bits of this byte as the index offset for truncating the encrypted string;

[0156] <3> Starting from the index offset, obtain 4 bytes and assemble them into an integer using big-endian format;

[0157] <4> Extract the last 6 digits of this integer to obtain the final string (i.e., the first or third string mentioned above).

[0158] There are many ways to implement Truncate; this article only illustrates one calculation method.

[0159] The following describes the process of generating offline passwords on the server:

[0160] Calculation steps:

[0161] (1) C=(T1-T 基 ) / T 周 ;

[0162] (2) key1 = Truncate(K, C);

[0163] (3) key2 = {Δt / 10}{key1}, string concatenation;

[0164] Key1 represents the first string, key2 represents the preset password, and Δt / 10 represents the second string.

[0165] The data example is as follows:

[0166] Initial value:

[0167] T 基 =1546272000, T1=1555989814, Δt=10 (minutes);

[0168] K = AA8C98F643492D18;

[0169] Calculated value:

[0170] C=(1555989814-1546272000) / 60=161963;

[0171] Key1 = Truncate(AA8C98F643492D18,161963) = 643890 (which is equivalent to generating a password every 60 seconds);

[0172] Key2={10 / 10}{643890}=1643890.

[0173] The following describes the offline password verification process on the device:

[0174] The premise of this embodiment is that the door opening time on the device side is T0, and T0 is later than T1 in the normal process;

[0175] For the device side, if the locksmith enters a 7-digit password, the device's short-term password verification mechanism is triggered. The device first extracts the first digit of the 7-digit password to determine the password validity period Δt. Based on the password validity period Δt, the device calculates the entire password pool that needs to be valid within the time range [T0-Δt, T0] preceding the current time T0. If the entered password is within the password pool, the verification passes; otherwise, the verification fails. The password pool valid within the time range [T0-Δt, T0] can be equivalently simplified to (C_USER-Δt / 10)~C_USER, calculated as follows:

[0176] (1) C_USER = (T0 - T 基 ) / T 周 ;

[0177] (2) The C_USER-Δt / 10 ~ C_USER is calculated;

[0178] (3)Truncate(K,[C_USER-Δt / 10,C_USER]) can get the key pool. For example, if Δt is 10 minutes, it will generate 10 6-character third strings.

[0179] (4) If the last 6 digits of the door opening password are any one of the password pool key_pool (i.e., the first string and the third string mentioned in the above embodiment are the same), then the password verification is considered to be successful; otherwise, the verification fails.

[0180] In the above embodiments, the passwords generated by the server are all in the format T. 周 Passwords are generated in units of 60 (representing 1 minute). The device generates a password pool based on the time range (the first character of the password). If the unlocking password is in the password pool, the verification is successful. The device performs the password verification locally during the verification process, taking no more than 100ms, which is a significant advantage compared to online verification schemes. The device does not require an internet connection during verification, greatly saving battery power and improving standby time.

[0181] Please see Figure 4 , Figure 4 This is a schematic diagram of a password generation system provided in an embodiment of this application. The system can be applied to a server and includes:

[0182] The string determination module 401 is used to perform an encryption operation on the moment the password generation request is received if a password generation request is received from the APP to obtain a first string;

[0183] The concatenation module 402 is used to concatenate the first string and the second string to obtain a preset password; wherein the second string is determined according to the password validity period Δt;

[0184] The password return module 403 is used to return the preset password to the APP so that the user can enter the password on the device. The device is used to determine a target time period [T0-Δt, T0] based on the password validity period Δt and the current time T0, and to perform an encryption operation on the time within the target time period to obtain a third string. If the third string is consistent with the first string, the device determines that the preset password has been successfully verified.

[0185] In this embodiment, the server performs an encryption operation on the received time of the password generation request, obtaining a first string related to the received time and encrypted therewith. A second string related to the password validity period Δt is then concatenated with the first string to obtain a preset password. The server returns the preset password to the APP, allowing the user to input the password on the device based on the preset password received on the APP. The device can use the password validity period Δt and the current time T0 to determine a target time period [T0-Δt, T0], and then perform an encryption operation on the times within the target time period to obtain a third string. If the received time is within the target time period, the device can generate a third string identical to the first string. If the third string matches the first string, it indicates that the current time is within the valid time period corresponding to the preset password, and the device can then determine that the preset password verification was successful. This embodiment generates a password that enables offline verification on the device, improving the password verification efficiency on the device.

[0186] Furthermore, it also includes:

[0187] The base value synchronization module is used to synchronize the time base value between the APP and the device before performing the encryption operation at the moment of receiving the password generation request;

[0188] Accordingly, the process by which the string determination module 401 performs an encryption operation on the receiving time of the password generation request to obtain the first string includes: calculating the difference between the receiving time of the password generation request and the time base value to obtain a target time difference; and performing an encryption operation based on the target time difference to obtain the first string.

[0189] Furthermore, it also includes:

[0190] The key synchronization module is used to query the encryption key corresponding to the device identity information on the device side before performing the encryption operation based on the target time difference; it is also used to synchronize the encryption key with the device side through the APP side.

[0191] Accordingly, the process by which the string determination module 401 performs an encryption operation based on the target time difference to obtain the first string includes: using the encryption key to perform an encryption operation on the target time difference to obtain the first string.

[0192] Furthermore, the process by which the string determination module 401 performs an encryption operation based on the target time difference to obtain the first string includes: dividing the target time difference by the password generation period and rounding the result to obtain the target text; and performing an encryption operation on the target text to obtain the first string.

[0193] Furthermore, it also includes:

[0194] The time synchronization module is used to synchronize the timestamp between the APP and the device before performing the encryption operation at the moment the password generation request is received.

[0195] Furthermore, it also includes:

[0196] The information query module is used to query the validity period Δt of the password corresponding to the device identity information of the device before concatenating the first string and the second string to obtain the preset password;

[0197] Alternatively, a request parsing module is used to determine the password validity period Δt by parsing the password generation request before concatenating the first string and the second string to obtain the preset password.

[0198] Please see Figure 5 , Figure 5 This is a schematic diagram of a password generation system provided in an embodiment of this application. The system can be applied to a device and includes:

[0199] The password receiving module 501 is used to receive a preset password; wherein, the preset password is obtained by the server concatenating a first string and a second string, the first string is obtained by the server performing an encryption operation on the moment the password generation request is received, and the second string is determined by the server according to the password validity period Δt;

[0200] The effective duration determination module 502 is used to extract the second string from the preset password and determine the effective duration Δt of the password based on the second string;

[0201] The time period determination module 503 is used to determine the target time period [T0-Δt, T0] based on the password validity duration Δt and the current time T0;

[0202] Encryption module 504 is used to perform encryption operations on the time within the target time period to obtain a third string;

[0203] The verification module 505 is used to determine that the preset password verification is successful if the third string is consistent with the first string.

[0204] This embodiment determines the password validity period Δt based on the received preset password, and determines the target time period [T0-Δt, T0] based on the password validity period Δt and the current time T0. Encryption is performed on the times within the target time period to obtain a third string. The first string is related to the received time. If the received time is within the target time period, the device can generate a third string identical to the first string. If the third string matches the first string, it indicates that the current time is within the valid time period corresponding to the preset password, and the device can then determine that the preset password has been successfully verified. This process does not require interaction between the device and the server, enabling offline password verification on the device and improving password verification efficiency.

[0205] Furthermore, the encryption module 504 performs encryption operations on the times within the target time period to obtain the third string, which includes: performing encryption operations on multiple target times within the target time period to obtain multiple third strings;

[0206] Correspondingly, it also includes:

[0207] A password pool construction module is used to construct a password pool including multiple third strings; it is also used to determine whether the third string is in the password pool; if so, it is determined that there is a third string that is consistent with the first string; if not, it is determined that there is no third string that is consistent with the first string.

[0208] Furthermore, it also includes:

[0209] The base value receiving module is used to receive the time base value synchronized by the server through the APP before performing the encryption operation on the time within the target time period;

[0210] Accordingly, the encryption module 504 performs an encryption operation on the time within the target time period to obtain the third string, which includes: selecting a target time from the target time period; calculating the difference between the target time and the time base value to obtain a candidate time difference; and performing an encryption operation based on the candidate time difference to obtain the third string.

[0211] Furthermore, it also includes:

[0212] The key receiving module is used to receive the encryption key synchronized by the server through the APP before performing the encryption operation according to the alternative time difference;

[0213] Accordingly, the encryption module 504 performs an encryption operation based on the alternative time difference to obtain the third string, which includes: using the encryption key to perform an encryption operation on the alternative time difference to obtain the third string.

[0214] Furthermore, the encryption module 504 performs an encryption operation based on the candidate time difference to obtain the third string, which includes: dividing the candidate time difference by the password generation period and rounding the result to obtain the candidate text; and performing an encryption operation on the candidate text to obtain the third string.

[0215] Since the embodiments of the system part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the system part, and they will not be repeated here.

[0216] This application also provides a storage medium on which a computer program is stored, which, when executed, can perform the steps provided in the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0217] This application also provides an electronic device that may include a memory and a processor. The memory stores a computer program, and when the processor calls the computer program in the memory, it can implement the steps provided in the above embodiments. Of course, the electronic device may also include various network interfaces, power supplies, and other components.

[0218] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.

[0219] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A method of generating a password, characterized by, Applied to a server, comprising: If a password generation request sent by an APP end is received, performing an encryption operation on a time when the password generation request is received to obtain a first string; The first string and a second string are spliced to obtain a preset password; wherein the second string is determined according to a password validity duration determined; The preset password is returned to the APP so that the user can enter the password on the device; wherein, the device is used to determine the password's validity period. Determine the target time period [T0-] based on the current time T0. [T0], and perform encryption operation on the time within the target time period to obtain a third string; if the third string is consistent with the first string, the device determines that the preset password verification is successful; the preset password is the password generated by the server based on the time T1 of receiving the password generation request and the password validity period. The generated password, wherein the valid time range of the preset password is: [T1, T1+] If the third string is consistent with the first string, then it is determined that the current time T0 is within the valid time period corresponding to the preset password.

2. The password generating method of claim 1, wherein, Before performing the encryption operation on the time when the password generation request is received, further comprising: Synchronizing a time base value between the APP end and the device end; Correspondingly, performing the encryption operation on the time when the password generation request is received to obtain the first string, comprising: Calculating a difference between the time when the password generation request is received and the time base value to obtain a target time difference value; Performing an encryption operation according to the target time difference value to obtain the first string.

3. The password generating method of claim 2, wherein, Before performing the encryption operation according to the target time difference value, further comprising: Querying an encryption key corresponding to device identity information of the device end; Synchronizing the encryption key between the APP end and the device end; Correspondingly, performing the encryption operation according to the target time difference value to obtain the first string, comprising: Performing the encryption operation on the target time difference value by using the encryption key to obtain the first string.

4. The password generating method of claim 2, wherein, Performing the encryption operation according to the target time difference value to obtain the first string, comprising: Taking an integer of a result of dividing the target time difference value by a password generation period to obtain a target text; Performing the encryption operation on the target text to obtain the first string.

5. The password generating method of claim 1, wherein, Before performing the encryption operation on the time when the password generation request is received, further comprising: Synchronizing a timestamp between the APP end and the device end.

6. The password generating method of claim 1, wherein, Before concatenating the first string and the second string to obtain a preset password, further comprising: query the password valid duration corresponding to the device identity information of the device end ; or, determining the password validity duration by analyzing the password generation request .

7. An off-line password verification method characterized by, Applied to a device end, comprising: receiving a preset password; wherein the preset password is obtained by the server by concatenating a first string and a second string, the first string is obtained by the server by performing an encryption operation on a time instant of receiving a password generation request, and the second string is obtained by the server according to a password valid duration determining; extracting the second string from the preset password, determining the password validity duration according to the second string ; According to the password valid duration and the current time T0 to determine the target time period [T0- , T0]. Performing an encryption operation on a time in a target time period to obtain a third string; If the third string is consistent with the first string, determining that the preset password is verified successfully; The preset password is generated by the server based on a receiving time T1 of the password generation request and a password validity time length The generated password, and a validity time range of the preset password is [T1, T1+ ]; if the third string is consistent with the first string, it is determined that the current time T0 is within the validity time period corresponding to the preset password.

8. The off-line password verification method of claim 7, wherein, Performing the encryption operation on the time in the target time period to obtain the third string, comprising: Performing the encryption operation on a plurality of target times in the target time period to obtain a plurality of the third strings; Correspondingly, further comprising: Constructing a password pool comprising the plurality of the third strings; Determining whether the third string is in the password pool; if yes, determining that there is the third string consistent with the first string; if no, determining that there is no third string consistent with the first string.

9. The off-line password verification method of claim 7, wherein, Before performing the encryption operation on the time in the target time period, further comprising: Receiving a time base value synchronized by the APP end of the server; Correspondingly, performing the encryption operation on the time in the target time period to obtain the third string, comprising: Selecting a target time from the target time period; Calculating a difference between the target time and the time base value to obtain a candidate time difference value; Performing the encryption operation according to the candidate time difference value to obtain the third string.

10. The off-line password verification method of claim 9, wherein, Before performing the encryption operation according to the candidate time difference value, further comprising: Receiving an encryption key synchronized by the APP end of the server; Correspondingly, performing the encryption operation according to the candidate time difference value to obtain the third string, comprising: The encryption key is used to perform an encryption operation on the alternative time difference value to obtain the third string.

11. The off-line password verification method of claim 9, wherein, The encryption operation is performed on the alternative time difference value to obtain the third string, including: The alternative time difference value is divided by a password generation period, and the result is rounded to obtain an alternative text; The encryption operation is performed on the alternative text to obtain the third string.

12. A cryptographic generation system characterized by, Applied to a server, including: A string determination module is configured to, if a password generation request sent by an APP end is received, perform an encryption operation on a time instant when the password generation request is received to obtain a first string; The splicing module is configured to splice the first character string and a second character string to obtain a preset password, wherein the second character string is determined according to a password validity duration ; A password return module is used to return the preset password to the APP so that the user can enter the password on the device; wherein, the device is used to determine the password validity period. Determine the target time period [T0-] based on the current time T0. [T0], and perform encryption operation on the time within the target time period to obtain a third string; if the third string is consistent with the first string, the device determines that the preset password verification is successful; the preset password is the password generated by the server based on the time T1 of receiving the password generation request and the password validity period. The generated password, wherein the valid time range of the preset password is: [T1, T1+] If the third string is consistent with the first string, then it is determined that the current time T0 is within the valid time period corresponding to the preset password.

13. An offline password verification system, characterized by, Applied to a device end, including: The password receiving module is configured to receive a preset password, wherein the preset password is obtained by splicing a first string and a second string by a server, the first string is obtained by performing an encryption operation on a time instant of receiving a password generation request by the server, and the second string is obtained by the server according to a password validity duration determination. The effective duration determination module is configured to extract the second character string from the preset password, and determine the password effective duration according to the second character string ; The time period determination module is used to determine the validity period of the password. Determine the target time period [T0-] based on the current time T0. [,T0]; An encryption module is configured to perform an encryption operation on a time instant in the target time period to obtain a third string; A verification module is configured to, if the third string is consistent with the first string, determine that the preset password verification is successful. The preset password is generated by the server based on a receiving time T1 of the password generation request and a password validity time length The generated password, and a validity time range of the preset password is [T1, T1+ ]; if the third string is consistent with the first string, it is determined that a current time T0 is within the validity time period corresponding to the preset password.

14. An electronic device, comprising: A memory and a processor are included, the memory stores a computer program, and the processor calls the computer program in the memory to implement the steps of the password generation method in any one of claims 1 to 6 or the offline password verification method in any one of claims 7 to 11.

15. A storage medium, characterized by The storage medium stores computer executable instructions, and the computer executable instructions are loaded and executed by the processor to implement the steps of the password generation method in any one of claims 1 to 6 or the offline password verification method in any one of claims 7 to 11.

Citation Information

Patent Citations

  • Offline password generation method, offline password verification method and door lock management server

    CN110430055A

  • Method and device for processing off-line password of equipment

    CN114299636A