Add Fingerprint Scan-based Security to Your .NET Applications Today

Add Fingerprint Scan-based Security to Your .NET Applications Today

iometric recognition is one of the most reliable ways to confirm the identity of an individual. And by now, many people are undoubtedly familiar with the Microsoft Fingerprint Reader (see Figure 1).

Besides logging into a computer using a fingerprint scan from the reader, you can also use the application provided by the Fingerprint Reader to save your user IDs and passwords for web sites that require them. You can then use your fingerprint as a key to retrieve the authentication information to log in securely, thereby eliminating the hassle of remembering different sets of passwords for different sites.

Unfortunately, that’s all you can do with the Fingerprint Reader. Microsoft does not provide an SDK to allow developers to incorporate the Fingerprint Reader into their applications. For this, you have to reply on third-party solution providers. Fortunately, there is one such provider available in the market: (Griaule provides the GrFinger Suite, a fingerprint recognition suite that comes with an SDK for integrating your fingerprint readers into your applications. (It works with Microsoft Fingerprint Reader, Digital Persona U.are.U 4000, SecuGen Hamster FDU02, Geomok (Testech) Bio-I, and Crossmatch USB Fingerprint Readers.).

In this article, I will show you how you can use the GrFinger SDK to integrate the Microsoft Fingerprint Reader into your .NET applications. In particular, you will build a Visitor Identification System whereby users visiting your office can register with their fingerprints at the reception desk (see Figure 2). Once a user is registered, the next time he visits the office he can simply scan his fingerprint and the system will register his visit. This application can also be adapted by schools for attendance taking purposes, such as in big lecture theaters where attendance must be taken rapidly and efficiently.


Figure 1. The Microsoft Fingerprint Reader in action.
 
Figure 2. The screen shot shows the completed Visitor Identification System application you will build in this article.

Obtaining the GrFinger SDK
There are three editons of the GrFinger SDK: FREE, LIGHT, and FULL. From Griuale’s web site:

“The FREE Edition can be used for any non-commercial purposes and evaluation. Support is provided in forum.griaule.com. LIGHT Edition is intended for companies that would like to deploy GrFinger in many computers but does not need all of its speed. FULL edition unleashes all the GrFinger speed and allows you to access the fingerprint images and also features e-mail support.”

In addition, images captured by the FREE and LIGHT editions are encrypted, and for the FREE version, there is an advertisement banner displayed on the captured image. Consult Griaule’s website for full pricing information for each edition. For this article, I have used the FULL edition (special thanks to Griaule for kindly granting me the license).

To obtain the GrFinger SDK, visit: http://griaule.com/page/en-us/downloads.

Creating the Application
Once the GrFinger SDK is installed, you are ready to create the application. For this article, I used Visual Studio .NET 2003. Create a new Windows application and name it C:Fingerprintreader.

First, you need to add the GrFingerxCtrl (an ActiveX control representing the GrFinger component) into your Toolbox. Right-click on Toolbox and select Add/Remove Items…. Check the GrFingerXCtrl Class (see Figure 3) and click OK.

The GrFingerXCtrl control will now appear in the ToolBox (see Figure 4).


Figure 3. Add the GrFingerXCtrl class into the ToolBox in Visual Studio.
 
Figure 4. Check the ToolBox to make sure the GrFingerXCtrl ActiveX control has been added successfully.

In the default Form1, populate it with the following controls (see also Figure 5):

  • PictureBox
  • Label
  • TextBox
  • ListBox
  • GroupBox
  • Button
  • AxGrFingerXCtrl
Figure 5. Populate the default Form1 with all the controls shown in the screen shot.

In addition, add a Timer control to the project. The Timer control will be used to clear away the user’s information after his identity has been loaded from the database (after five seconds).

Also, add an ImageList control and add an image to it (via the Images property). This image is the one shown in the PictureBox control as shown in Figure 5.

Author’s Note: I suggest you download the source code for this project in order to obtain the detailed settings for each control.

Coding the Application
The GrFinger SDK comes with a sample application written in different languages: VB6, Java, C++, VB.NET, etc. For the VB.NET version of this sample, there are two useful libraries that Griaule has provided: DBClass.vb and Util.vb. The DBClass.vb contains routines to add/retrieve users’ information to/from a database. The Util.vb contains all the necessary routines to use the GrFingerXCtrl control and other supporting Win32 APIs. Rather than reinvent the wheel, I have decided to make use of them in my application. Hence, I will add the DBClass.vb and Util.vb files into my project (see Figure 6). Right-click on Solution Explorer and then select Add?>Existing Item…. Listings 1 and 2 show the full source of Util.vb and DBClass.vb. I will also modify the sample application provided by Griaule to suit the purpose of my application.


Figure 6. Add the two useful libraries provided by Griaule, Util.vb and DBClass.vb, to your solution.
 
Figure 7. Add five new fields to the enroll table to associate the data the sample application needs.

To keep the code in the DBClass.vb intact, I will use the sample Access database provided by Griaule. The original Access database is named GrFingerSample.mdb and contains one single table called enroll. The original enroll table contains only two fields: ID and template (for storing the fingerprint image). For this application, I will add five more fields to the enroll table. They are: SSN, Name, Company, ContactNumber, and Email (see Figure 7).

Save the database GrFingerSample.mdb in C:Fingerprintreaderin.

Let’s now switch to the code-behind of Form1 and write the code to wire up all the controls.

First, import the GrFingerXLib namespace:

Imports GrFingerXLib

Declare the following constants and member variables:

    '---name of the database---    Const DBFile = "GrFingerSample.mdb"    Const ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="    '---for an instance of the Util.vb class---    Private myUtil As Util    '---for storing user's ID---    Private _UserID As Integer    '---database connection string---    Private connection As System.Data.OleDb.OleDbConnection

In the Form1_Load event, code the following:

    Private Sub Form1_Load( _       ByVal sender As System.Object, _       ByVal e As System.EventArgs) _       Handles MyBase.Load        Dim err As Integer        ' initialize util class        myUtil = New Util(ListBox1, PictureBox1, AxGrFingerXCtrl1)        ' Initialize GrFingerX Library        err = myUtil.InitializeGrFinger()        ' Print result in log        If err < 0 Then            myUtil.WriteError(err)            Exit Sub        Else            myUtil.WriteLog( _               "**GrFingerX Initialized Successfull**")        End If        '---create a log file---        If Not System.IO.File.Exists(Logfile) Then            System.IO.File.Create(Logfile)        End If    End Sub

Here, you create an instance of the Util class. The constructor of the Util class takes in three arguments: the ListBox control to display the status of the GrFingerXCtrl control, a PictureBox control to display the captured fingerprint image, and finally the GrFingerXCtrl control itself. You then initialize the GrFingerX library and create a log file (if it is not already present). This log file is a comma-separated value (CSV) file that contains users' IDs and login times.

Next, service all the necessary events of the GrFingerXCtrl control:

    ' -----------------------------------------------------------------------------------    ' GrFingerX events    ' -----------------------------------------------------------------------------------    ' A fingerprint reader was plugged on system    Private Sub AxGrFingerXCtrl1_SensorPlug( _       ByVal sender As System.Object, _       ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_SensorPlugEvent) _       Handles AxGrFingerXCtrl1.SensorPlug        myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Plugged.")        AxGrFingerXCtrl1.CapStartCapture(e.idSensor)    End Sub    ' A fingerprint reader was unplugged from system    Private Sub AxGrFingerXCtrl1_SensorUnplug( _       ByVal sender As System.Object, _       ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_SensorUnplugEvent) _       Handles AxGrFingerXCtrl1.SensorUnplug        myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Unplugged.")        AxGrFingerXCtrl1.CapStopCapture(e.idSensor)    End Sub    ' A finger was placed on reader    Private Sub AxGrFingerXCtrl1_FingerDown( _       ByVal sender As System.Object, _       ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_FingerDownEvent) _       Handles AxGrFingerXCtrl1.FingerDown        myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Finger Placed.")    End Sub    ' A finger was removed from reader    Private Sub AxGrFingerXCtrl1_FingerUp( _       ByVal sender As System.Object, _       ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_FingerUpEvent) _       Handles AxGrFingerXCtrl1.FingerUp        myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Finger removed.")    End Sub

