banner
andrewji8

Being towards death

Heed not to the tree-rustling and leaf-lashing rain, Why not stroll along, whistle and sing under its rein. Lighter and better suited than horses are straw sandals and a bamboo staff, Who's afraid? A palm-leaf plaited cape provides enough to misty weather in life sustain. A thorny spring breeze sobers up the spirit, I feel a slight chill, The setting sun over the mountain offers greetings still. Looking back over the bleak passage survived, The return in time Shall not be affected by windswept rain or shine.
telegram
twitter
github

Using Python, it is possible to calculate the ID card number.

Start working.
First, let's take a look at the pictures posted in Li Dawei's Moments.

image
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:#

image
Based on the first 6 digits of Li Dawei's ID card information "330221"

We can easily obtain:

image
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.

image

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.

image
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:

image

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.

image

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.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.