ID Number Verification System Based on Visual Structure

ID Number Verification System Based on Visual Structure

Abstract: This work is a universal ID number verification system. It has been tried to run on Linux and Windows systems, and the results are satisfactory.The system creates a highly compatible visual interface by using the base GUI library tkinter.Through data structure algorithm to analyze and calculate the ID number, the final output of identity information obtained by the ID number, and if the information is wrong, the system will prompt through the visual interface.At the same time, the system has many advantages, such as simple program, flexibility, high execution efficiency.
Keywords: Identity card verification; Visualization;

1. Description of the problem:

As a certificate of citizenship, second-generation identity cards have unique numbers, so it is important to verify the authenticity of identity cards according to their numbers.Verifying the authenticity of the ID card number should meet the following design requirements:
(1) Correctness of ID number length
(2) Legality of ID number
The verification system of the ID number to be designed can not only verify the correct length of the ID number, verify the validity of the ID number, but also identify the birth year, nationality, gender and other information.

2. System Design

2.1 Design Principles

According to the provisions of the national standard GB11643-1999 of the People's Republic of China on the citizenship number, the citizenship number is a feature combination code consisting of a 17-digit digital body code and a digital check code.The sequence from left to right is: six digit address code, eight digit date of birth code, three digit sequence code and one digit check code.Address code indicates the administrative zoning code of the county (city, flag, district) where the permanent residence of the coded object is located.The date of birth code represents the year, month and day of birth of the coded object. The year is represented by four digits, and there is no separator between the year, month and day.Sequence codes represent the serial numbers of persons born in the same year, month and day within the area identified by the same address code.The odd number of the sequence code is assigned to men and even number to women.The check code is a check code calculated from the first 17 digits according to the ISO 7064:1983.MOD 11-2 check code.The last checkcode is especially important.

Formula (1): denotes the position sequence of the number character from right to left, including the check code; denotes the number character value at the position; denotes the weighting factor at the position, whose value can be calculated from the formula.Number characters and their corresponding weighting factors are shown in the distribution in Table 1:

  • Table 1 Number characters and their corresponding weighting factors
i 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
W 7 9 10 5 8 4 2 1 6 3 7 9 10 5 4 3 2 1

Calculated according to formula (1), the ID number is correct as long as the final weighted sum is divided by 11 and the remainder can correspond to the table of Table 2 check codes query.

  • Table 2 Checkcode Query Table
0 1 2 3 4 5 6 7 8 9 10
1 0 x 9 8 7 6 5 4 3 2

Note: X means the result is 10.

2.2. Module Design

The design of the function module is shown in Figure 1, which mainly contains the visual interface module and the data processing module.The visualization interface module can also be divided into two major components: input prompt window and information display window.The data processing module consists of data reading, data splitting and algorithm processing.

Fig.1 System functional module diagram


The main program window records and displays the ID number entered by the user, and provides the user with operation keys and prompts.

The system reads the user's input ID number and processes it with the algorithm, then interactively displays it through the check result display window, through which you can clearly see if the ID number is qualified, and if it is qualified, you can get the correct identity information.

2.3. Data structure design

The system defines a list structure for the ID number entered by the user, and gets the ID number as follows:
** id_num = ['3','4','0','4','2','1','1'......] **
For the visual interface, the output data format is expressed in the form of characters. On the one hand, the characters are easy to stitch, and can be compatible with many symbols and languages.On the other hand, the visual interface display design in the form of characters can effectively prevent data from being distorted during transmission.
When reading and calculating the cadastral information, the cadastral table is stored in the form of a dictionary, and the program can get the corresponding cadastral information directly by searching the dictionary.The source dictionary is in the following form:
prov_list = {"11": "Beijing", "12": "Tianjin", "13": "Hebei", "14": "Shanxi", "15", "Inner Mongolia", "21", "Liaoning", "22", "Jilin", "23", "Heilongjiang", "31", "Shanghai", "32", "Jiangsu", "33", "Zhejiang", "34", "Anhui", "35", "Fujian".""36", "Jiangxi", "37", "Shandong", "41": "Henan", "42": "Hubei", "43": "Hunan", "44", "Guangdong", "45": "Guangxi", "46", "Hainan", "50", "Chongqing", "51", "Sichuan", "52", "Guizhou", "53", "Yunnan", "54", "Tibet", "61", "Shaanxi".""62", "Gansu", "63", "Qinghai", "64", "Ningxia", "65", "Xinjiang", "71", "Taiwan", "81", "Hong Kong", "82", "Macau", "91", "Foreign"}