These events are raised when:

  • A fingerprint reader is plugged or unplugged from the computer
  • A finger is placed or removed from the fingerprint reader

Also, you need to service the ImageAcquired event of the GrFingerXCtrl control. This event is fired whenever a fingerprint image is acquired. Once the image is acquired, you call the ExtractTemplate() function (explained in the subsequent paragraphs) and then the IdentifyFingerprint() subroutine to identify the user's fingerprint:

    ' An image was acquired from reader    Private Sub AxGrFingerXCtrl1_ImageAcquired( _       ByVal sender As System.Object, _       ByVal e As AxGrFingerXLib._IGrFingerXCtrlEvents_ImageAcquiredEvent) _       Handles AxGrFingerXCtrl1.ImageAcquired        ' Copying aquired image        myUtil.raw.height = e.height        myUtil.raw.width = e.width        myUtil.raw.res = e.res        myUtil.raw.img = e.rawImage        ' Signaling that an Image Event occurred.        myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Image captured.")        ' display fingerprint image        myUtil.PrintBiometricDisplay(False, GRConstants.GR_DEFAULT_CONTEXT)        '---extract the template from the fingerprint scanned---        ExtractTemplate()        '---identify who the user is---        _UserID = IdentifyFingerprint()        If _UserID > 0 Then            '---user found---            Beep()            btnRegister.Enabled = False            '---display user's information---            GetUserInfo()            '---writes to log file---            WriteToLog(_UserID)        Else            '---user not found---            ClearDisplay()            btnRegister.Enabled = True            Beep()            lblMessage.Text = "User not found! Please register your information below"        End If    End Sub

