Identity card number retrieval method

By extracting the first two digits of the year in the ID card and searching in the pending data, and confirming the ID card number in combination with the ID card verification method, the problem of matching errors when the ID card number and other numbers or characters appear continuously is solved, achieving efficient Accurate ID number positioning and information protection.

CN119311925APending Publication Date: 2025-01-14SUZHOU SUCHENG WIRELESS APPL CENT
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411011133.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

In the prior art, when the ID number and other numbers or characters appear continuously, matching positioning based on regular expressions is prone to errors, resulting in an increase in the risk of information leakage and manual re-check is required.

Method used

By initializing the year set and subscript set, extract the first two digits of the possible year in the ID card, search and confirm their location one by one in the pending data, obtain a string of the same length as the ID card number, and pass the ID card verification Methods confirm its authenticity and avoid mislocalization.

Benefits of technology

It realizes accurate positioning of ID card numbers in mixed characters and numerical strings, avoids information leakage, and improves matching accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311925A_ABST
    Figure CN119311925A_ABST
Patent Text Reader

Abstract

According to the identity card number retrieval method provided by the invention, the character string with the same length as the identity card number is extracted from the initial data set on the basis of the number part capable of determining the content in the identity card, namely the first two digits of the year data, and then the extracted character string is verified through the existing identity number verification mode; whether the identity number is a real identity number is confirmed, so that the problem of inaccurate identity card verification result caused by mixing of numbers and characters is avoided; the method is simple in design thought and convenient to implement, and is particularly suitable for accurately positioning the identity card number in the character string with mixed characters and numerical values.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of number recognition, in particular to a method for retrieving identity card numbers. Background Art

[0002] In many applications, it is necessary to desensitize the ID card number to ensure the confidentiality of personal identity information. For example, in some systems, the page information to be displayed contains identity information, and the desensitized ID card number needs to be displayed to unauthorized users. In specific implementation, the ID card in the display information is usually located first, the location of the ID card number is found, and then the ID card number is desensitized. In the prior art, the ID card number is usually matched and located by regular expression matching. For example, the method for identifying sensitive data in data preview and desensitizing it disclosed in the patent with application number: CN202410123109.8 matches and locates the ID card number based on regular expressions in the embodiment.

[0003] However, in actual applications, in some cases, the ID number will appear consecutively with other numbers or characters when input for some reason, such as: "Approve your application for changing the person in charge (No.: BH20100000190000001000101)" where "100000 19000000 1000" is the ID number, and the numbers before and after the ID number are generated based on the file naming rules. In such cases, only regular matching is used for positioning, which is very easy to locate errors and requires manual recheck by staff. Summary of the invention

[0004] In order to solve the problem in the prior art that positioning based on regular expression matching is prone to errors when the identity card number and other numbers and characters appear consecutively, the present invention provides an identity card number retrieval method, which can locate the identity number more accurately and avoid information leakage.

[0005] The technical solution of the present invention is as follows: a method for retrieving an identity card number, characterized in that it comprises the following steps: S1: Initialize the yearStart collection and indexList collection; S2: Place the first two digits of all years that may be included in the ID card into the yearStart set; S3: read the data to be processed; S4: confirm the length L of the data to be processed; If the data to be processed is empty or its length is less than the ID card number length, stop this operation; Otherwise, execute step S5; S5: Read the data stored in the yearStart set one by one, recorded as: yearStart to be retrieved; S6: Retrieve the yearStart to be retrieved in the data to be processed, and once retrieved, store the corresponding subscript number in the data to be processed into the indexList set; S7: looping steps S5 to S6 until all data stored in the yearStart set have participated in the calculation; S8: Read all subscript numbers stored in the indexList set, and delete the subscript numbers that do not satisfy the position relationship between the first two digits of the year in the ID card according to the relationship between the length L of the data to be processed and the subscript numbers; S9: If the indexList set is not empty, execute step S10; Otherwise, stop this operation; S10: According to the specific positions of the first two digits of the year in the ID card number, the length of the ID card number is corresponding to the length of the ID card number, and the lengths before and after the year are obtained, which are recorded as: the length before the year n and the length after the year m; S11: Read the subscript data index in the indexList set one by one; S12: Based on the subscript data index, obtain data from the data to be processed in the following manner: indexStart = index - n; indexEnd = index + m; Get the string including indexStart and indexEnd and the string between them that is the same length as the ID number, recorded as: ID card data to be verified; S13: Execute steps S11 to S12 in a loop until all data in the indexList set participate in the calculation; S14: Obtain the ID card data to be verified one by one, and confirm whether it is the ID card number based on the ID card verification method; If yes, proceed with the follow-up operation; If not, skip and proceed to the next loop.

