Problem description

As a citizen, everyone has a unique ID card with a unique ID number. It stores almost all of our movements and information, so there are a lot of criminals who can carry out some crimes just by using their ID numbers. However, in life, it is very easy to reveal such information, such as tickets and so on. Although the four digits are covered, is it really safe?

The solution

Through a simple query, we are not difficult to know, in fact, although the ID number is unique, but the law of its generation is fixed, only through the formula can determine whether an ID number is correct, conversely, can also be determined by a correct but incomplete ID number to reverse the complete information.

As we all know, the most important part of the IDENTITY card is the last digit verification code, which is actually very simple to calculate:

Each of the first 17 digits corresponds to a coefficient of 7.9 10.5 8.4.2. The remainder of each digit multiplied by the coefficient must be within 0-10. And then the 11 numbers, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. The last id card number corresponding to it is 1.0. X. 9. 8.

Although we know that even if the hard calculation, only 366 attempts to get the result, but learning the language is to simplify, so the author wrote a paragraph to determine whether the ID card is correct and roughly calculate the ID number of the code, readers can try their own.

Check whether the id number is real

def ID_Card_judgment(ID_num):

List1 =,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 [7]

sums = 0

for i in range(len(list1)):

new_num = int(ID_num[i]) * list1[i]

sums += new_num

Check_code = (1, 0, “X”, 9,8,7,6,5,4,3,2]

num = sums % 11

if str(check_code[num]) == ID_num[-1]:

return “True”

else:

return “False”

Roughly infer the complete ID card number:

def ID_Card_calculation(ID_num):

if ID_num[-1] == “X”:

new_ID_num = ID_num[:-1]+”10″

else:

new_ID_num = ID_num

a = new_ID_num.split(“*”)

new_ID_card = “”.join(a)

,9,10,5,8,4,2,1,6,3,8,4,2 front_code = [7] # except birthday four digits the number of other parameters

sums = 0

for i in range(len(front_code)): #len(new_ID_card) = 18-4-1 =13

nums = int(new_ID_card[i]) * front_code[i]

sums += nums

Sum of the products of all numbers and corresponding parameters except the four digits

#7,9,10,5 birthdays four-digit parameter

Duiying =,0,10,9,8,7,6,5,4,3,2 [1]

times = 0

For a in range (0, 2) :

A for b in the range (0, 10) :

For c in range (0, 4) :

For d in range (0, 10) :

if (sums + (a*7 + b*9 + c*10 + d*5)) % 11 == duiying[int(new_ID_num[17:])]:

string = str(a)+str(b)+str(c)+str(d)

if 0 < int(string[0:2]) <= 12 and 0 < int(string[2:4]) <= 31:

times += 1

ID_Card_num = ID_num[0:10] + string + ID_num[14:18]

print(ID_Card_num)

Print (” %d “) %times)

The code asks for a string of numbers with a birthday of ****, which also conforms to the common rule of hiding an ID number. Although it can not be accurately inferred, but the results of only 20 or 30, through the existing network of some platforms, plus the name and constellation and other information, it is easy to get your information.

conclusion

There is too much personal information stored on the ID card, everyone must keep it safe. Discarded tickets and other numbers that seem to hide information that can protect us could be the ultimate culprits. While the rest may not be hidden by the four digits, it can be found by the rules. So the author reminds everyone, must make his id number Mosaic on the network, do not give lawless elements can take advantage of.