Once the user's identity is found, you will display the user's particulars by calling the GetUserInfo() subroutine. You will also write an entry to the log file by calling the WriteToLog() subroutine.

Once a fingerprint image is captured, you need to extract some characteristic points from the image; these are called minutiae. One regular fingerprint has approximately 50 minutiae. To identify a user, you need about 13 of them. When all the minutiae are extracted, they are put together into a structure called a Template, which is the joining of all the extracted minutiae in a fingerprint. According to Griaule, the identification is made by a triangulation process and geometrical relation between the minutiae only, not the entire image. This process is accomplished by the ExtractTemplate() function:

    ' Extract a template from a fingerprint image    Private Function ExtractTemplate() As Integer        Dim ret As Integer        ' extract template        ret = myUtil.ExtractTemplate()        ' write template quality to log        If ret = GRConstants.GR_BAD_QUALITY Then            myUtil.WriteLog("Template extracted successfully. Bad quality.")        ElseIf ret = GRConstants.GR_MEDIUM_QUALITY Then            myUtil.WriteLog("Template extracted successfully. Medium quality.")        ElseIf ret = GRConstants.GR_HIGH_QUALITY Then            myUtil.WriteLog("Template extracted successfully. High quality.")        End If        If ret >= 0 Then            ' if no error, display minutiae/segments/directions into the image            myUtil.PrintBiometricDisplay(True, GRConstants.GR_NO_CONTEXT)        Else            ' write error to log            myUtil.WriteError(ret)        End If        Return ret    End Function

The IdentifyFingerprint() function locates the identity of the user by calling the Identify() method located in the Util.vb class. It returns the ID of the identified user:

    '---Identify a fingerprint; returns the ID of the user---    Private Function IdentifyFingerprint() As Integer        Dim ret As Integer, score As Integer        score = 0        ' identify it        ret = myUtil.Identify(score)        ' write result to log        If ret > 0 Then            myUtil.WriteLog("Fingerprint identified. ID = " & ret & ". Score = " & score & ".")            myUtil.PrintBiometricDisplay(True, GRConstants.GR_DEFAULT_CONTEXT)        ElseIf ret = 0 Then            myUtil.WriteLog("Fingerprint not Found.")        Else            myUtil.WriteError(ret)        End If        Return ret    End Function