[0006] It is further characterized by: In step S2, 19 and 20 are placed into the yearStart set; In step S4, the length of the ID card number is set to 18 digits; Step S8 specifically includes the following operations: a1: Confirm the sequential position of the first two digits of the year in the ID card, and obtain the length n before the year and the length m after the year; a2: Read the subscript index stored in the indexList collection one by one; If any of the following conditions is met, skip it and proceed to the next loop; index < n, or index > (L - m); In step S10, the length before the year is set to 6, and the length after the year is set to 12; In step S14, the ID card verification method is verified based on the regular expression method.

[0007] A method for retrieving an ID card number provided by the present invention is based on the digital part of the content that can be determined in the ID card, that is, the first two digits of the year data. A string of the same length as the ID card number is extracted from the initial dataset, and then the extracted string is verified through the existing ID number verification method to confirm whether it is a real ID number, avoiding the problem of inaccurate ID card verification results caused by the mixing of numbers and characters. The design idea of this method is simple and easy to implement, and is especially suitable for accurately locating the ID card number in a string mixed with characters and numerical values. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] Figure 1 It is a flowchart example for retrieving the ID card number in this method. DETAILED DESCRIPTION OF THE INVENTION

[0009] The present invention includes a method for retrieving an ID card number, which includes the following steps.

[0010] S1: Initialize the yearStart collection and the indexList collection.

[0011] S2: Place the first two digits of all possible years in the ID card into the yearStart collection.

[0012] Place 19 and 20 into the yearStart collection. In the future, if the year data in the ID number changes, it can also be added to the yearStart collection.

[0013] In this embodiment, the specific steps are implemented based on Java.

[0014] public static List <string>yearStart = Arrays.asList(new String[]{"19","20"}).

[0015] S3: Read the data to be processed.

[0016] Assume the initial data (data) to be processed is: "Agree to your kindergarten's application regarding the change of the person in charge (serial number: BH20100000190002001000101). The person in charge of Zhuoya Kindergarten in Tiandong County is changed from Zhang San (resident ID number: 100000190002001000) to Li Si (resident ID number: 420000200000006000)".

[0017] In the data to be processed between the double quotes, there are a total of 122 characters. The subscripts are: 0 to 121. The subscript serial number of the character "同" is 0, and the subscript serial number of the last character ")" is 121.

[0018] S4: Confirm the length L of the data to be processed; If the data to be processed is empty or the length is less than the length of the ID number, it means that the data to be processed cannot contain a complete ID number, and this operation is stopped; Otherwise, execute step S5.

[0019] In this embodiment, the length L of the data to be processed is 122 bits, and the current length of the ID number is 18 bits; then compare L with 18: L > 18.

[0020] S5: Read one by one the data stored in the yearStart set, denoted as: the yearStart to be retrieved.

[0021] S6: Search for the yearStart to be retrieved in the data to be processed. Once retrieved, store the corresponding subscript serial number in the indexList set. When specifically implemented, for the two-digit year number, only store the subscript serial number of the first digit in the indexlist set. For example: If the first occurrence position of the retrieved "19" in the data to be processed corresponds to the subscript serial number 30, then store 30 in the indexlist set.

[0022] S7: Loop steps S5 - S6 until all the data stored in the yearStart set has participated in the calculation.

[0023] After retrieving in the data to be processed in this embodiment, the subscripts corresponding to the positions when 19 appears are: 30, 76; the subscripts corresponding to 20 are 22, 35, 81, 104, 109. All the subscript numbers index: 30, 76, 22, 35, 81, 104, 109 are stored in the indexList set.

[0024] S8: Read all the subscript numbers index stored in the indexList set, and delete the subscript numbers that do not satisfy the positional relationship of the first two digits of the year in the ID card according to the relationship between the length L of the data to be processed and the subscript number.

[0025] Specifically, it includes the following operations: a1: Confirm the sequential position of the first two digits of the year in the ID card to obtain the length n before the year and the length m after the year; The length n before the year is set to 6, and the length m after the year is set to 12; a2: Read the subscript numbers index stored in the indexList set one by one; If any of the following conditions is satisfied, skip to the next loop; index < n, or index > (L - m).

[0026] For example, XXXXXX19XXXXXXXXXX, there should be only 6 digits in front of the year start and at least (2 + 10) 12 digits behind to meet the ID card number length.

[0027] Confirm the relationship between all index and n and m. In this embodiment, the judgment condition is: index < 6, or index > (122 - 12), that is, index > 110, Then all index in this embodiment need to participate in the calculation.

[0028] S9: If the indexList set is not empty, execute step S10; Otherwise, stop this operation.