2.4. Functional description

def exit_gui(): Exits a system function, which will exit the system.
def math(): Data processing function that analyzes the input ID number and outputs the corresponding identity data.
def id_check_ui (birth_num, add, sex, check): Visualizes interface functions that display the analyzed identity information.
def: get_id_born_year(id_birth): Get the date of birth and return by entering part of your ID number.
def get_id_pro(id_add): Get the origin information and return it by entering part of the ID number.
def get_id_sex(id_sex): Get the gender information and return it by entering part of the ID number.
def get_id_ecc(id_num): Calculates the check bit information and returns it by entering part of the ID number.
myWindow.mainloop() enters the window loop (program entry)

3. Detailed Design (Program Source)

"""
//Program description: Read the ID number entered by the user, and determine whether the number is legal. If it is legal, display the identity information, and if it is not, remind the user.
Author:       Zhang Haitao
Specification:  follow PEP-257 rule
Modify:       2019-09-16
"""
# -*- coding: utf-8 -*-
# Import GUI Programming Base Library-tkinter
import tkinter as tk
# Get the absolute path root_path of the function file and import it.
import os
current_path = os.path.abspath(__file__)
root_path = os.path.abspath(os.path.dirname(current_path) + os.path.sep + ".")  
import sys
sys.path.append(root_path)
# Import algorithm file
import function.mathfunction as mathfunction

# Create a main program window
myWindow = tk.Tk()
# Set the title of the window
myWindow.title('Identity card verification')
# Set window size
myWindow.geometry('300x300')

# Import Tip Label
input_lab = tk.Label(myWindow, text="Please enter your ID number :")
# Determine Tip Label Position and Size
input_lab.place(x=50, y=10, width=150, height=50)

"""
//Function description: Display identity information visually on the screen
Parameters: birth_num - Date of birth,
            add - Origin Information
            sex - Gender Information
            check - Check Bit Information
Returns:    nothing
Modify:     2019-09-16
"""
def id_check_ui(birth_num, add, sex, check):
    # Create an Information Display Window
    view = tk.Tk()
    # Set the title of the window
    view.title('Identity Card Information Display Window')
    # Set window size
    view.geometry('300x300')
    # Import Age Tag Box
    birth_num_lab = tk.Label(view, text="Date of birth:")
    # Determine age label position and size
    birth_num_lab.place(x=10, y=20, width=60, height=30)
    # Print the age information extracted from the ID number into the text box
    birth_num_txt = tk.Text(view)
    birth_num_txt.place(x=80, y=25, width=200, height=20)
    birth_num_txt.insert('insert', birth_num)

    # Import Nationality Label Box
    add_lab = tk.Label(view, text="Origin:")
    # Determine Origin Label Location and Size
    add_lab.place(x=10, y=60, width=60, height=30)
    # Import Nationality Text Box
    add_txt = tk.Text(view)
    # Import Nationality Text Box Location and Size
    add_txt.place(x=80, y=65, width=200, height=20)
    # Import data from the origin text box
    add_txt.insert('insert', add)

    # Import Gender Tag Box
    sex_lab = tk.Label(view, text="Gender:")
    # Determine gender label position and size
    sex_lab.place(x=10, y=100, width=60, height=30)
    sex_txt = tk.Text(view)
    sex_txt.place(x=80, y=105, width=200, height=20)
    sex_txt.insert('insert', sex)

    # Import Check Results Label Box
    sex_lab = tk.Label(view, text="Check results:")
    # Determine label position and size for check results
    sex_lab.place(x=10, y=140, width=60, height=30)
    sex_txt = tk.Text(view)
    sex_txt.place(x=80, y=145, width=200, height=20)
    sex_txt.insert('insert', check)