The GetUserInfo() subroutine retrieves the user's particulars using the value of the _UserID variable:

    '---get user's information---    Public Sub GetUserInfo()        Dim filePath As String        Try            filePath = Application.StartupPath() & "" & DBFile            connection = New OleDb.OleDbConnection(ConnectionString & filePath)            connection.Open()            Dim reader As OleDb.OleDbDataReader            Dim command As OleDb.OleDbCommand = New OleDb.OleDbCommand            command.Connection = connection            '---retrieve user's particulars---            command.CommandText = "SELECT * FROM Enroll WHERE ID=" & _UserID            reader = command.ExecuteReader(CommandBehavior.CloseConnection)            reader.Read()            '---display user's particulars---            lblMessage.Text = "Welcome, " & reader("name")            txtSSN.Text = reader("SSN")            txtName.Text = reader("Name")            txtCompany.Text = reader("Company")            txtContactNumber.Text = reader("ContactNumber")            txtEmail.Text = reader("Email")            '---reset the timer to another 5 seconds---            Timer1.Enabled = False            Timer1.Enabled = True        Catch ex As Exception            MsgBox(ex.ToString)        End Try    End Sub

When a new user scans his fingerprint for the first time, naturally, thefingerprint is not recognized. The user can then register the fingerprint by filling his identifying data, in this case the SSN, name, company name, contact number, and email address. This is accomplished using the Register button, which first adds the fingerprint to the database (via the EnrollFingerprint() function) and then adds the particulars of the user using the AddNewUser() subroutine:

    '---Register button---    Private Sub btnRegister_Click( _       ByVal sender As System.Object, _       ByVal e As System.EventArgs) _       Handles btnRegister.Click        '---first add the fingerprint---        _UserID = EnrollFingerprint()        '---then add the particulars---        AddNewUser()        '---clears the display---        ClearDisplay()        '---writes to log file---        WriteToLog(_UserID)    End Sub

The EnrollFingerprint() function enrolls a fingerprint into the database using the Enroll() method defined in the Util.vb class:

    '---adds a fingerprint to the database; returns the ID of the user---    Private Function EnrollFingerprint() As Integer        Dim id As Integer        ' add fingerprint        id = myUtil.Enroll()        ' write result to log        If id >= 0 Then            myUtil.WriteLog("Fingerprint enrolled with id = " & id)        Else            myUtil.WriteLog("Error: Fingerprint not enrolled")        End If        Return id    End Function

The AddNewUser() subroutine saves the user's particulars into the database:

    '---Add a new user's information to the database---    Public Sub AddNewUser()        Dim filePath As String        Try            filePath = Application.StartupPath() & "" & DBFile            connection = New OleDb.OleDbConnection(ConnectionString & filePath)            connection.Open()            Dim command As OleDb.OleDbCommand = New OleDb.OleDbCommand            command.Connection = connection            '---set the user's particulars in the table---            Dim sql As String = "UPDATE enroll SET SSN='" & txtSSN.Text & "', " & _               "Name='" & txtName.Text & "', " & _               "Company='" & txtCompany.Text & "', " & _               "ContactNumber='" & txtContactNumber.Text & "', " & _               "Email='" & txtEmail.Text & "' " & _               " WHERE ID=" & _UserID            command.CommandText = sql            command.ExecuteNonQuery()            MsgBox("User added successfully!")            connection.Close()        Catch ex As Exception            MsgBox(ex.ToString)        End Try    End Sub

The ClearDisplay() subroutine clears away the information displayed in the various TextBox controls:

    '---Clears the user's particulars---    Public Sub ClearDisplay()        lblMessage.Text = _           "Please place your index finger on the fingerprint reader"        PictureBox1.Image = ImageList1.Images(0)        txtSSN.Text = String.Empty        txtName.Text = String.Empty        txtCompany.Text = String.Empty        txtContactNumber.Text = String.Empty        txtEmail.Text = String.Empty    End Sub

