Start working.
First, let's take a look at the pictures posted in Li Dawei's Moments.
The personal information exposed in the ticket is:
3302211993****4914 Li Dawei
Only the four digits of the month and date are missing.
So, there are a total of 365 possibilities.
Science Popularization Time:#
Based on the first 6 digits of Li Dawei's ID card information "330221"
We can easily obtain:
He is from Ningbo, Zhejiang Province, born in 1993.
Let's use Python to generate all the dates in 1993.
import time
# Generate all the dates in the year of birth
def dateRange(year):
fmt = '%Y-%m-%d'
bgn = int(time.mktime(time.strptime(year+'-01-01',fmt)))
end = int(time.mktime(time.strptime(year+'-12-31',fmt)))
list_date = [time.strftime(fmt,time.localtime(i)) for i in range(bgn,end+1,3600*24)]
return [i.replace('-','') for i in list_date]
data_time = dateRange('1993')
Successfully obtained the list of dates.
Let's use the verification code calculation rule we just obtained to check which date is correct! Write the calculation rule ourselves? Too troublesome!
Let me introduce you to a library: id-validator
Installation: pip install id-validator
It can be used to verify the validity of ID card numbers, obtain ID card information, generate fake data that can pass verification, and upgrade ID cards.
Then we use id-validator to verify the ID card numbers generated just now. The complete code is as follows:
from id_validator import validator
import time
# Generate all the dates in the year of birth
def dateRange(year):
fmt = '%Y-%m-%d'
bgn = int(time.mktime(time.strptime(year+'-01-01', fmt)))
end = int(time.mktime(time.strptime(year+'-12-31', fmt)))
list_date = [time.strftime(fmt, time.localtime(i))for i in range(bgn, end+1, 3600*24)]
return [i.replace('-', '') for i in list_date]
# Traverse all dates and print the ID card numbers that pass the verification
def vali_dator(id1, id2, id3):
for i in dateRange(id2):
theid = id1 + i + id3
if validator.is_valid(theid):
print(theid)
vali_dator('330221','1993','4914')
Result:
How to pick out Li Dawei's real date of birth from the 33 dates?
Next, we need to filter the final result based on whether the ID card number and name match. The previous solution was to query on 12306, add a contact on 12306, and if the ID card and name match, it will show that the verification is passed. If it cannot pass, it means that the ID card and name do not match. But now this method cannot be used anymore.
Then I found Alibaba Cloud's real-name authentication interface, which checks whether the ID card name and ID card number match the identity information. However, only enterprise users can use it, and individuals cannot, so I won't try it.
Summary#
This is roughly the process of calculating the ID card number using Python. Of course, many people will publicly disclose their birth month and date on QQ or other social software, so you can easily find it.