[0029] S10: According to the specific position of the first two digits of the year in the ID card number and corresponding to the length of the ID card number, obtain the front and back lengths, which are respectively recorded as: the length n before the year and the length m after the year.

[0030] S11: Read the subscript data index in the indexList set one by one.

[0031] S12: Based on the subscript data index, obtain the data in the data to be processed in the following manner: indexStart = index - n; indexEnd = index + m; Get the string including indexStart and indexEnd and the character string between the two that is the same length as the identity number, and record it as: the identity card data to be verified.

[0032] For example, the first 19 retrieved in the data to be processed corresponds to the subscript index: 30.

[0033] Then, indexStart = 30 -6 =24; indexEnd = 30 + 12 = 42; The string between 24 and 42 in the data to be processed is: 100000190002001000. When implemented specifically: sfz = data.substring(24,42)="100000190002001000".

[0034] S13: Execute steps S11 to S12 in a loop until all data in the indexList collection participate in the calculation.

[0035] S14: Obtain the ID card data to be verified one by one, and confirm whether it is the ID card number based on the ID card verification method; If yes, then perform subsequent operations on the identified ID card number, such as desensitization operation; If not, skip and proceed to the next loop.

[0036] The specific ID card verification method and desensitization operation can be implemented based on any ID card verification method and desensitization algorithm in the prior art.

[0037] The ID card verification method of this embodiment is based on regular expression verification. For example: ‌'^[1-9]\d{5}(18|19|(\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$'.

[0038] The desensitization operation is: replaceSfz=sfz.substring(0,6)+"********"+sfz.substring(14,18); Then replace data=data.replace(sfz,replaceSfz) and continue the next loop; Replace "100000190002001000" with "100000********1000" to complete the desensitization operation.

[0039] After using the technical solution of the present invention, when the ID card number is mixed with numbers before and after it, the ID card number can be accurately matched in the character string. The method is simple and the execution efficiency is high.< / string>

Claims

1. A method for retrieving an identity card number, characterized in that: It includes the following steps: S1: Initialize the yearStart set and the indexList set; S2: Place the first two digits of all possible years in the ID card into the yearStart set; S3: Read the data to be processed; S4: Confirm the length L of the data to be processed; If the data to be processed is empty or the length is less than the length of the ID card number, stop this operation; Otherwise, execute step S5; S5: Read the data stored in the yearStart set one by one, denoted as: the yearStart to be retrieved; S6: Retrieve the yearStart to be retrieved in the data to be processed. Once retrieved, store the corresponding subscript number in the data to be processed into the indexList set; S7: Loop steps S5~S6 until all the data stored in the yearStart set has participated in the calculation; S8: Read all the subscript numbers stored in the indexList set. According to the relationship between the length L of the data to be processed and the subscript numbers, delete the subscript numbers that do not satisfy the position relationship of the first two digits of the year in the ID card; S9: If the indexList set is not empty, execute step S10; Otherwise, stop this operation; S10: According to the specific position of the first two digits of the year in the ID card number, corresponding to the length of the ID card number, obtain the front and back lengths, denoted as: the year front length n and the year back length m; S11: Read the subscript data index in the indexList set one by one; S12: Based on the subscript data index, obtain data in the data to be processed in the following way: indexStart = index - n; indexEnd = index + m; Obtain a string including indexStart and indexEnd and the string of the same length as the ID number between them, denoted as: the ID card data to be verified; S13: Loop and execute steps S11~S12 until all the data in the indexList set has participated in the calculation; S14: Obtain the ID card data to be verified one by one, and confirm whether it is an ID card number based on the ID card verification method; If it is, perform subsequent operations; If not, skip and proceed to the next loop.

2. A method for retrieving an identity card number according to claim 1, characterized in that: In step S2, place 19 and 20 into the yearStart set.

3. The ID card number retrieval method according to claim 1, characterized in that: In step S4, the length of the ID card number is set to 18 digits.

4. The ID card number retrieval method according to claim 1, characterized in that: In step S8, it specifically includes the following operations: a1: Confirm the sequential position of the first two digits of the year in the ID card to obtain the year front length n and the year back length m; a2: Read the subscript numbers index stored in the indexList set one by one; If any of the following conditions is satisfied, skip and proceed to the next loop; index < n, or index > (L - m).

5. The ID card number retrieval method according to claim 1, characterized in that: In step S10, the year front length is set to 6 and the year back length is set to 12.

6. The ID card number retrieval method according to claim 1, characterized in that: In step S14, the ID card verification method performs verification based on a regular expression.

Citation Information

Patent Citations

  • Method for identifying and desensitizing sensitive data in data preview

    CN118171311A