When the Timer1_Tick event is fired (every 5 seconds), call the ClearDisplay() subroutine to clear the display:

    '---the Timer control---    Private Sub Timer1_Tick( _       ByVal sender As System.Object, _       ByVal e As System.EventArgs) _       Handles Timer1.Tick        ClearDisplay()        Timer1.Enabled = False    End Sub

The WriteToLog() subroutine writes to the log file an entry containing user's ID and the current time:

    Public Sub WriteToLog(ByVal ID As String)        '---write to a log file---        Dim sw As New System.IO.StreamWriter( _           Logfile, True, System.Text.Encoding.ASCII)        sw.WriteLine(id & "," & Now.ToString)        sw.Close()    End Sub

Testing the Application
You are now ready to test the application. Press F5 in Visual Studio .NET 2003 and you will see the application as shown in Figure 8.

Place your index finger on the fingerprint reader and you should be prompted to register with your particulars (personal data). Once registered, your particulars will be cleared after five seconds. Once that's completed, you can try placing the same finger to check if you can be identified correctly. If so, you will see your information displayed as in Figure 9.


Figure 8. Testing the Application: This is the first screen you will see upon launching the application. It prompts the user for his or her fingerprint scan.
 
Figure 9. The application displays the information of an identified user.

Note that there will be times where your fingerprint may not be correctly identified. This is likely due to incorrect positioning of your finger. Try again and it should be identified correctly.

Applications for Biometrics Abound
In this article, you have seen how you can integrate the fingerprint reader into your .NET application. While the example shown in this article is very simple, you can easily extend it to more complex scenarios, such as video rental applications, payment services, etc. If you have not started evaluating biometric authentication for your projects, this is a very good time to start.

devx-admin

devx-admin

Share the Post:
USA Companies

Top Software Development Companies in USA

Navigating the tech landscape to find the right partner is crucial yet challenging. This article offers a comparative glimpse into the top software development companies

Software Development

Top Software Development Companies

Looking for the best in software development? Our list of Top Software Development Companies is your gateway to finding the right tech partner. Dive in

India Web Development

Top Web Development Companies in India

In the digital race, the right web development partner is your winning edge. Dive into our curated list of top web development companies in India,

USA Web Development

Top Web Development Companies in USA

Looking for the best web development companies in the USA? We’ve got you covered! Check out our top 10 picks to find the right partner

Clean Energy Adoption

Inside Michigan’s Clean Energy Revolution

Democratic state legislators in Michigan continue to discuss and debate clean energy legislation in the hopes of establishing a comprehensive clean energy strategy for the

Chips Act Revolution

European Chips Act: What is it?

In response to the intensifying worldwide technology competition, Europe has unveiled the long-awaited European Chips Act. This daring legislative proposal aims to fortify Europe’s semiconductor

USA Companies

Top Software Development Companies in USA

Navigating the tech landscape to find the right partner is crucial yet challenging. This article offers a comparative glimpse into the top software development companies in the USA. Through a

Software Development

Top Software Development Companies

Looking for the best in software development? Our list of Top Software Development Companies is your gateway to finding the right tech partner. Dive in and explore the leaders in

India Web Development

Top Web Development Companies in India

In the digital race, the right web development partner is your winning edge. Dive into our curated list of top web development companies in India, and kickstart your journey to

USA Web Development

Top Web Development Companies in USA

Looking for the best web development companies in the USA? We’ve got you covered! Check out our top 10 picks to find the right partner for your online project. Your

Clean Energy Adoption

Inside Michigan’s Clean Energy Revolution

Democratic state legislators in Michigan continue to discuss and debate clean energy legislation in the hopes of establishing a comprehensive clean energy strategy for the state. A Senate committee meeting

Chips Act Revolution

European Chips Act: What is it?

In response to the intensifying worldwide technology competition, Europe has unveiled the long-awaited European Chips Act. This daring legislative proposal aims to fortify Europe’s semiconductor supply chain and enhance its

Revolutionized Low-Code

You Should Use Low-Code Platforms for Apps

As the demand for rapid software development increases, low-code platforms have emerged as a popular choice among developers for their ability to build applications with minimal coding. These platforms not

Cybersecurity Strategy

