Weak password judgment method and device
By splitting the password string into substrings and constructing an optimized array, the problem of low efficiency in weak password identification in existing technologies is solved, achieving efficient and accurate weak password determination and adapting to the security needs of different scenarios.
Patent Information
- Application Number
- CN202512000703.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-29
- Publication Date
- 2026-02-06
AI Technical Summary
In existing technologies, the BF algorithm and KMP algorithm have performance issues when identifying weak passwords, especially when the string is long. The execution of the judgment logic is time-consuming and there are many redundant operations, resulting in low efficiency in weak password identification.
By splitting the user-input password string into multiple substrings, a first array and a second array are constructed. The first array describes the prefix and suffix features of the pattern string pointer on the substring, and the second array indicates the backtracking position of the pattern string pointer when a match fails, thus optimizing the matching process and reducing redundant operations.
It improves the efficiency of weak password identification, reduces computational complexity and workload, enhances matching accuracy, reduces false positives and false negatives, and adapts to the security requirements of different scenarios.
Smart Images

Figure CN121485904A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method and apparatus for determining weak passwords. Background Technology
[0002] In today's digital age, secure websites have become an indispensable part of businesses, organizations, and individuals. However, website security faces many threats, the most common and vulnerable of which is passwords. Password security is directly related to the security of user data and information.
[0003] Weak passwords are easily cracked or guessed, are typically simple and easy to remember, lack complexity, and are often reused across multiple websites. For example, weak passwords can expose users to security risks such as brute-force attacks, dictionary attacks, social engineering attacks, and password reuse attacks, leading to user data breaches and other security problems. In contrast, strong passwords effectively improve website security, defend against various attacks, and protect user information. Therefore, website administrators and users should pay attention to password selection, avoid using weak passwords, and always use strong passwords to protect the security of individuals and organizations.
[0004] Currently, the BF algorithm (brute-force matching algorithm) is commonly used to identify weak passwords. However, the BF algorithm suffers from significant performance issues, especially with long strings. Executing the judgment logic is time-consuming and inefficient, contradicting the goal of high-performance software systems. In contrast, the KMP algorithm is used to identify weak passwords because the main string pointer does not backtrack, avoiding redundant comparisons and making it suitable for matching large numbers of strings. However, in the implementation of the KMP algorithm, even after backtracking, it still needs to compare identical characters, resulting in redundant operations that negatively impact the efficiency of weak password identification. Summary of the Invention
[0005] To address or partially address the problems existing in related technologies, this application provides a method and apparatus for determining weak passwords, which can reduce redundant and repetitive operations and improve the efficiency of weak password identification.
[0006] The first aspect of this application provides a method for determining weak passwords, including: Obtain the target string, which is used to indicate a preset continuous character sequence and / or keyboard character sequence; Obtain the password string input by the user, and split the password string into multiple substrings; A first array is determined for each substring, and a second array is determined based on the first array, wherein the first array is used to describe the prefix and suffix features of the pattern string pointer on the substring, and the second array is used to indicate the backtracking position of the pattern string pointer in the substring when a match fails; Based on the second array of each substring, the substring is matched with the target string, and the password determination result is determined based on the matching result. The password determination result is used to indicate whether the password string is a weak password.
[0007] In one possible implementation, splitting the password string into multiple substrings includes: Starting from the first character of the password string, iteratively extract consecutive characters of a preset substring length as a substring, until (m-n+1) substrings are obtained, where m is the password length of the password string and n is the substring length.
[0008] In one possible implementation, the first array contains at least one first element value corresponding to the pattern string pointer, the first element value indicating the initial jump position of the pattern string pointer in the substring when a match fails; determining the first array for each substring includes: For each substring, iteratively perform the following steps until the pattern string pointer has sequentially traversed all positions on the substring: Get the current dynamic variable, the current pattern string character, and the current dynamic character, wherein the dynamic variable is used to indicate the maximum equal prefix and suffix length on the substring corresponding to the current pattern string pointer, the pattern string character is used to indicate the character corresponding to the pattern string pointer on the substring, and the dynamic character is used to indicate the character corresponding to the current dynamic variable on the substring; Determine whether the current pattern string matches the current dynamic character; If a match is found, or if the current dynamic variable takes the value of the specified logical value, then the pattern string pointer is advanced to the next pending position, the dynamic variable is updated synchronously, and the updated dynamic variable value is written into the first element value in the first array corresponding to the next pattern string pointer. If there is no match, the current dynamic variable is backtracked to the first element value corresponding to the pattern string pointer in the first array that has the same value as the current dynamic variable, so as to re-determine whether the current pattern string character matches the dynamic character determined by the backtracked dynamic variable.
[0009] In one possible implementation, the second array contains at least one second element value corresponding to the pattern string pointer, the second element value being used to indicate the backtracking position in the substring when the pattern string pointer fails to match. Determining the second array based on the first array includes: For each substring, iteratively perform the following steps until the pattern string pointer has sequentially traversed all positions on the substring: Get the pattern string character pointed to by the current pattern string pointer; In the first array, obtain the first element value corresponding to the current pattern string pointer and the corresponding initial jump character. The initial jump character is used to describe the character corresponding to the initial jump position indicated by the first element value on the substring. Determine if the current pattern string matches the current initial jump character; If there is no match, the first element value corresponding to the current pattern string pointer is reused and written into the second element value corresponding to the current pattern string pointer in the second array; If a match is found, the second element value corresponding to the pattern string pointer that matches the current first element value will be written into the second array as the second element value corresponding to the current pattern string pointer.
[0010] In one possible implementation, the step of matching the substring with the target string based on the second array of each substring includes: For each substring, let the main string pointer start from the first character of the target string, and the pattern string pointer start from the first character of the substring, iteratively execute the following steps until all characters in the substring match their corresponding positions in the target string, or, the main string pointer has sequentially traversed all positions in the target string but at least one character in the substring does not match its corresponding position in the target string: Get the main string character corresponding to the current main string pointer, and the pattern string character corresponding to the current pattern string pointer; Determine whether the current main string character matches the current pattern string character; If a match is found, or if the current pattern string pointer points to a preset match restart position, then the main string pointer and the pattern string pointer are advanced to the next pending position, wherein the match restart position is used to indicate that the pattern string pointer is reset to the starting position; If there is no match, the current pattern string pointer is backtracked to the second element value in the second array corresponding to the current pattern string pointer, so as to re-determine whether the current main string character matches the current pattern string character determined by the backtracked pattern string pointer.
[0011] In one possible implementation, determining the password determination result based on the matching result includes: When it is determined that the password string meets all the preset judgment conditions, a first judgment result is generated to indicate that the password string is not a weak password. The judgment conditions include: a normal length condition corresponding to the password length of the password string, a normal character type condition corresponding to the character type of the password string, a non-repetition condition corresponding to the degree of character repetition of the password string, and a non-continuous condition corresponding to the matching result. If it is determined that the password string does not meet any of the determination conditions, a second determination result is generated to indicate that the password string is a weak password.
[0012] In one possible implementation, the normal length condition includes: the password length is greater than a preset first length threshold and does not exceed a preset second length threshold; The non-repetition condition includes: the number of consecutive repetitions of any character in the password string is less than a preset threshold.
[0013] In one possible implementation, determining whether the password string satisfies the normal character type condition involves the following steps: The password string is traversed sequentially for each character. When the password string is found to contain at least lowercase letters, uppercase letters, numbers, and specified special symbols, the password length of the password string is verified. When the password length is found to meet the normal length condition, it is determined that the password string meets the normal character type condition. If the password string is found to contain at least one of lowercase letters, uppercase letters, numbers, and specified special symbols, or if the password length is found to be inconsistent with the normal length condition, the password string is determined to be inconsistent with the normal character type condition.
[0014] In one possible implementation, determining whether the password string satisfies the non-continuous condition involves the following steps: When any substring is detected to match the target string, it is determined that the password string does not satisfy the non-contiguous condition; When it is detected that none of the substrings match the target string, it is determined that the password string satisfies the non-continuous condition.
[0015] A second aspect of this application provides a weak password determination device, comprising: A target string acquisition module is used to acquire a target string, which is used to indicate a preset continuous character sequence and / or keyboard character sequence; The password string acquisition module is used to acquire the password string input by the user and split the password string into multiple substrings; An array construction module is used to determine a first array for each substring and, based on the first array, to determine a second array, wherein the first array is used to describe the prefix and suffix features of the pattern string pointer on the substring, and the second array is used to indicate the backtracking position of the pattern string pointer in the substring when a match fails; The determination module is used to perform string matching between the substring and the target string based on the second array of each substring, and determine the password determination result based on the matching result. The password determination result is used to indicate whether the password string belongs to a weak password.
[0016] The weak password determination method and apparatus provided in this application obtains a target string and a password string input by the user, splits the password string into multiple substrings, determines a first array for each substring, and determines a second array based on the first array. The first array describes the prefix and suffix features of the pattern string pointer on the substring, and the second array indicates the backtracking position of the pattern string pointer in the substring when a match fails. Based on the second array of each substring, the substring is matched with the target string, and the password determination result is determined based on the matching result to indicate whether the password string belongs to a weak password. In this way, by optimizing the first array, the positions of repeated comparisons are skipped directly, reducing redundant operations of repeated character matching after backtracking, further improving matching efficiency, and effectively improving the identification efficiency of weak passwords.
[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0018] The above and other objects, features and advantages of this application will become more apparent from the following description of exemplary embodiments of this application in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components.
[0019] Figure 1 This is a flowchart illustrating a weak password determination method according to an embodiment of this application; Figure 2 This is a flowchart illustrating the method for determining the first array as shown in an embodiment of this application; Figure 3 This is a flowchart illustrating the method for determining the second array as shown in an embodiment of this application; Figure 4 This is a schematic diagram of the data matching process shown in an embodiment of this application; Figure 5This is a schematic diagram of a weak password determination device shown in an embodiment of this application. Detailed Implementation
[0020] Embodiments of this application will now be described in more detail with reference to the accompanying drawings. While embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to make this application more thorough and complete, and to fully convey the scope of this application to those skilled in the art.
[0021] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0022] It should be understood that although the terms "first," "second," "third," etc., may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0023] Currently, weak passwords are easily cracked or guessed, are typically simple and easy to remember, lack complexity, and are often reused across multiple websites. For example, weak passwords can lead to security risks such as brute-force attacks, dictionary attacks, social engineering attacks, and password reuse attacks, resulting in user data breaches and other security problems. In contrast, strong passwords can effectively improve website security, resist various cracking attacks, and protect user information. Therefore, website administrators and users should pay attention to password selection, avoid using weak passwords, and always use strong passwords to protect the security of individuals and organizations.
[0024] In related technologies, the BF algorithm (i.e., brute-force matching algorithm) is commonly used to identify weak passwords. It compares the pattern string with all possible starting positions of the main string one by one until a match is found or all possibilities have been traversed. However, the main string pointer needs to backtrack frequently, resulting in a large number of invalid and repeated comparisons, leading to low matching efficiency for long strings. It is clear that the BF algorithm has significant performance issues, especially when the string is long; executing the judgment logic is time-consuming and inefficient, violating the goal of high-performance software systems.
[0025] To address this, the KMP algorithm is used to identify weak passwords. Compared to the BF algorithm, although the main string pointer does not backtrack, avoiding a large number of repeated comparisons and making it suitable for matching a large number of strings, it still needs to compare the same characters after backtracking, which is an invalid and redundant operation and affects the identification efficiency of weak passwords to some extent.
[0026] Therefore, in scenarios where the pattern string contains a large number of repeated prefixes or long string matching, it is easy to affect the efficiency of character matching, thereby reducing the recognition efficiency of weak passwords.
[0027] To address the aforementioned issues, this application provides a method for determining weak passwords. By optimizing the array used to indicate the backtracking position of the pattern string pointer in the substring when a match fails, and using it for character matching, the method directly skips positions that are repeatedly compared, reduces redundant operations of repeated character matching after backtracking, and further improves matching efficiency. This effectively enhances the recognition efficiency of weak passwords.
[0028] The technical solutions of the embodiments of this application are described in detail below with reference to the accompanying drawings.
[0029] Figure 1 This is a flowchart illustrating a weak password determination method according to an embodiment of this application.
[0030] See Figure 1 The weak password determination method includes the following steps S101 to S104.
[0031] S101. Obtain the target string, which is used to indicate a preset continuous character sequence and / or keyboard character sequence.
[0032] In this application, a continuous character sequence can be a continuously ordered set of characters, which includes forward and reverse sequences, such as a sequence of numbers (e.g., 0123456789 and 9876543210), a sequence of lowercase letters (e.g., abcdefghijklmnopqrstuvwxyz), and a sequence of uppercase letters (e.g., ABCDEFGHIJKLMNOPQRSTUVWXYZ). It should be noted that the continuous character sequence can be the complete sequence described above (e.g., a sequence of numbers, lowercase letters, or uppercase letters), or it can be a sequence composed of multiple consecutive characters based on the complete sequence described above, such as "123456", "abcdef", and "654321". A keyboard character sequence can be a combination of characters from adjacent keys on a physical keyboard. Examples include QWERTY keyboard row sequences (such as qwertyuiop, asdfghjkl, zxcvbnm), column sequences (such as qaz, wsx, edc, etc.), and reverse sequences (poiuytrewq, lkjhgfdsa, etc.). It should be noted that this keyboard character sequence can be a complete sequence as described above (such as a row sequence, column sequence, or reverse sequence), or it can be a sequence composed of multiple consecutive keyboard characters based on a complete sequence, such as "qwert", "asdfg", "zxcvb", and "1qaz".
[0033] Optionally, all consecutive character sequences and keyboard character sequences can be concatenated into a long string called `sequences` (i.e., the target string), for example: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZqwertyuiopasdfghjklzxcvbnmpoiuytrewqlkjhgfdsa...".
[0034] Therefore, by integrating all the pattern sequences into a unified target string, this application can quickly determine whether the password string entered by the user is a continuous sorted character by judging whether the pattern string (i.e., the substring in this application) exists in the main string (i.e., the target string), while avoiding redundant calculations of repeated matching.
[0035] S102. Obtain the password string input by the user and split the password string into multiple substrings.
[0036] In this application, the password string input by the user can be "a123456b" or "qwert123". The password string is split into multiple substrings of fixed length. Optionally, splitting the password string using a sliding window ensures that no possible consecutive segments are missed, thus keeping the number of substrings controllable and preventing a surge in computation. For example, using a sliding window, the password string "a123456b" can be split into multiple substrings of length 3 and step size 1, such as "a12", "123", "234", "345", "456", and "56b". Optionally, the password string can be split into corresponding substrings according to a fixed length. For example, if the fixed length is set to 4, "qwert123" can be split into "qwer" and "t123".
[0037] Therefore, this application improves matching efficiency and enhances the feature coverage of substrings by splitting long password strings into short substrings, thus avoiding the low matching efficiency caused by directly comparing long strings (i.e., password strings) with target strings.
[0038] S103. Determine a first array for each substring, and determine a second array based on the first array, wherein the first array is used to describe the prefix and suffix features of the pattern string pointer on the substring, and the second array is used to indicate the backtracking position of the pattern string pointer in the substring when a match fails.
[0039] It should be noted that the first array is used to store the prefix and suffix features of the pattern string pointer in the substring. These features can be the length of the longest subsequence where the prefix and suffix are equal. For example, in the substring "ababa", the prefix "aba" and suffix "aba" are equal, and the length is 3. This first array is used to indicate the initial backtracking position of the pattern string pointer in the substring when a match fails. Subsequently, this application optimizes the first array to obtain a second array. This second array is used to indicate the optimized backtracking position of the pattern string pointer in the substring when a match fails. The backtracking position means that when a match fails, the pattern string pointer does not need to be reset to 0, but instead jumps to the optimal position indicated by the second array, avoiding invalid backtracking.
[0040] In this application, by optimizing the second array obtained after the first array, it is possible to eliminate the need to backtrack to the starting point when the pattern string pointer mismatches, and instead only jump to the optimal backtracking position. This solves the problem of invalid backtracking caused by duplicate characters, reduces the matching complexity, and thus improves the matching efficiency.
[0041] S104. Based on the second array of each substring, perform string matching between the substring and the target string, and determine the password determination result based on the matching result. The password determination result is used to indicate whether the password string belongs to a weak password.
[0042] In this application, based on the second array, it is determined whether a substring is a subsequence of the target string. The matching result indicates the matching status between the substring and the target string, which is either a successful match or a failed match. The password determination result indicates whether the password string is a weak password. For example, each substring is traversed, and the substring (equivalent to the pattern string) is matched with the target string (equivalent to the main string). If any substring matches the target string, it is considered a subsequence of the target string. If the substring is a continuous character sequence or a keyboard character sequence, the matching terminates and a successful match is output, meaning the password string is a weak password. For example, the substring "123" matches the target string "123456", so the password string is a weak password. If all substrings do not match the target string, the matching terminates and a failed match is output.
[0043] Therefore, this application achieves efficient subsequence matching through the second array, ensuring that a matching relationship is quickly found in the target string and multiple substrings. If only one substring is detected that matches the target string, it is determined to be a weak password. This avoids the situation where comparing identical characters after backtracking leads to invalid and redundant operations, reduces the amount of computation and computational complexity, improves the judgment speed and matching efficiency, and improves the matching accuracy, reduces false positives and false negatives, thereby improving the security of the password.
[0044] Furthermore, this application can determine the password determination result through four dimensions: password length, character type, repetition, and sorting. For example, when the password length, character type, character repetition degree, and matching result (i.e., all substrings do not match the target string) all meet preset conditions, a password determination result indicating that the password string is not a weak password is output. When at least one of the password length, character type, character repetition degree, and matching result does not meet the above preset conditions, a password determination result indicating that the password string is a weak password is output.
[0045] Therefore, this application determines the password judgment result by considering password length, character type, repetition, and sorting, achieving comprehensive coverage of weak password scenarios, improving the accuracy of weak password judgment, and adapting to the security requirements of different scenarios. Simultaneously, combining the second array for string matching reduces computational complexity and improves matching efficiency.
[0046] In some embodiments, splitting the password string into multiple substrings includes: Starting from the first character of the password string, iteratively extract consecutive characters of a preset substring length as a substring, until (m-n+1) substrings are obtained, where m is the password length of the password string and n is the substring length.
[0047] In this embodiment, the password string is split into substrings according to a set substring length n. Each substring has a length of n, resulting in (m-n+1) substrings. For example, starting from the first character, one substring of length n is extracted every time the character is slid one position. This extraction operation is repeated until the required number of substrings is met, ensuring that the password string is extracted into multiple substrings and avoiding the omission of features.
[0048] For example, the password string "abceaacab" has a password length of m=9 and a substring length of n=4. The password string can be split into (m-n+1)=6 substrings, namely "abce", "bcea", "ceaa", "eaac", "aaca", and "acab".
[0049] Therefore, this application can cover all consecutive length segments by splitting the password string into (m-n+1) substrings, ensuring that the password string is extracted as a substring, avoiding feature omissions, achieving comprehensive substring coverage, and avoiding the decrease in subsequent matching efficiency due to chaotic splitting rules, thus improving the efficiency of weak password identification.
[0050] Figure 2 This is a flowchart illustrating the method for determining the first array as shown in an embodiment of this application.
[0051] In some embodiments, such as Figure 2 As shown, the first array contains at least one first element value corresponding to the pattern string pointer, the first element value being used to indicate the initial jump position of the pattern string pointer in the substring when a match fails; determining the first array for each substring includes: For each substring, iteratively execute the following steps S201 to S204 until the pattern string pointer has sequentially traversed all positions on the substring: S201. Obtain the current dynamic variable, the current pattern string character, and the current dynamic character, wherein the dynamic variable is used to indicate the maximum equal prefix and suffix length on the substring corresponding to the current pattern string pointer, the pattern string character is used to indicate the character corresponding to the pattern string pointer on the substring, and the dynamic character is used to indicate the character corresponding to the current dynamic variable on the substring. S202. Determine whether the current pattern string matches the current dynamic character; S203. If a match is found, or if the current dynamic variable takes the value of a specified logical value, then the pattern string pointer is advanced to the next pending position, the dynamic variable is updated synchronously, and the updated dynamic variable value is written into the first element value in the first array corresponding to the next pattern string pointer. S204. If there is no match, the current dynamic variable is backtracked to the first element value corresponding to the pattern string pointer in the first array that has the same value as the current dynamic variable, so as to re-determine whether the current pattern string character matches the current dynamic character determined by the backtracked dynamic variable.
[0052] It should be noted that the first array can be the next array of the KMP algorithm. The length of the first array is the same as that of the substring. Each element in the first array (the first element value) is bound to a position of the pattern string pointer, storing the initial jump target of the pattern string pointer when a match fails at that position. It should also be noted that j represents the pattern string pointer, which points to the current processing position (index) of the substring. It is traversed sequentially in [0, j-1] to ensure that no values are missed in the first array. The essence of the first array is the length of the longest equal prefix and suffix of the substring [0, j-1]. The dynamic variable can be denoted as k, used to record the length of the longest equal prefix and suffix of the substring [0, j-1], and is also the initial backtracking target when a match fails, working in conjunction with the pattern string pointer j to advance or backtrack. The pattern string character is used to indicate the character pointed to by the pattern string pointer j in the substring (denoted as T[j]), and the dynamic character is used to indicate the character pointed to by the dynamic variable k in the substring (denoted as T[k]). The specified logical value can be the sentinel value (takes a value of -1) as defined by the KMP algorithm, used to mark the absence of a valid prefix and suffix, corresponding to an empty substring with 0 characters in the first position, triggering the pointer advance logic. Note that in this application, the sentinel value next[0] is defined as -1, corresponding to an empty substring without a prefix or suffix.
[0053] Exemplarily, based on the current dynamic variable and the pattern string pointer, extract the current pattern string character T[j], the current dynamic character T[k], and the current value of the dynamic variable k (i.e., the current length of the longest equal prefix and suffix). Subsequently, determine whether the current pattern string character matches the current dynamic character, and determine whether the current value of the dynamic variable is the specified logical value. Optionally, if the current pattern string character matches the current dynamic character, or the current value of the dynamic variable is the specified logical value (i.e., k = -1), then assign the first array: write the value of the current dynamic variable k into the bit corresponding to j in the first array (the first element value), that is, next[j] = k. In addition, the pointers are advanced synchronously: j += 1 (i.e., the pattern string pointer moves to the next position to be processed), and k += 1 (i.e., the length of the longest equal prefix and suffix + 1, updating the dynamic variable synchronously). Optionally, if the current pattern string character does not match the current dynamic character, and the current value of the dynamic variable is not the specified logical value, then the dynamic variable backtracks. Specifically, backtrack the dynamic variable to the first element value corresponding to the pattern string pointer in the first array that is the same as the current k value, that is, k = next[k]. The current value of k is the longest equal length in the previous stage, corresponding to the index k of the first array, and its first element value is the shorter effective prefix and suffix length. Thus, based on the backtracked dynamic variable k, extract the dynamic character T[k] again, and re-determine whether the dynamic character T[k] matches the currently held pattern string character T[j] until the current pattern string character matches the current dynamic character or the dynamic variable k is the specified logical value, and the pointer advances to the next bit. Therefore, iteratively repeat the above steps until the pattern string pointer sequentially traverses all positions on the substring, and output the first array (next array) that is exactly the same length as the substring length n. It should be noted that for the index characteristics of the first array, that is, the array index j corresponds one-to-one with the position of the pattern string pointer (0 ≤ j ≤ n - 1). For the first element value characteristics of the first array, its value range is [-1, 0, 1, ..., n - 2], and next[j] < j, so the backtracking position is before the current position to avoid infinite loops.
[0054] For example, taking the substring "T = aaaaaaaab" as an example, initially j=0, k=-1, next[0] = -1. Then, if z determines that the dynamic variable k=-1, the pointer advances to j=1, k=0, and next[1]= k = 0. Furthermore, if it is determined that T[j]= T[1]= a, T[k]= T[0]= a, then the current pattern string character matches the current dynamic character, the pointer advances to j=2, k=1, and next[2]= k = 1. Further, if it is determined that T[j]= T[2]= a, T[k]= T[1]= a, then the current pattern string character matches the current dynamic character, the pointer advances to j=3, k=2, and next[3]= k = 2. If it is determined that T[j] = T[3] = a and T[k] = T[2] = a, then the current pattern string character matches the current dynamic character, and the pointer advances to j = 4, k = 3, and next[4] = k = 3. Similarly, if j = 7 and k = 6, and it is determined that T[j] = T[7] = a and T[k] = T[6] = a, then the pointer advances to j = 8, k = 7, and next[8] = k = 7. Thus, j = 8, and all indices 0 to 8 have been traversed, so the iteration stops, and the first array is output as [-1, 0, 1, 2, 3, 4, 5, 6, 7].
[0055] Taking the substring "T = aafaaaaab" as an example, initially j=0, k=-1, next[0] = -1. Then, if z determines that the dynamic variable k=-1, the pointer advances to j=1, k=0, and next[1]= k = 0. Furthermore, if it is determined that T[j] = T[1]= a, T[k] = T[0]= a, then the current pattern string character matches the current dynamic character, the pointer advances to j=2, k=1, and next[2] = k = 1. Further, if it is determined that T[j]= T[2]= f, T[k]= T[1]= a, then the current pattern string character does not match the current dynamic character, so the current dynamic variable is backtracked to k = next[k]=next[1] = 0, and the current dynamic character (i.e., the dynamic character T[0] obtained after backtracking) is re-determined to match the current pattern string character T[2]. If it is determined that T[j] = T[2] = f and T[k] = T[0] = a, and they still do not match, then the current dynamic variable is backtracked to k = next[k] = next[0] = -1. If it is determined that the current dynamic variable k = -1, then the pointer is advanced to j = 3, k = 0, and next[3] = k = 0. If it is determined that T[j] = T[3] = a and T[k] = T[0] = a, and they match, then the pointer is advanced to j = 4, k = 1, and next[4] = k = 1. If it is determined that T[j] = T[4] = a and T[k] = T[1] = a, and they match, then the pointer is advanced to j = 5, k = 2, and next[5] = k = 2. If it is determined that T[j] = T[5] = a and T[k] = T[2] = f, which do not match, then the current dynamic variable is backtracked to k = next[k] = next[2] = 1, and the current dynamic character (i.e., the dynamic character T[1] obtained after backtracking) is re-evaluated to see if it matches the current pattern string character T[5]. If it is determined that T[j] = T[5] = a and T[k] = T[1] = a, which match, then the pointer is advanced to j = 6, k = 2, and next[6] = k = 2. If it is determined that T[j] = T[6] = a and T[k] = T[2] = f, which do not match, then the current dynamic variable is backtracked to k = next[k] = next[2] = 1, and the current dynamic character (i.e., the dynamic character T[1] obtained after backtracking) is re-evaluated to see if it matches the current pattern string character T[6]. If it is determined that T[j] = T[6] = a and T[k] = T[1] = a, and they match, then the pointer advances to j = 7, k = 2, and next[7] = k = 2.If it is determined that T[j] = T[7] = a and T[k] = T[2] = f, which do not match, then the current dynamic variable is backtracked to k = next[k] = next[2] = 1, and the current dynamic character (i.e., the dynamic character T[1] obtained after backtracking) is re-determined to match the current pattern string character T[7]. If it is determined that T[j] = T[7] = a and T[k] = T[1] = a, which match, then the pointer is advanced to j = 8, k = 2, and next[8] = k = 2. Thus, j = 8, all indices 0 to 8 have been traversed, the iteration stops, and the first array is output as [-1, 0, 1, 0, 1, 2, 2, 2, 2].
[0056] Therefore, this embodiment constructs a first array, indicating that when a match fails, the pattern string pointer does not need to be reset to 0. Instead, it backtracks to the initial jump position of the first array, reducing the comparison of repeated characters and providing a prerequisite for the second array. This eliminates the need to re-derive prefix and suffix features, thereby improving matching efficiency.
[0057] Figure 3 This is a flowchart illustrating the method for determining the second array as shown in an embodiment of this application.
[0058] In some embodiments, such as Figure 3 As shown, the second array contains at least one second element value corresponding to the pattern string pointer, and the second element value is used to indicate the backtracking position in the substring when the match fails; Determining the second array based on the first array includes: For each substring, iteratively execute the following steps S301 to S305 until the pattern string pointer has sequentially traversed all positions on the substring: S301. Obtain the pattern string character indicated by the current pattern string pointer; S302. In the first array, obtain the first element value corresponding to the current pattern string pointer and the corresponding initial jump character. The initial jump character is used to describe the character corresponding to the initial jump position indicated by the first element value on the substring. S303. Determine whether the current pattern string character matches the current initial jump character; S304. If there is no match, reuse the first element value corresponding to the current pattern string pointer and write it into the second array to the second element value corresponding to the current pattern string pointer. S305. If a match is found, the second element value corresponding to the pattern string pointer that matches the current first element value is written into the second array corresponding to the current pattern string pointer.
[0059] It should be noted that the length of the second array is exactly the same as the length of the substring and the first array. Each element of the second array (the second element value) corresponds to a position of the pattern string pointer, indicating the optimal backtracking position of the pattern string pointer when a match fails. Compared to the first array, it skips invalid backtracking paths (i.e., repeated invalid characters), improving matching efficiency. The second element value, i.e., each element of the second array, refers to the final jump target when a match fails. It either reuses the initial jump position of the first array or reuses an earlier second element value, ensuring a one-step backtrack. For example, the output is the second array, which has the same length as the substring and the first array. The index j of the second array corresponds one-to-one with the position of the pattern string pointer (0 ≤ j ≤ n-1). Therefore, compared to the first array, for consecutive positions of the same character, the second element value is optimized to -1 (skipping all invalid backtracking).
[0060] For example, based on the current pattern string pointer j, the current pattern string character T[j] is extracted. Then, the first element value next[j] corresponding to the pattern string pointer j is obtained from the first array, and the initial jump character T[next[j]] corresponding to this value is extracted. Further, it is determined whether the current pattern string character T[j] matches the current initial jump character T[next[j]]. If they do not match, the second element value in the second array is nextval[j] = next[j], that is, the initial jump position of the first array is reused. It can be understood that the initial jump position is valid at this time and is directly used as the optimal backoff position. If they match, the second element value in the second array is nextval[j] = nextval[next[j]], that is, the second element value corresponding to next[j] is used. It can be understood that the initial jump position is invalid at this time, the redundant backoff is skipped, and the earlier optimal position is directly reused. The above steps are repeated iteratively. When the last position of the substring is assigned a value, the pattern string pointer has traversed all positions in sequence, and the iteration terminates.
[0061] For example, taking the substring "T = aaaaaaaab" as an example, the first array is [-1, 0, 1, 2, 3, 4, 5, 6, 7]. If j=0, next[0]= -1, there is no initial jump character, then nextval[0] = next[0]= -1. If j=1, next[1]= 0, T[j]= T[1]= a, T[next[j]]= T[0]= a, they match, then the second element value corresponding to the first element value next[j] is used as the second element value corresponding to the pattern string pointer j, that is, nextval[1]= nextval[0]= -1. If j=2, next[2]= 1, T[j]= T[2]= a, T[next[j]]= T[1]= a, they match, then nextval[2]= nextval[1]= -1. If j=3, next[3]=2, T[j]=T[3]=a, T[next[j]]=T[2]=a, they match, then nextval[3]=nextval[2]=-1. Iterate through the above steps until j=8, next[8]=7, T[j]=T[8]=b, T[next[j]]=T[7]=a, they do not match, then reuse the first element value corresponding to the current pattern string pointer j=8, and write the second element value corresponding to the current pattern string pointer j=8, that is, nextval[8]=next[8]=7. Thus, the output second array is [-1,-1,-1,-1,-1,-1,-1,-1,-1,7].
[0062] Therefore, this embodiment constructs a second array using the first array, directly skipping redundant backtracking and eliminating invalid backtracking paths. This skips all invalid backtracking with consecutive identical characters, ensuring that the pattern string pointer is immediately positioned when a match fails, eliminating the need for multiple backtracking steps and improving matching efficiency. Thus, the second array significantly reduces redundant comparisons in the matching process, improving the real-time performance and efficiency of weak password detection.
[0063] Figure 4 This is a schematic diagram illustrating the data matching process in an embodiment of this application.
[0064] In some embodiments, such as Figure 4 As shown, the step of matching the substring with the target string based on the second array of each substring includes: For each substring, the main string pointer starts from the first character of the target string, and the pattern string pointer starts from the first character of the substring. The following steps S401 to S404 are iteratively executed until all characters in the substring match their corresponding positions in the target string, or until the main string pointer has sequentially traversed all positions in the target string but at least one character in the substring does not match its corresponding position in the target string. S401. Obtain the main string character corresponding to the current main string pointer and the pattern string character corresponding to the current pattern string pointer; S402. Determine whether the current main string character matches the current pattern string character; S403. If a match is found, or if the current pattern string pointer points to a preset match restart position, then the main string pointer and the pattern string pointer are advanced to the next pending position, wherein the match restart position is used to indicate that the pattern string pointer is reset to the starting position; S404. If there is no match, the current pattern string pointer is backtracked to the second element value in the second array corresponding to the current pattern string pointer, so as to re-determine whether the current main string character matches the current pattern string character determined by the backtracked pattern string pointer.
[0065] It should be noted that string matching refers to determining whether a substring (pattern string) is a continuous subsequence of the target string (main string). This is achieved through character comparison and backtracking, avoiding redundant calculations. The main string index can be denoted as i, pointing to the current character position (index) being compared in the target string; it only moves forward, not backtracks. The matching restart position can be the set sentinel value - 1 (consistent with the sentinel value of the second array), indicating that there are no valid prefixes available for reuse, and the pattern string pointer needs to be reset to the starting position (j=0) to restart matching.
[0066] Exemplarily, the main string character S[i] and the pattern string character T[j] are extracted, and it is determined whether the current main string character S[i] matches the current pattern string character T[j], so as to indicate the advancement or backtracking of the pointers (main string pointer, pattern string pointer). If they match, the matching is advanced (successful match), that is, the main string pointer and the pattern string pointer are advanced to the next position to be processed. If the current pattern string pointer points to the match restart position (i.e., j = -1), the match is restarted (no valid prefix). If they do not match, the pattern string pointer backtracks according to the second array, intelligently skipping invalid comparisons, and the main string does not backtrack. Specifically, the current pattern string pointer j is backtracked to the second element value corresponding to j in the second array, that is, j = nextval[j]. The above steps are iteratively repeated. When j == n, that is, all characters of the substring are matched, indicating that the substring contains weak password features, it is considered that any substring matches the target string, and the matching is terminated and a successful match is output. Optionally, when i == m and j < n, that is, the main string has been traversed and the characters on the substring are not all matched, and the substring has no weak password features, it is considered that all substrings do not match the target string, and the matching is terminated and a failed match is output.
[0067] For example, the target string is "123456", the substring is "235", and the second array is [-1, 0, 1]. Initialize, i = 0, j = 0. Then, if i = 0, j = 0, S[i] = S[0] = "1", T[j] = T[0] = "2", the current main string character S[0] does not match the current pattern string character T[0], so the pattern string pointer backtracks, i.e., j = nextval[0] = -1. Further, if i = 0, j = -1, then a restart is triggered, and the pointer advances to i = 1, j = 0. If i = 1, j = 0, S[i] = S[1] = "2", T[j] = T[0] = "2", they match, so the pointer advances to i = 2, j = 1. If i = 2, j = 1, S[i] = S[2] = "3", T[j] = T[1] = "3", they match, so the pointer advances to i = 3, j = 2. If i=3, j=2, S[i]=S[3]="4", T[j]=T[2]="5", there is no match, so the pattern string pointer backtracks, i.e., j=nextval[2]=1. If i=3, j=1, S[i]=S[3]="4", T[j]=T[1]="3", there is no match, so the pattern string pointer backtracks, i.e., j=nextval[1]=0. If i=3, j=0, S[i]=S[3]="4", T[j]=T[0]="2", there is no match, so the pattern string pointer backtracks, i.e., j=nextval[0]=-1. If i=3, j=-1, then a restart is triggered, and the pointer advances to i=4, j=0. When i=4 and i=5, S[4]=“5” and S[5]=“6” do not match T[0]= “2”. Finally, i=6, that is, the main string is traversed, and j=0 is less than 3, so the matching fails.
[0068] Therefore, this embodiment uses the second array to match the target string with the substring. The target string does not backtrack to ensure that all possible matching positions are traversed without missing any features. This avoids missed judgments caused by invalid backtracking, and allows for direct skipping of positions that are repeatedly compared. This reduces redundant operations of repeated character matching after backtracking, further improving matching efficiency and effectively enhancing the recognition efficiency of weak passwords.
[0069] In some embodiments, determining the password determination result based on the matching result includes: When it is determined that the password string meets all the preset judgment conditions, a first judgment result is generated to indicate that the password string is not a weak password. The judgment conditions include: a normal length condition corresponding to the password length of the password string, a normal character type condition corresponding to the character type of the password string, a non-repetition condition corresponding to the degree of character repetition of the password string, and a non-continuous condition corresponding to the matching result. If it is determined that the password string does not meet any of the determination conditions, a second determination result is generated to indicate that the password string is a weak password.
[0070] It should be noted that the password judgment result includes a first judgment result and a second judgment result. The first judgment result indicates that the password string is not a weak password (i.e., it is a strong password), and the second judgment result indicates that the password string is a weak password. Password length refers to the total number of characters in the user-input password string, such as "Abc123!" which has a length of 7. Character type refers to the character categories contained in the password string, such as uppercase letters, lowercase letters, numbers, and special characters (!@#$, etc.). Character repetition degree refers to the distribution characteristics of repeated characters in the password string, such as continuous repetition (e.g., "aaaa123") or overall repetition percentage (e.g., "aabbaa11" has a repetition percentage of 75%). The matching result is the string matching conclusion between the substrings in the preceding steps and the target string (continuous character sequence and / or keyboard character sequence), i.e., a successful match or a failed match. A successful match means that any substring matches the target string, and a failed match means that none of the substrings match the target string.
[0071] For example, the judgment criteria could include: a normal length condition (password length meets a preset security range, i.e., a minimum secure length (e.g., not less than 8 characters to avoid the risk of being too short and easily cracked) and a maximum length limit (e.g., not more than 20 characters to avoid excessive redundancy). A normal character type condition (password contains a sufficiently diverse range of character types, with a minimum of more than 2 or 3 character types; for example, the character type could be letters, numbers, special characters, etc., avoiding the risk of brute-force attacks due to a single type). A non-repetition condition (password character repetition does not exceed a preset threshold; for example, no more than 3 consecutive repeated characters, i.e., the maximum number of consecutive repeated characters is no more than 3, and the proportion of repeated characters is no more than 50%; avoiding the risk of easy guessing due to many repeated characters). A non-continuous condition (password does not contain a preset continuous character sequence or keyboard character sequence; i.e., all substrings do not match the target string, resulting in a matching failure; avoiding the risk of easily memorized and cracked regular sequences).
[0072] In this embodiment, the system determines whether the password string's length meets the normal length condition, whether the character type meets the normal character type condition, whether the character repetition degree meets the non-repetition condition, and whether the matching result meets the non-contiguous condition. Therefore, if any of the above conditions are not met (i.e., no condition is satisfied), meaning the password string's length, character type, character repetition degree, and matching result do not meet the non-contiguous condition, the password string is considered a weak password, and a second determination result is generated. If all the above conditions are met (i.e., all conditions are satisfied), meaning the password string's length, character type, character repetition degree, and matching result meet the non-contiguous condition, the password string is considered not a weak password, and a first determination result is generated.
[0073] For example, the system obtains the password string input by the user and determines whether its length meets the normal length condition. If the password string does not meet the normal length condition, it is considered a weak password, and a second determination result is generated. Further, if the password string length meets the normal length condition, the system determines whether the character type meets the normal character type condition. If the character type does not meet the normal character type condition, the password string is considered a weak password, and a second determination result is generated. Then, if the character type meets the normal character type condition, the system determines whether the character repetition degree of the password string meets the non-repetition condition. If the character repetition degree does not meet the non-repetition condition, the password string is considered a weak password, and a second determination result is generated. Further still, if the character repetition degree meets the non-repetition condition, the system determines whether the matching result meets the non-contiguous condition. If the matching result does not meet the non-contiguous condition, the password string is considered a weak password, and a second determination result is generated. Therefore, if the matching result meets the non-contiguous condition, the password string is considered not a weak password, and a first determination result is generated. Therefore, this embodiment achieves serial triggering and step-by-step verification by triggering the next judgment condition only when any judgment condition is met, which can effectively improve the judgment efficiency of weak passwords.
[0074] Therefore, this embodiment improves the comprehensiveness and accuracy of weak password identification by determining that a password is weak as soon as any one of the criteria is not met. Secondly, it only determines a password to be strong when all criteria are met, ensuring security and comprehensive coverage of multi-dimensional risks associated with strong passwords, while also improving the accuracy of strong password identification.
[0075] In some embodiments, the normal length condition includes: the password length is greater than a preset first length threshold and does not exceed a preset second length threshold; For example, the first length threshold can be the minimum secure length, such as 8 characters. Passwords shorter than the first length threshold are considered too short and weak. The second length threshold can be the maximum valid length, such as 20 characters. Passwords exceeding the second length threshold are considered too long and invalid. Specifically, if the password length is greater than the first length threshold but not exceeding the second length threshold, the password length is considered to meet the normal length condition. If the password length is less than or equal to the first length threshold, the password is considered too short. Short passwords have very few brute-force combinations, leading to increased password security risks. In this case, it is considered a weak password, and a second judgment result is directly generated. Alternatively, if the password length exceeds the second length threshold, the password is considered too long, leading to increased input error rate, storage redundancy, and no significant increase in brute-force difficulty. In this case, it is considered a weak password, and a second judgment result is directly generated.
[0076] Therefore, this embodiment improves the efficiency of determining whether the password length meets the normal length condition by configuring a first length threshold and a second length threshold, thus ensuring the security of strong passwords. Furthermore, by adjusting the first and second length thresholds, it enables rapid adaptation to different services and expands the scope of application.
[0077] In some embodiments, the non-repetition condition includes: the number of consecutive repetitions of any character in the password string is less than a preset number threshold.
[0078] In this embodiment, the consecutive repetition count refers to the total number of times the same character appears continuously without interruption. For example, in "111abcd", the consecutive repetition count of "1" is 3; in "aaabbb", the consecutive repetition counts of "a" and "b" are 3. Specifically, if the consecutive repetition count of any character in the password string is less than the threshold, the password length is considered to meet the normal length condition. If the consecutive repetition count of any character in the password string is not less than the threshold, the password length is considered not to meet the normal length condition, and it is regarded as a weak password, directly generating the second judgment result. In this way, this embodiment intercepts weak passwords with repetition features, with a high probability of cracking. At the same time, consecutive repetition of characters reduces the randomness of the password. By limiting the consecutive repetition count of characters, the diversity of characters can be increased, and the difficulty of guessing the password can be improved.
[0079] Therefore, this embodiment, by judging the number of consecutive repetitions of any character in the password string and comparing it to a threshold, can filter weak passwords with obvious repetition patterns, accurately intercepting weak passwords with repetitive characteristics and improving the accuracy of weak password identification. Simultaneously, by restricting password characters to reduce consecutive repetitions, it increases the diversity of password characters and improves password security.
[0080] In some embodiments, determining whether the password string meets the normal character type condition involves the following steps: The password string is traversed sequentially for each character. When the password string is found to contain at least lowercase letters, uppercase letters, numbers, and specified special symbols, the password length of the password string is verified. When the password length is found to meet the normal length condition, it is determined that the password string meets the normal character type condition. If the password string is found to contain at least one of lowercase letters, uppercase letters, numbers, and specified special symbols, or if the password length is found to be inconsistent with the normal length condition, the password string is determined to be inconsistent with the normal character type condition.
[0081] In this embodiment, the normal character type condition must simultaneously meet multiple character type and length criteria to quantify password complexity. Specifically, the password string is traversed character by character in order (from position 0 to position n-1) without skipping any characters to ensure no character type is missed. For each character, the character type is determined, for example, lowercase letters, uppercase letters, numbers, and specified special symbols. Furthermore, if the password string is found to fully cover the specified character types (i.e., lowercase letters, uppercase letters, numbers, and specified special symbols), then the password length is checked. At this point, the more character types in the password string, the more difficult it is to crack. Further still, the password length is judged based on a first length threshold and a second length threshold. If the password length falls between the first and second length thresholds, the password length is considered acceptable, triggering the password string to meet the normal character type condition. If the password length is less than the first length threshold or greater than the second length threshold, the password length is considered insufficient and does not meet the normal character type condition. In this case, it is considered a weak password, and a second judgment result is generated directly. Optionally, if it is determined that the characters in the password string do not completely cover the specified character type, for example, the password string only covers lowercase letters, uppercase letters, and numbers, but does not contain the specified special symbols, the password string is considered not to meet the normal character type condition. In this case, it is considered a weak password, and a second judgment result is generated directly.
[0082] Therefore, this embodiment determines that a password meets the normal character type condition by judging that all character types are fully covered and the length meets the standard. This improves the accuracy and efficiency of strong password determination, increases password complexity, raises the cost of cracking the password, and enhances password security. Conversely, if a password does not meet the normal character type condition by judging that the character types are not fully covered or the length does not meet the standard, passwords with all character types but too short a length, or passwords with the length meeting the standard but a single character type, are filtered out, thus increasing password complexity.
[0083] In some embodiments, determining whether the password string satisfies the non-continuous condition involves the following steps: When any substring is detected to match the target string, it is determined that the password string does not satisfy the non-contiguous condition; When it is detected that none of the substrings match the target string, it is determined that the password string satisfies the non-continuous condition.
[0084] It should be noted that the non-continuous condition refers to the criterion that the password string does not contain a preset high-risk pattern sequence (i.e., a continuous character sequence and / or a keyboard character sequence), in order to avoid weak password features such as "continuous characters / adjacent keyboard characters" that are easy to remember and crack. For example, if any substring matches the target string representing a continuous sequence, the password string is considered to contain a pattern sequence, and in this case, the password string does not meet the non-continuous condition. For instance, if the target string is "123456" and the password string is "1234abcd", and the substrings "123" and "234" match the target string, then the password string does not meet the non-continuous condition and is considered a weak password, directly generating the second judgment result. Optionally, if all substrings do not match the target string, the password string is considered to have no pattern sequence, and in this case, the password string meets the non-continuous condition.
[0085] Therefore, this embodiment filters out weak passwords containing regular sequences by matching the substring with the target string, thereby intercepting regular weak passwords, improving the accuracy of weak password identification, and ensuring password security.
[0086] Corresponding to the aforementioned application function implementation method embodiments, this application also provides a weak password determination device and corresponding embodiments.
[0087] Figure 5 This is a schematic diagram of a weak password determination device shown in an embodiment of this application.
[0088] See Figure 5 The weak password determination device 500 includes: The target string acquisition module 501 is used to acquire a target string, which is used to indicate a preset continuous character sequence and / or keyboard character sequence; The password string acquisition module 502 is used to acquire the password string input by the user and split the password string into multiple substrings; An array construction module 503 is used to determine a first array for each substring and, based on the first array, to determine a second array, wherein the first array is used to describe the prefix and suffix features of the pattern string pointer on the substring, and the second array is used to indicate the backtracking position of the pattern string pointer in the substring when a match fails. The determination module 504 is used to perform string matching between the substring and the target string according to the second array of each substring, and determine the password determination result according to the matching result. The password determination result is used to indicate whether the password string belongs to a weak password.
[0089] In some embodiments, the password string acquisition module 502 includes: The substring splitting unit is used to iteratively extract consecutive characters of a preset substring length, starting from the first character of the password string, as a substring, until (m-n+1) substrings are obtained, where m is the password length of the password string and n is the substring length.
[0090] In some embodiments, the first array includes at least one first element value corresponding to the pattern string pointer, the first element value being used to indicate the initial jump position of the pattern string pointer in the substring when a match fails. The array construction module 503 includes: The first array construction unit is used to iteratively execute the following unit for each substring until the pattern string pointer has sequentially traversed all positions on the substring: The first data acquisition unit is used to acquire the current dynamic variable, the current pattern string character, and the current dynamic character. The dynamic variable is used to indicate the maximum equal prefix and suffix length on the substring corresponding to the current pattern string pointer. The pattern string character is used to indicate the character corresponding to the pattern string pointer on the substring. The dynamic character is used to indicate the character corresponding to the current dynamic variable on the substring. The first judgment unit is used to determine whether the current pattern string character matches the current dynamic character; The first matching success unit is used to advance the pattern string pointer to the next pending position if a match is found, or if the current dynamic variable takes the value of a specified logical value, and to synchronously update the dynamic variable and write the updated dynamic variable value into the first element value in the first array corresponding to the next pattern string pointer. The first matching failure unit is used to backtrack the current dynamic variable to the first element value corresponding to the pattern string pointer in the first array that has the same value as the current dynamic variable if there is no match, so as to re-determine whether the current pattern string character matches the current dynamic character determined by the backtracked dynamic variable.
[0091] In some embodiments, the second array contains at least one second element value corresponding to the pattern string pointer, the second element value being used to indicate a backtracking position in the substring when a match fails. The array construction module 503 includes: The second array construction unit is used to iteratively execute the following unit for each substring until the pattern string pointer has sequentially traversed all positions on the substring: The second data acquisition unit is used to acquire the pattern string character indicated by the current pattern string pointer; The first array data acquisition unit is used to acquire the first element value corresponding to the current pattern string pointer and the corresponding initial jump character in the first array. The initial jump character is used to describe the character corresponding to the initial jump position indicated by the first element value on the substring. The second judgment unit is used to determine whether the current pattern string character matches the current initial jump character; The second matching failure unit is used to reuse the first element value corresponding to the current pattern string pointer and write it into the second element value corresponding to the current pattern string pointer in the second array if there is no match. The second matching success unit is used to write the second element value corresponding to the pattern string pointer that matches the current first element value into the second array if a match is found.
[0092] In some embodiments, the determination module 504 includes: A string matching unit is used to iteratively execute the following units for each substring, starting from the first character of the target string and the first character of the substring, until all characters in the substring match their corresponding positions in the target string, or, the main string pointer has sequentially traversed all positions in the target string but at least one character in the substring does not match its corresponding position in the target string: The third data acquisition unit is used to acquire the main string character corresponding to the current main string pointer and the pattern string character corresponding to the current pattern string pointer. The third judgment unit is used to determine whether the current main string character matches the current pattern string character; The third matching success unit is used to advance the main string pointer and the pattern string pointer to the next pending position if a match is found or the current pattern string pointer points to a preset matching restart position. The matching restart position is used to indicate that the pattern string pointer is reset to the starting position. The third matching failure unit is used to backtrack the current pattern string pointer to the second element value in the second array corresponding to the current pattern string pointer if there is no match, so as to re-determine whether the current main string character matches the current pattern string character determined by the backtracked pattern string pointer.
[0093] In some embodiments, the determination module 504 includes: The first determination unit is used to generate a first determination result indicating that the password string does not belong to a weak password when it is determined that the password string meets the preset determination conditions. The determination conditions include: a normal length condition corresponding to the password length of the password string, a normal character type condition corresponding to the character type of the password string, a non-repetition condition corresponding to the degree of character repetition of the password string, and a non-continuous condition corresponding to the matching result. The second determination unit is used to generate a second determination result indicating that the password string belongs to a weak password when it is determined that the password string does not meet any of the determination conditions.
[0094] In some embodiments, the normal length condition includes: the password length is greater than a preset first length threshold and does not exceed a preset second length threshold; The non-repetition condition includes: the number of consecutive repetitions of any character in the password string is less than a preset threshold.
[0095] In some embodiments, the determination module 504 includes: The character type determination unit is used to sequentially traverse each character of the password string, and when it is detected that the password string contains at least lowercase letters, uppercase letters, numbers and specified special symbols, it verifies the password length of the password string; The password length normal unit is used to determine that the password string meets the normal character type condition when the password length is found to meet the normal length condition. The character type exception unit is used to determine that the password string does not meet the normal character type condition when it is detected that the password string does not contain at least one of lowercase letters, uppercase letters, numbers and specified special symbols, or when the password length is found to be not in accordance with the normal length condition.
[0096] In some embodiments, the determination module 504 includes: A continuity determination unit is used to determine that the password string does not meet the non-continuous condition when any substring is detected to match the target string; The non-continuous determination unit is used to determine that the password string satisfies the non-continuous condition when it is detected that none of the substrings match the target string.
[0097] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated further here.
[0098] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A method for determining weak passwords, characterized in that, include: Obtain the target string, which is used to indicate a preset continuous character sequence and / or keyboard character sequence; Obtain the password string input by the user, and split the password string into multiple substrings; A first array is determined for each substring, and a second array is determined based on the first array, wherein the first array is used to describe the prefix and suffix features of the pattern string pointer on the substring, and the second array is used to indicate the backtracking position of the pattern string pointer in the substring when a match fails; Based on the second array of each substring, the substring is matched with the target string, and the password determination result is determined based on the matching result. The password determination result is used to indicate whether the password string is a weak password.
2. The weak password determination method according to claim 1, characterized in that, The step of splitting the password string into multiple substrings includes: Starting from the first character of the password string, iteratively extract consecutive characters of a preset substring length as a substring, until (m-n+1) substrings are obtained, where m is the password length of the password string and n is the substring length.
3. The weak password determination method according to claim 1, characterized in that, The first array contains at least one first element value corresponding to the pattern string pointer, the first element value being used to indicate the initial jump position of the pattern string pointer in the substring when a match fails; The determination of the first array for each substring includes: For each substring, iteratively perform the following steps until the pattern string pointer has sequentially traversed all positions on the substring: Get the current dynamic variable, the current pattern string character, and the current dynamic character, wherein the dynamic variable is used to indicate the maximum equal prefix and suffix length on the substring corresponding to the current pattern string pointer, the pattern string character is used to indicate the character corresponding to the pattern string pointer on the substring, and the dynamic character is used to indicate the character corresponding to the current dynamic variable on the substring; Determine whether the current pattern string matches the current dynamic character; If a match is found, or if the current dynamic variable takes the value of the specified logical value, then the pattern string pointer is advanced to the next pending position, the dynamic variable is updated synchronously, and the updated dynamic variable value is written into the first element value in the first array corresponding to the next pattern string pointer. If there is no match, the current dynamic variable is backtracked to the first element value corresponding to the pattern string pointer in the first array that has the same value as the current dynamic variable, so as to re-determine whether the current pattern string character matches the dynamic character determined by the backtracked dynamic variable.
4. The weak password determination method according to claim 3, characterized in that, The second array contains at least one second element value corresponding to the pattern string pointer, the second element value being used to indicate the backtracking position in the substring when the match fails; Determining the second array based on the first array includes: For each substring, iteratively perform the following steps until the pattern string pointer has sequentially traversed all positions on the substring: Get the pattern string character indicated by the current pattern string pointer; In the first array, obtain the first element value corresponding to the current pattern string pointer and the corresponding initial jump character. The initial jump character is used to describe the character corresponding to the initial jump position indicated by the first element value on the substring. Determine if the current pattern string matches the current initial jump character; If there is no match, the first element value corresponding to the current pattern string pointer is reused and written into the second element value corresponding to the current pattern string pointer in the second array; If a match is found, the second element value corresponding to the pattern string pointer that matches the current first element value will be written into the second array as the second element value corresponding to the current pattern string pointer.
5. The weak password determination method according to claim 4, characterized in that, The step of matching the substring with the target string based on the second array of each substring includes: For each substring, let the main string pointer start from the first character of the target string, and the pattern string pointer start from the first character of the substring, iteratively execute the following steps until all characters in the substring match their corresponding positions in the target string, or, the main string pointer has sequentially traversed all positions in the target string but at least one character in the substring does not match its corresponding position in the target string: Get the main string character corresponding to the current main string pointer, and the pattern string character corresponding to the current pattern string pointer; Determine whether the current main string character matches the current pattern string character; If a match is found, or if the current pattern string pointer points to a preset match restart position, then the main string pointer and the pattern string pointer are advanced to the next pending position, wherein the match restart position is used to indicate that the pattern string pointer is reset to the starting position; If there is no match, the current pattern string pointer is backtracked to the second element value in the second array corresponding to the current pattern string pointer, so as to re-determine whether the current main string character matches the current pattern string character determined by the backtracked pattern string pointer.
6. The weak password determination method according to claim 1, characterized in that, The step of determining the password determination result based on the matching result includes: When it is determined that the password string meets all the preset judgment conditions, a first judgment result is generated to indicate that the password string is not a weak password. The judgment conditions include: a normal length condition corresponding to the password length of the password string, a normal character type condition corresponding to the character type of the password string, a non-repetition condition corresponding to the degree of character repetition of the password string, and a non-continuous condition corresponding to the matching result. If it is determined that the password string does not meet any of the determination conditions, a second determination result is generated to indicate that the password string is a weak password.
7. The weak password determination method according to claim 6, characterized in that, The normal length condition includes: the password length is greater than a preset first length threshold and does not exceed a preset second length threshold; The non-repetition condition includes: the number of consecutive repetitions of any character in the password string is less than a preset threshold.
8. The weak password determination method according to claim 6 or 7, characterized in that, The following steps are used to determine whether the password string meets the normal character type condition: The password string is traversed sequentially for each character. When the password string is found to contain at least lowercase letters, uppercase letters, numbers, and specified special symbols, the password length of the password string is verified. When the password length is found to meet the normal length condition, it is determined that the password string meets the normal character type condition. If the password string is found to contain at least one of lowercase letters, uppercase letters, numbers, and specified special symbols, or if the password length is found to be inconsistent with the normal length condition, the password string is determined to be inconsistent with the normal character type condition.
9. The weak password determination method according to claim 6, characterized in that, The following steps are used to determine whether the password string meets the non-continuous condition: When any substring is detected to match the target string, it is determined that the password string does not satisfy the non-contiguous condition; When it is detected that none of the substrings match the target string, it is determined that the password string satisfies the non-continuous condition.
10. A weak password detection device, characterized in that, include: A target string acquisition module is used to acquire a target string, which is used to indicate a preset continuous character sequence and / or keyboard character sequence; The password string acquisition module is used to acquire the password string input by the user and split the password string into multiple substrings; An array construction module is used to determine a first array for each substring and, based on the first array, to determine a second array, wherein the first array is used to describe the prefix and suffix features of the pattern string pointer on the substring, and the second array is used to indicate the backtracking position of the pattern string pointer in the substring when a match fails; The determination module is used to perform string matching between the substring and the target string based on the second array of each substring, and determine the password determination result based on the matching result. The password determination result is used to indicate whether the password string belongs to a weak password.