def math():
    # Add a prompt label to the main program window
    prompt_lab1 = tk.Label(myWindow, text="Verifying :")
    prompt_lab1 .place(x=50, y=200, width=150, height=50)

    # Get Input ID Number
    id_num = Input_num.get()
    print(id_num)
    if len(id_num) != 18:
        prompt_lab1 = tk.Label(myWindow, text="The number you entered is incorrectly long :", fg='red')
        prompt_lab1 .place(x=50, y=200, width=150, height=50)
        return 0

    # Split the obtained ID number for easy post-operation
    id_add = id_num[0:6]
    id_birth = id_num[6:14]
    id_sex = id_num[14:17]
    id_check = id_num[17]

    # Calculate the date of birth in the ID number
    birth_num = mathfunction.get_id_born_year(id_birth)
    print(birth_num)

    # Calculate Origin Information for ID Number
    add = mathfunction.get_id_pro(id_add)
    print(add)

    # Calculate gender information for ID number
    sex = mathfunction.get_id_sex(id_sex)
    print(sex)

    # Check Bit Information for Calculating ID Number Check Mathematical Terms (ECC)
    check_num = mathfunction.get_id_ecc(id_num)
    print(check_num)
    if id_check == check_num:
        check = 'Verification successful'
    else:
        check = 'Check failed'
    print(check)

    # Call UI display function to display identity information
id_check_ui(birth_num, add, sex, check)

"""
//Function description: Exit the system
Parameters:   nothing
Returns:      nothing
Modify:     2019-09-16
"""
def exit_gui():
    sys.exit()

# Import key 1, the hit_me function will be called when key 1 is pressed
Button1 = tk.Button(myWindow, text="check", bg='yellow', command=math)
# Determine key 1 position and size
Button1.place(x=50, y=120, width=60, height=50)
# Import key 2, which will call exit_gui function when key 2 is pressed
Button2 = tk.Button(myWindow, text="Sign out", command=exit_gui)
# Determine key 2 position and size
Button2.place(x=160, y=120, width=60, height=50)
# Place Input Module
Input_num = tk.Entry(myWindow, show=None)  # Enter all normal display
Input_num.place(x=30, y=70, width=200, height=30)

# Start Window Loop
myWindow.mainloop()

Reference

[1] Zeng Hao. Interface program development and application technology [J]. Science and Education, 2010 (10): 87-89.
[2] Qiu Daoyin. Identification algorithm of ID number based on MATLAB [N]. Journal of North China University of Water Resources and Hydropower, April 2012-2(2).
[3] Qi Peng. Web Data Acquisition Technology Based [J/OL]. Electronic Technology, November 2012-05.
[4] Wei Rui. The algorithm of 15 digits up to 18 digits in ID card with C++Builder [J]. Tianzhong Journal, 2007 (10): 54-55.
[5] Li Wenhong. Error correction method of ID number based on redundant bit check and information comparison [J]. Journal of People's Public Security University of China, 2012 (2): 87-90.
[6] Exercise application. Design method of using Excel authentication ID number check code [J]. Joint Journal of Tianjin Joint Vocational College, 2014 (2): 65-67.
[7] Long Xiangming. Use custom function to check and obtain identity card data [J]. Computer programming skills and maintenance, 2014 (5): 106-107.
[8] Zhu Jian. Implementation of mobile ID number recognition algorithm [J]. Software Guide, 2019 (7): 71-73.

11 original articles published, 3 praised, 318 visits
Private letter follow

Keywords: Programming Linux Windows MATLAB

Added by vbzoom.com on Sun, 23 Feb 2020 04:58:02 +0200