Five Powerful Strategies to Bolster Your Cybersecurity

In today’s increasingly digital landscape, businesses of all sizes must prioritize cyber security measures to defend against potential dangers. Cyber security professionals suggest five simple technological strategies to help companies

Global Layoffs

Tech Layoffs Are Getting Worse Globally

Since the start of 2023, the global technology sector has experienced a significant rise in layoffs, with over 236,000 workers being let go by 1,019 tech firms, as per data

Huawei Electric Dazzle

Huawei Dazzles with Electric Vehicles and Wireless Earbuds

During a prominent unveiling event, Huawei, the Chinese telecommunications powerhouse, kept quiet about its enigmatic new 5G phone and alleged cutting-edge chip development. Instead, Huawei astounded the audience by presenting

Cybersecurity Banking Revolution

Digital Banking Needs Cybersecurity

The banking, financial, and insurance (BFSI) sectors are pioneers in digital transformation, using web applications and application programming interfaces (APIs) to provide seamless services to customers around the world. Rising

FinTech Leadership

Terry Clune’s Fintech Empire

Over the past 30 years, Terry Clune has built a remarkable business empire, with CluneTech at the helm. The CEO and Founder has successfully created eight fintech firms, attracting renowned

The Role Of AI Within A Web Design Agency?

In the digital age, the role of Artificial Intelligence (AI) in web design is rapidly evolving, transitioning from a futuristic concept to practical tools used in design, coding, content writing

Generative AI Revolution

Is Generative AI the Next Internet?

The increasing demand for Generative AI models has led to a surge in its adoption across diverse sectors, with healthcare, automotive, and financial services being among the top beneficiaries. These

Microsoft Laptop

The New Surface Laptop Studio 2 Is Nuts

The Surface Laptop Studio 2 is a dynamic and robust all-in-one laptop designed for creators and professionals alike. It features a 14.4″ touchscreen and a cutting-edge design that is over

5G Innovations

GPU-Accelerated 5G in Japan

NTT DOCOMO, a global telecommunications giant, is set to break new ground in the industry as it prepares to launch a GPU-accelerated 5G network in Japan. This innovative approach will

AI Ethics

AI Journalism: Balancing Integrity and Innovation

An op-ed, produced using Microsoft’s Bing Chat AI software, recently appeared in the St. Louis Post-Dispatch, discussing the potential concerns surrounding the employment of artificial intelligence (AI) in journalism. These

Savings Extravaganza

Big Deal Days Extravaganza

The highly awaited Big Deal Days event for October 2023 is nearly here, scheduled for the 10th and 11th. Similar to the previous year, this autumn sale has already created

Cisco Splunk Deal

Cisco Splunk Deal Sparks Tech Acquisition Frenzy

Cisco’s recent massive purchase of Splunk, an AI-powered cybersecurity firm, for $28 billion signals a potential boost in tech deals after a year of subdued mergers and acquisitions in the

Iran Drone Expansion

Iran’s Jet-Propelled Drone Reshapes Power Balance

Iran has recently unveiled a jet-propelled variant of its Shahed series drone, marking a significant advancement in the nation’s drone technology. The new drone is poised to reshape the regional

Solar Geoengineering

Did the Overshoot Commission Shoot Down Geoengineering?

The Overshoot Commission has recently released a comprehensive report that discusses the controversial topic of Solar Geoengineering, also known as Solar Radiation Modification (SRM). The Commission’s primary objective is to

Remote Learning

Revolutionizing Remote Learning for Success

School districts are preparing to reveal a substantial technological upgrade designed to significantly improve remote learning experiences for both educators and students amid the ongoing pandemic. This major investment, which

Revolutionary SABERS Transforming

SABERS Batteries Transforming Industries

Scientists John Connell and Yi Lin from NASA’s Solid-state Architecture Batteries for Enhanced Rechargeability and Safety (SABERS) project are working on experimental solid-state battery packs that could dramatically change the

Build a Website

How Much Does It Cost to Build a Website?

Are you wondering how much it costs to build a website? The approximated cost is based on several factors, including which add-ons and platforms you choose. For example, a self-hosted