You are on page 1of 111

Hong Kong Institute of Vocational Education (Tsing Yi) Department of Multimedia and Internet Technology

Higher Diploma in Multimedia and lnternet Applications (41381)

Final Year Project Report

Apply Multi-Biometrics Recognition Systems for Intelligent House Management


By Chan Ka Lun, Peae Tsang Man Piu

Academic Year 2005/06

Supervised by Mr. MK Lam

ABSTRACT
This final year project describes the design and development of applying the biometrics technology with facial recognition and fingerprint recognition system. Several commonly used applications for our biometric system are reviewed in this report. Details of the design criteria of both hardware and software principles of operation as well as the testing and verification of the system are presented. Further development of project is also proposed and recommended. This project is to develop and built up a biometrics system for intelligent house and clubhouse. As biometrics is a popular and safety technology, the project applies this technology to improve the security level and easy for management.

TABLE OF CONTENTS
page ABSTRACT TABLE OF CONTENTS LIST OF FIGURES LIST OF TABLES LIST OF APPENDICES i ii v viii ix

Chapter 1

Introduction

1
1 1 1

1.1 Overview 1.2 Background Information 1.3 Structure of the Final Year Project Report

Chapter 2

Literature Review

3
3 3 3 3 4 6 7 7 8 10 11 12

2.1 Introduction 2.2 Introduction to Biometrics Technologies 2.2.1 What is Biometrics? 2.2.2 History of Biometrics 2.2.3 How does it work? 2.2.4 Applications in Biometrics 2.2.5 Template size of each Biometrics Technology 2.3 Examples of biometrics system in my life 2.4 Examples of biometrics system layout 2.5 Examples of hardware design 2.6 Examples of software interface design 2.7 Summary

Chapter 3
3.1 3.2 3.3 3.4 3.5

Development Methodology for Multi-Biometrics Recognition System

13
13 13 17 17 19

Introduction Design Consideration of Hardware System Design Consideration of Software Graphics Design and Layout Structure of Database Design

ii

Chapter 4

Details of the Multi-Biometrics Recognition System

20
20 21 22 22 23 23 24 25 26 28 28 29 29 30 30 31 31 32 32 34 35

4.1 Overview 4.2 Workflow of Recognition System 4.3 Function of Recognition System 4.3.1 Function of Administration tools 4.3.2 Function of Building security system 4.3.3 Function of Clubhouse system 4.4 Hardware of Recognition System 4.5 Development Software use 4.6 Software needs and setup 4.7 Database Structure 4.7.1 Relational between tables 4.7.2 Householder 4.7.3 Householder Log 4.7.4 Visitor 4.7.5 Building 4.7.6 Floor and Flat 4.7.7 Clubhouse 4.8 Graphics Design and Layout 4.8.1 Administration Tools layout design 4.8.2 Building security system layout design 4.8.3 Clubhouse system layout design

Chapter 5

Evaluation of Multi-Biometrics Recognition Systems

38
38 38 38

5.1 Overview 5.2 Principle of Biometric Enrolment and Verification 5.3 Summary

Chapter 6

Application Procedure of Multi-Biometrics Recognition Systems

39
39 39 43 45 46 47 49

6.1 Administration tools 6.1.1 Add new householder 6.1.2 Edit householder 6.1.3 Delete householder 6.1.4 Householder entry log 6.1.5 Visitor entry log 6.2 Building Security System
iii

6.2.1 Householder mode 6.2.2 Visitor mode 6.3 Clubhouse system 6.3.1 Clubhouse login and logout system 6.3.2 Clubhouse payroll system

49 51 54 54 57

Chapter 7

Verification of the Multi-Biometrics Recognition Systems

59
59 59 59

7.1 Overview 7.2 Verification of Result 7.3 Summary

Chapter 8
8.1 8.2 8.3 8.4

Conclusion and Further Development

60
60 60 60 61

Overview Contribution of Final Year Project Discussion on the Project Limitation Further Proposal

References Appendices
Appendix A: Appendix B: Appendix C: Team member workload Project plan Programming code

62 64
64 65 66

iv

LIST OF FIGURES

Fig. 2.1 Fig. 2.2 Fig. 2.3 Fig. 2.4 Fig. 2.5 Fig. 2.6 Fig. 2.7 Fig. 2.8 Fig. 2.9 Fig. 2.10 Fig. 2.11 Fig. 2.12 Fig. 3.1 Fig. 3.2 Fig. 3.3 Fig. 3.4 Fig. 3.5 Fig. 3.6 Fig. 3.7 Fig. 3.8 Fig. 3.9 Fig. 3.10 Fig. 3.11 Fig. 4.1 Fig. 4.2 Fig. 4.3 Fig. 4.4 Fig. 4.5 Fig. 4.6 Fig. 4.7 Fig. 4.8 Fig. 4.9 Fig. 4.10 Fig. 4.11

Biometric identification and encrypted data system Biometric access control system (Exys Security system) Country entry and exit control system Hand geometry control system Biometric experiment system Presse Fotos ekey fingerprint system Biometric reader clocking system Office access control system Windows lcqon recognition system Breaker facial searching system Biometric Patient Tracking System fingerID system with biometrics in USA Types of fingerprint Optical Fingerprint Sensors Surface Pressure Sensor Capacitive Sensors Facial geometry example Correct recognition example Facial recognition in airport First Visitor mode layout Second Visitor mode layout Clubhouse mode layout Database schema of Biometrics System Structure of System Workflow of Building security system Workflow of Clubhouse system Marcomedia Flash Adobe Photoshop Visual Basic 6.0 Create MySQL user Restore the backup file Permission of the folder Folder of householder and visitor Database Structure of Systems
v

page 8 8 8 9 9 10 10 10 11 11 11 11 13 14 14 14 15 15 16 17 18 18 19 20 21 22 25 25 25 26 27 27 28 28

Fig. 4.12 Fig. 4.13 Fig. 4.14 Fig. 4.15 Fig. 4.16 Fig. 4.17 Fig. 4.18 Fig. 4.19 Fig. 4.20 Fig. 4.21 Fig. 4.22 Fig. 4.23 Fig. 6.1 Fig. 6.2 Fig. 6.3 Fig. 6.4 Fig. 6.5 Fig. 6.6 Fig. 6.7 Fig. 6.8 Fig. 6.9 Fig. 6.10 Fig. 6.11 Fig. 6.12 Fig. 6.13 Fig. 6.14 Fig. 6.15 Fig. 6.16 Fig. 6.17 Fig. 6.18 Fig. 6.19 Fig. 6.20 Fig. 6.21 Fig. 6.22 Fig. 6.23 Fig. 6.24 Fig. 6.25 Fig. 6.26

Main page of Administration Tools Database Management of Householder Entry Log of Householder Entry Log of Visitor Selection mode of building security system Householder mode of building security system Visitor mode of building security system Language Selection mode of clubhouse system Selection mode of clubhouse system Login mode of clubhouse system Choose facilities mode of clubhouse system Logout mode of clubhouse system Select Database Management Click the Add New button Add user windows Procedure of face enrollment Successful message of face enrollment Successful message of add new householder Error message of add new householder New householder in the list Click the Edit button Enroll new face Successful message of face enrollment Successful message of update householder Delete the householder Confirm to delete householder Select Entry Log of householder Query of Householder Entry Log Result of Householder Entry Log Select Entry Log of visitor Query of Visitor Entry Log Show the photo of visitor Mode selection of Building Security System Procedure of identify the householder Error message when cannot identify the householder Householder identify complete Mode selection of Building Security System Procedure of enter the floor and flat
vi

32 32 33 33 34 34 35 35 36 36 37 37 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51

Fig. 6.27 Fig. 6.28 Fig. 6.29 Fig. 6.30 Fig. 6.31 Fig. 6.32 Fig. 6.33 Fig. 6.34 Fig. 6.35 Fig. 6.36 Fig. 6.37 Fig. 6.38 Fig. 6.39

Error message of enter wrong floor Procedure of face capture Procedure of fingerprint capture Visitor register complete Step 1 of process clubhouse system Step 2 of process clubhouse system Step 3 of process clubhouse system Step 4 of process clubhouse system Step 5 of process clubhouse system Step 6 of process clubhouse system Step 1 of process clubhouse payroll system Step 2 of process of clubhouse payroll system Step 3 of process of clubhouse payroll system

52 52 53 53 54 54 55 55 56 56 57 57 58

vii

LIST OF TABLES

Table 2.1 Table 4.1 Table 4.2 Table 4.3 Table 4.4 Table 4.5 Table 4.6 Table 7.1 Table 7.2

Template size of each Biometrics Technology Database structure of householder Database structure of householder log Database structure of visitor Database structure of building Database structure of floor and flat Database structure of clubhouse FRR rate of facial recognition FAR rate of facial recognition

page 7 29 29 30 30 31 31 59 59

viii

LIST OF APPENDICES

Appendix A Appendix B Appendix C

Team member workload Project plan Programming code

page 64 65 66

ix

Chapter 1
1.1 Overview

Introduction

Nowadays, Biometrics becomes important in our life. Since it has a high security and convenient, so that people use Biometrics technology on anything. Such as, door access control, border control, banking, identify people, intelligent house, etc. The application is very diverse and their capacity of development is very large. The intelligent house becomes popular for the past few years. It can provide a safety and comfortable to the householder. But the security is very important, it must be identify the house holder accurately and prevent the system to make a mistake for identification. So that, we need to build a system like the security to make a identity and monitoring the security of building. 1.2 Background Information In fact, Hong Kong building security is decreased. The thief is increased to make the people safety to be damaged. So, we must improve the building security and the management. By the way, when we come back to our building, we may use words of password or the key to open the building door. That is so trouble and inconvenience. Biometrics technologies can help us to improve the security and easy to management. So, we may use the biometrics technologies to maintain our final year project. 1.3 Structure of the Final Year Project Report The remainder of this report is divided into Seven Chapters. They are as follows: Chapter 2 covers the literature review on the design research of biometrics system. We find a lot of the information and image from Internet. Chapter 3 discusses on the design criteria of hardware system, software, layout and database Chapter 4 presents the details of the components of the hardware software, workflow and database about our system. Chapter 5 describes the performance evaluation of the developed system about the principle of biometric enrolment and verification. Chapter 6 and 7 describe the enrolment and verification procedure of how to capture and record of our recognition system.
1

Chapter 8 concludes the report and out lines the contributions of the project. The limitations were highlighted and suggestions are made for further development to improve the system.

Chapter 2

Literature Review

2.1 Introduction That part is literature review. It means we will show you all our research before our project starting. And the research should be about example of biometric system, layout of the hardware system, layout of the software interface, etc. We will show you all of our research for the final year project.

2.2 Introduction to Biometrics Technologies 2.2.1 What is Biometrics? The term biometrics refers to the emerging field of technology devoted to the identification of individuals using biological traits or behaviours [1]. In practice, this means capturing an image of a unique feature of an individual such as a fingerprint, hand, eye or face, and comparing it with a template captured previously. For ease of explanation this has been over-simplified, but in essence this is biometric technology works.

Human Recognition Systems works with 4 key biometric technologies:


z z z z

Iris Recognition Hand Recognition Fingerprint Recognition Facial Recognition

2.2.2 History of Biometrics 1800s identification largely relied upon "photographic memory" [2]. This was changed in 1883 when Alphonse Bertillon, a clerk in the Paris police prefecture, introduced physical measurement system (which came to bear his name: bertillonage) Bertillon based his system on the claim that measurement of adult bones does not change throughout life. Measurements in his system included: height, length, and breadth of the head, the length of different fingers, the length of forearms, etc (Bertillon estimated that the odds of duplicate records were 286,435,456 to 1 if 14 traits were used.

After this, the police used finger printing, which was developed by Richard Edward Henry of Scotland Yard, instead. Essentially reverting to the same methods used by

the Chinese for years. However the idea of biometrics as a field of study with useful identification applications, was there and interest in it has grown. Personal Identification Numbers (PINs) were one of the first methods used for identification. There are also methods that involve passwords and physical tokens e.g. smart cards. There are a number of problems associated with this kind of identification. People forget passwords, lose tokens, reuse passwords, write them down, tokens can get stolen. The recognition of the above does not mean the identification of the person providing it - they could be presented by anybody. With the advent of e-commerce brings increased pressure on IT managers to provide partners and customers with means of identification to access corporate networks. This results in a deluge of passwords and means of access, which are often forgotten, misused or lost. With the increased population accessing these networks the risk of attacks on the networks is increased. Companies are turning to Biometric Systems to bring tighter security to their computer networks.

Today we have the technology to realize the aims, and to refine the accuracy of biometric identification, and therefore the possibility of making it a viable field. Soon biogenetics technology will be used in every house hold and it is getting increasingly more and safer to use biometric technologies in order to better our life. 2.2.3 How does it work?

False Reject Rates: For most applications, letting the good guys in is just as important as keeping the bad guys out [3]. The probability that a biometric device won't recognize a good guy is called the "False Reject Rate." The False Reject Rates quoted for current biometric systems range from 0.00066% to 1.0%. A low False Reject Rate is very important for most applications, since users will become extremely frustrated if they're denied access by a device that has previously recognized them.

There has a example may be helpful. A company with 100 employees has a biometric device at its front door. Each employee uses the door four times a day, yielding 400 transactions per day. A False Reject Rate of 1.0% predicts that every day, four good guys (1% of 400) will be denied access. Over a five-day week, that means 20 problems. Reducing the False Reject Rate to 0.1% results in just two problems per week. A low False Reject Rate is very important for most applications, since users will become extremely frustrated if they're denied access by a device that has previously recognized them. As mentioned previously, the combination of a low False Reject Rate plus a simple keypad code provides virtually unbreakable security.

Equal Error Rates: Error curves give a graphical representation of a biometric device's "personality." The point where false accept and false reject curves cross is called the "Equal Error Rate." The Equal Error Rate provides a good indicator of the unit's performance. The smaller the Equal Error Rate, the better.

Validity of Test Data: Testing biometrics is difficult, because of the extremely low error rates involved. To attain any confidence in the statistical results, thousands of transactions must be examined. Some error rates cited by manufacturers are based on theoretical calculations. Other rates are obtained from actual field testing. Field data are usually more reliable. In the case of False Reject rates, only field test data can be considered accurate, since biometric devices require human interaction. For example, if the device is hard to use, false reject rates will tend to rise. A change in the user's biometric profile could also cause a false reject (a finger is missing, for example).

None of these conditions can be accurately quantified by purely theoretical calculations. On the other hand, False Accept Rates can be calculated with reasonable accuracy from cross-comparison of templates in large template databases.

Currently, most field test error rates have been generated by various biometric manufacturers using end-user data. Tests have also been conducted by independent laboratories such as the U.S. Department of Energy's Sandia National Laboratories. The most recent test released by Sandia was performed in 1991.

It's important to remember that error rates are statistical: they are derived from a series of transactions by a population of users. In general, the larger the population and the greater the number of transactions, the greater the confidence level in the accuracy of the results.

If the error rate is reported at 1:100,000, and only 100 transactions were included in the study, the confidence level in the results should be very low. If the same error rate was reported for 1 million transactions, the confidence level would be much higher.

The magnitude of the reported results affects the size of the sample required for a reasonable confidence level. If the reported error rate is 1:10, then a sample of 100 transactions may provide a sufficient confidence level. Conversely, a 100-transaction sample would be too small if the error rate was reported as 1:100,000. 2.2.4 Applications in Biometrics There are 9 biometrics applications: [4] z Physical Access Control z Logical Access Control z Justice/Law Enforcement z Time and Attendance z Border Control/Airports z HIPAA
z z z

Financial/Transactional Integrators/Resellers Safes, Door Locks

2.2.5

Template size of each Biometrics Technology Biometrics Technology Iris Fingerprint Facial Hand Geometry Template size per record 256 Bytes 512-1000 Bytes >512 Bytes 9 Bytes

Table 2.1 Template size of each Biometrics Technology

2.3 Examples of biometrics system in my life Law Enforcement The law enforcement community is perhaps the largest biometrics user group. Police forces thought the world use AFIS technology to process criminal suspect, match finger images and bring guilty criminals to justices. A number of biometrics vendors are earning significant revenues in this area.

Banking Bank has been evaluating a range of biometrics technologies for many years. Automated Teller Machines (ATMs) and transaction at the point of scale are particularly vulnerable to fraud and can be secured by biometrics. Other emerging markets such as telephone banking and internet bank must also be totally secure for bankers alike.

2.4 Examples of biometrics system layout We researched that the following figures are the examples of the biometrics system.

Fig. 2.1 Biometric identification and encrypted data system [5]

Fig. 2.2 Biometric access control system (Exys Security system) [6]

Fig. 2.3 Country entry and exit control system [7]

Fig. 2.4 Hand geometry control system [8]

Fig. 2.5 Biometric experiment system [9]

2.5 Examples of hardware design We may show you our research of hardware. The following figures are below.

Fig. 2.6 Presse Fotos ekey fingerprint system [10]

Fig. 2.7 Biometric reader clocking system [11]

Fig. 2.8 Office access control system [12]

10

2.6 Examples of software interface design The following figures are our research of the biometrics software interface examples.

Fig. 2.9 Windows lcqon recognition system [13]

Fig. 2.10 Breaker facial searching system [14]

Fig. 2.11 Biometric Patient Tracking System [15]

Fig. 2.12 fingerID system with biometrics in USA [16]

11

2.7 Summary After the research that, we find many about the information of biometrics and many different kinds of the biometrics system. In fact, there were many technologies were used the biometrics technology. It is the truth and it must be more popular in the future. Now a day, many old systems are displaced by the biometric system. For example: access control system, payroll system, banking system, etc. During the project development, the biometric hardware is used. There are TiFace system, U are U fingerprint system. TiFace system enables to capture and enrol users face. U are U fingerprint system is use to capture and enrol users fingerprint. So, we have to use the biometric in the future life.

12

Chapter 3

Development Methodology for Multi-Biometrics Recognition System

3.1 Introduction In this part, we will tell you about our first development methodology. What kinds of hardware did we use. Why we use that hardware. What kinds of software did we use. Why we use that software. And we also post our first layout design in that part. We will all tell you the answer 3.2 Design Consideration of Hardware System Fingerprint recognition represents the oldest method of biometric identification. Its history is going back as far as at least 2200 BC. The use of fingerprints as a personal code has a long tradition and was already used by the Assyrians, the Babylonians, the Chinese and the Japanese. Since 1897, dactyloscopy (synonym for non-computer-based fingerprint identification) has been used for criminal identification. A fingerprint consists of ridges (lines across fingerprints) and valleys (spaces between ridges). The pattern of the ridges and valleys is unique for each individual. [17]

There are two major methods of fingerprint matching: Minutiae matching and global pattern matching. The first approach analyses ridge bifurcations and endings, the second method represents a more macroscopic approach. The last approach considers the flow of ridges in terms of, for example, arches, loops and whorls. As the equal-error-rate is low, therefore fingerprint recognition is very accurate. The prices of such systems compared to other biometric systems are quite low and the user acceptance is very high. The strength of fingerprint identification is, that it can be deployed in a varied range of environments.

Fig. 3.1 Types of fingerprint [18]

13

There are 6 types of sensors for fingerprint recognition: z z z z z z Optical Fingerprint Sensors Themalelectric Sensors Capacitive Sensors E-Field Sensors Touchless Sensors Surface Pressure Sensor

Fig. 3.2 Optical Fingerprint Sensors [19]

Fig. 3.3 Surface Pressure Sensor [20]

Fig. 3.4 Capacitive Sensors [21]

The template size varies from 100 bytes to 1500 Bytes depending on the algorithm and the quality of a fingerprint. Nevertheless, very rarely there are fingerprints without any minutiae-points that leads to a failure to enroll (FER = Failure to Enroll Rate). It is also difficult to extract the minutiae points accurately when the fingerprint has got a low quality.

14

Introduction of facial recognition Facial recognition systems are built on computer programs that analyze images of human faces for the purpose of identifying them. The programs take a facial image, measure characteristics such as the distance between the eyes, the length of the nose, and the angle of the jaw, and create a unique file called a "template." Using templates, the software then compares that image with another image and produces a score that measures how similar the images are to each other. Typical sources of images for use in facial recognition include video camera signals and pre-existing photos such as those in driver's license databases. [22]

Computers can do increasingly amazing things, but they are not magic. If human beings often can't identify the subject of a photograph, why should computers be able to do it any more reliably? The human brain is highly adapted for recognizing faces infants, for example, remember faces better than other patterns, and prefer to look at them over other patterns. The human brain is also far better than computers at compensating for changes in lighting and angle. The fact is that faces are highly complex patterns that often differ in only subtle ways, and that it can be impossible for man or machine to match images when there are differences in lighting, camera, or camera angle, let alone changes in the appearance of the face itself.

Fig. 3.5 Facial geometry example [23]

Fig. 3.6 Correct recognition example [24]

15

All of this makes face recognition ideal for high traffic areas open to the general public, such as:
z z z z z z z z

Airports and railway stations Casinos Cashpoints Stadiums Public transportation Financial institutions Government offices Businesses of all kinds

Fig. 3.7 Facial recognition in airport [25]

16

3.3 Design Consideration of Software We choose macromedia flash and adobe Photoshop for our design software. Why we use that two software for design development? It is because macromedia flash is so powerful. It can be used actionscript for many different of animation. Although, it is easy to use and popular in the design area. The second point is we dont want to have a static and boring interface. So, we decided to use flash animation to replace of static picture interface. It can attract the people to use our system and make the system more interest. In the internet, many people used that two software. It is the brand name power and that software is really good for design. On the other hand, Photoshop can help us for tuning the photo color, light, size, effect, etc. It also can help us to make the picture be good. 3.4 Graphics Design and Layout

Fig. 3.8 First Visitor mode layout

17

Fig. 3.9 Second Visitor mode layout

Fig. 3.10 Clubhouse mode layout

.
18

3.5 Structure of Database Design The following Fig. 3.11 is our first development of database structure design. It only consists of 4 tables: tblHouseHolder, tblBuilding, tblVisitoryymmdd and tblFloorFlat. That is our first developed schema.

Fig. 3.11 Database schema of Biometrics System

19

Chapter 4

Details of the Multi-Biometrics Recognition System

4.1 Overview In this part, we finished to discuss and develop all the kinds of tool should we use. We will use two hardware for the system. It should be Face recognition and fingerprint hardware. And we will tell you the function of our biometric system. It has three different parts of the recognition system, please refer to Fig. 4.1. Finally, we choose the software, hardware and the final layout. We will show you all the things in the following.

Fig. 4.1 Structure of System

20

4.2 Workflow of Recognition System The following two figures 4.2 & 4.3 are our workflow of the building security system and clubhouse system.

Entry

Select Mode

Visitor

Input Floor and Flat

Householder

Facial Recognition

Enroll Face

Invaild

Check database & identify

Enroll Fingerprint

Vaild

Open door

Open door

Fig. 4.2 Workflow of Building security system

21

Entry

Select Login/Logout

Logout

Login

Login mode

Logout mode

Facial recognize
Invaild vaild Invaild

Facial recognize
vaild

Check database

Check database

Store login time to database

Store logout time to database

Fig. 4.3 Workflow of Clubhouse system

4.3 Function of Recognition System There are three parts of our recognition system. It consists of Administration Tools, Building security system and Clubhouse system. 4.3.1 Function of Administration Tools Actually, householder and visitor also need to enroll fast when they want to use the biometric system. We make an enrolment to analysis this problem. Householder can come to our office to use the householder enrolment system. They only need to put their face in front of the camera. Their face record will store to our database for verify used. They also need to type their information (e.g. name,
22

gender, and floor no., flat no., etc.) to our database used. It is used for comparison. 4.3.2 Function of Building security system We design that householder mode is for householder using. They are no need to remember the word of password for house entry. It is because the entry password always changed a time. The householder may forget the password or remember the wrong one. So, Householder mode system can help person easily for entry. They only put their face in front of camera. If they are our householders then the door will open automatically by our system. Nowadays, people visit to their friend house. They must write down their personal information (e.g. name, id, gender, visit reason, visit room no.) in the building entry control. It is because the building needs to protect their householder safety and giving record. It may make the visitor inconvenient. So, we make a visitor mode for visitor using. It can help visitor more convenient, Visitor only put their face in front of camera and fingerprint to record their personal data. That should be fast and more convenient than the paper record. 4.3.3 Function of Clubhouse system Clubhouse is to be more popular to the new building. Householders can use their own clubhouse facilities. When they used the clubhouse facilities, they need to make a paper rent. That is not convenient and trouble. So, we make a clubhouse biometric system for householder using. They only open our system and put their face in front of the camera. Our system will record their login time. Otherwise, when they want to logout and leave that they also use our system to record their logout time. They can use our clubhouse easily. When you finished your playing from clubhouse, you need to pay the free to the clubhouse using. We make a payroll system for clubhouse payment. Householder only put their face in front of camera. Our database will search your clubhouse login time and logout time used for calculate the price. When you know the price that you only pay the money to our staff. He will help you to finish the payment process.

23

4.4 Hardware of Recognition System We choose facial recognition and fingerprint for our system used Facial recognition systems are computer-based security systems that are able to automatically detect and identify human faces. These systems depend on a recognition algorithm. The first step for a facial recognition system is to recognize a human face and extract it fro the rest of the scene. Next, the system measures nodal points on the face, such as the distance between the eyes, the shape of the cheekbones and other distinguishable features. Facial recognition is a good biometric system and it is too convenience and user-friendly. So that, we use facial recognition for our system used. For the fingerprint reason, we found that following good points: z More securable than passwords by intercepting use and approach of Unauthorized people whose identification is not registered. z Free from inconvenience to upgrade and remember passwords and the company z It can save much cost to manage passwords. z Fast and exact perception with high technology of finger print identification. z Adopted dsp system that is to calculate moving direction and distance without Password by the image perceiving sensor. z No roller and soft movement thanks to less rubbing resistance. z Finally, fingerprint is easy too use, user-friendly and too cheap in the kinds of biometrics devices.

24

4.5 Development Software use Macromedia Flash

Fig. 4.4 Marcomedia Flash [26]

Adobe Photoshop

Fig. 4.5 Adobe Photoshop [27]

These two design tools are very powerful and easy to use. It can help us to analysis all the design problems. And we can make many different effects by that two software. It is very popular and great. So that, we used the tools for our interface layout design. Programming tools

Fig. 4.6 Visual Basic 6.0 [28]

Visual Basic 6.0. It is very easy to learn. It seen that very simple and comfortable for user programming. Finally, it also is a popular programming tool in the common program company.

25

4.6 Software needs and setup The basic software needs to install of the system are below: z Flash Player 8.0 z TiFace Runtime z TiFace SmartGate SDK z Futronic Fingerprint SDK The server and driver of the system needs are below: z MySQL Server 4.0.x z MySQL ODBC 3.51 Driver For easy to manage the database, we suggest to install these software are below: z MySQL Administrator z MySQL Query Browser Now, I will show you how to create new database account and restore the table in database form sql backup file. Step1. Use MySQL Administrator to create a new account. The MySQL user and password also is ive. Then, click Apply changes. The user will be created.

Fig. 4.7 Create MySQL user

26

Step2. Open the sql backup file to restore the table needs in the database. It will create the schema ive_fyp automatically.

Fig. 4.8 Restore the backup file

Next, I will show how to share the folder. This folder is used to store householder and visitors template and photo. Step1. Create a folder userdata in your any local drive. E.g.: C drive. Step2. Share this folder and set the permission of Everyone to Full control.

Fig. 4.9 Permission of the folder

27

Step3. Create two folders householder and visitor in the userdata folder.

Fig. 4.10 Folder of householder and visitor

Then, I will show you how to change the server ip of the system connect. Step1. Open the config.ini file in the same level of folder. Step2. Modify the IP and enter the correct server IP. For example, you MySQL servers IP is 192.168.0.1. So, you should enter the serverIP=192.168.0.1. And the template file and photo also store in this server. Important: If your MySQL server is setup on localhost, you must enter 127.0.0.1. 4.7 Database structure 4.7.1 Relational between tables

Fig. 4.11 Database Structure of Systems 28

4.7.2

Householder

Table: fyp_tblHouseHolder Description: Store the detail of householder Key 9 Field Name intHolderID chrHolderName chrGender datBirth chrHKID datRegDate chrUserData intBuildingID intFFID Data Type INT(5) VARCHAR(255) CHAR(1) DATE VARCHAR(11) DATE VARCHAR(64) INT(2) INT(3) Description HouseHolders ID HouseHolders Name HouseHolders Gender HouseHolder Birthday HouseHolders HKID Number Register Date Template Filename of Face Enroll Building ID Floor and Flat ID

Table 4.1 Database structure of householder

4.7.3

Householder Log

Table: fyp_tblHolderLog Description: Store the log of householder login Key 9 Field Name intLogID intHolderID datInTime Data Type INT(8) INT(5) DATETIME Description Log ID Householders ID Login Date and Time

Table 4.2 Database structure of householder log

29

4.7.4

Visitor

Table: fyp_tblVisitor Description: Store the detail and log of visitor Key 9 Field Name intVisitorID chrFaceData chrFingerData Data Type INT(8) VARCHAR(64) VARCHAR(64) Description Visitors ID Template Filename of Face Enroll Template Enroll datEntry intBuildingID intFFID DATETIME INT(2) INT(3) Entry Date and Time Building ID of Visitor visit Floor and Flat ID of Visitor visit Filename of Fingerprint

Table 4.3 Database structure of visitor

4.7.5

Building

Table: fyp_tblBuilding Description: Store the name of building Key 9 Field Name intBuildingID chrBuildingName Data Type INT(2) VARCHAR(255) Description Building ID Building Name

Table 4.4 Database structure of building

30

4.7.6

Floor and Flat

Table: fyp_tblFloorFlat Description: Store the floor and flat Key 9 Field Name intFFID chrFloor chrFlat Data Type INT(3) CHAR(2) CHAR(1) Description Floor and Flat ID Floor Number Flat Character

Table 4.5 Database structure of floor and flat

4.7.7

Clubhouse

Table: fyp_tblClubLog Description: Store the log of householder using clubhouse Key 9 Field Name intLogID intHolderID datInTime datOutTime intPrice Data Type INT INT(5) DATETIME DATETIME INT(5) Description Log ID Householders ID Login Date and Time Logout Date and Time Price of using clubhouse

Table 4.6 Database structure of clubhouse

31

4.8 Graphics Design and Layout 4.8.1 Administration Tools layout design

Fig. 4.12 Main page of Administration Tools

1. Menu bar

Fig. 4.13 Database Management of Householder

1. Query search 3. Add new householder

2. List of the householder 4. Edit selected householder

5. Delete selected householder 6. Refresh the List of householder


32

Fig. 4.14 Entry Log of Householder

1. List of entry log

2. Query search

Fig. 4.15 Entry Log of Visitor

1. List of Entry Log 3. Photo of the visitor

2. Query search

33

4.8.2

Building security system layout design

Fig. 4.16 Selection mode of building security system

1. Date and Time

2. Mode selection button

Fig. 4.17 Householder mode of building security system

1. Date and Time 3. Message box

2. Camera box 4. Exit button

34

Fig. 4.18 Visitor mode of building security system

1. Date and Time 3. Message box 5. Exit button 4.8.3 Clubhouse system layout

2. Display of floor and flat 4. Number and character keypad

Fig. 4.19 Language Selection mode of clubhouse system

1. Mode selection button

35

Fig. 4.20 Selection mode of clubhouse system

1. Mode selection button

Fig. 4.21 Login mode of clubhouse system

1. Camera box 3. Login button

2. Message box

36

Fig. 4.22 Choose facilities mode of clubhouse system

1. Camera box 3. Login button

2. Message box 4. Facilities button

Fig. 4.23 Logout mode of clubhouse system

1. Camera box 3. Logout button

2. Message box

37

Chapter 5

Evaluation of Multi-Biometrics Recognition Systems

5.1 Overview We would like to tell you our biometric system. Its all of good points in the popular area. And we also have any short points for future improvement. 5.2 Principle of Biometric Enrolment and Verification For the good side, people no need to remember the word of password for entry to their building. They no need to use any key or find other people to help them open the door. Our biometric system can easy to help people only put their face in front of the camera for open the door. It seen that it is very convenience, comfortable and user-friendly to our customer. For the bad side, when a householder sometime wears glasses, sometime not wear glasses. Our facial recognition system may verify failed for their glasses or cap. It is because our system is followed the capture face data to compare the persons face. If the person wear glasses or cap, it may verify failed. On the other hand, if the area has not enough light. It also may distort the verify %. It is because if the area has not enough light, then the camera can not capture the face data fully and immediately. 5.3 Summary In fact, all of the technology also has good and bad points. Facial recognition system also has that two points. But Biometric system really can help people to make the world convenience and more easy. So that, biometric system also can help human to analysis many problems. We may improve the biometric technology as soon as possible. It is because it may be the future one of the main technology.

38

Chapter 6

Application Procedure of Multi-Biometrics Recognition Systems

6.1 Administration Tools 6.1.1 Add new householder Step1. Select Householder -> Database Management in menu bar.

Fig. 6.1 Select Database Management

Step2. Click the Add New button.

Fig. 6.2 Click the Add New button 39

Step3. The Add user windows will appear. Enter the detail of householder.

Fig. 6.3 Add user windows

Step4. Click the Start button to open the camera and click Enroll button to make a face enrollment.

Fig. 6.4 Procedure of face enrollment

40

Step5. The successful message will be appear when the face enrollment success.

Fig. 6.5 Successful message of face enrollment

Step6. Click the Save button after enroll the face and enter the detail. The tools will add new householder in database and show the successful message.

Fig. 6.6 Successful message of add new householder

41

Step7. If you do not enroll the face before click the Save button, the tools will show the error message and tell you enroll the face.

Fig. 6.7 Error message of add new householder

Step8. The tools will show you the new householder in the list.

Fig. 6.8 New householder in the list

42

6.1.2 Edit householder Step1. Select the householder you want to edit in the list, and then click Edit button.

Fig. 6.9 Click the Edit button

Step2. Click the Start button to open the camera and click Enroll button to make a new face enrollment.

Fig. 6.10 Enroll new face

43

Step3. The successful message will be appear when the face enrollment success.

Fig. 6.11 Successful message of face enrollment

Step4. Click the Save button after enroll the face and modify the detail. The tools will update householder in database and show the successful message.

Fig. 6.12 Successful message of update householder

44

6.1.3 Delete householder Step1. Select the householder in the list and click Delete button.

Fig. 6.13 Delete the householder

Step2. The tools will ask you confirm to delete.

Fig. 6.14 Confirm to delete householder

45

6.1.4 Householder entry log Step1. Select Householder -> Entry Log in menu bar.

Fig. 6.15 Select Entry Log of householder

Step2. Enter the householder ID or name and select the range of date to search the log.

Fig. 6.16 Query of Householder Entry Log

46

Step3. The tools will show the result.

Fig. 6.17 Result of Householder Entry Log

6.1.5 Visitor entry log Step1. Select Visitor -> Entry Log in menu bar.

Fig. 6.18 Select Entry Log of visitor

47

Step2. Select the date and building

Fig. 6.19 Query of Visitor Entry Log

Step3. You can select the visitor in the list and it will show the photo of visitor.

Fig. 6.20 Show the photo of visitor

48

6.2 Building Security System 6.2.1 Householder Mode Step1. Press the Householder button.

Fig. 6.21 Mode selection of Building Security System

Step2. The systems will identify after 3 seconds automatically. No needs enter any button.

Fig. 6.22 Procedure of identify the householder

49

Step3. If the systems cannot identify you, it will show the error message and identify after 3 seconds again.

Fig. 6.23 Error message when cannot identify the householder

Step4. If success to identify, the systems will show your name and show you the success message. The door will be open.

Fig. 6.24 Householder identify complete

50

6.2.2 Visitor Mode Step1. Press the Visitor button.

Fig. 6.25 Mode selection of Building Security System

Step2. Enter the floor and flat you want to go. Then, press the Enter button. Also, you can the Clear button when you enter wrong floor and flat.

Fig. 6.26 Procedure of enter the floor and flat

51

Step3. Our floor range is 1 to 15. If you enter large than 15, you will get the error message and enter the correct floor.

Fig. 6.27 Error message of enter wrong floor

Step4. Press the button to capture your face when you are ready in front of the camera. After press the button, the systems will countdown 3 seconds to capture automatically.

Fig. 6.28 Procedure of face capture

52

Step5. Put your any finger on the fingerprint device to capture your finger. It needs to capture 3 times.

Fig. 6.29 Procedure of fingerprint capture

Step6. After face and fingerprint capture, the systems will save your data in database and open the door.

Fig. 6.30 Visitor register complete

53

6.3 Clubhouse system 6.3.1 Process of clubhouse login and logout system Step1. You can see the selection page. When you want to login clubhouse, you can press the button

Fig. 6.31 Step 1 of process clubhouse system

Step2. The login page is opened. You can see the monitor and message. In this moment, you need to put your face in front of the camera.

Fig. 6.32 Step 2 of process clubhouse system

54

Step3. When you are our householder, our database will find your face data. The system will let you pass the login process and click the login button for verifies.

Fig. 6.33 Step 3 of process clubhouse system

Step4. When you login successful, our database should store your login time record.

Fig. 6.34 Step 4 of process clubhouse system

55

Step5. When you want to leave our clubhouse, you must logout our system. It is as same as login part. You also put on your face in front of the camera. Our database will record your logout time automatically.

Fig. 6.35 Step 5 of process clubhouse system

Step6. When you logout successful, our database should store your logout time record.

Fig. 6.36 Step 6 of process clubhouse system

56

Process of clubhouse payroll system Step1. When you pay the clubhouse free, you may go to our clubhouse payroll system.
6.3.2

Fig. 6.37 Step 1 of process clubhouse payroll system

Step2. You also put your face in front of our camera. Our database will search your login and logout time for calculates the price for clubhouse payment.

Fig. 6.38 Step 2 of process of clubhouse payroll system

57

Step3. When you pay the money to our staff, our database should store your payment record.

Fig. 6.39 Step 3 of process of clubhouse payroll system

58

Chapter 7

Verification of the Multi-Biometrics Recognition Systems

7.1 Overview In this part, we would like to represent our systems verification result of facial recognition. We will test it 20 times to get the result of its FAR and FRR. It cans test the reliable and accuracy of the system. 7.2 Verification of Result FAR and FRR of Facial recognition: No. of correct acceptance (a) 15 No. of false rejection (b) 5
Table 7.1 FRR rate of facial recognition

False Rejection Rate (FRR) b / (a + b) 0.25

No. of correct rejection (a) 20

No. of false acceptance (b) 0

False Acceptance Rate (FAR) b / (a + b) 0

Table 7.2 FAR rate of facial recognition

7.3 Summary To summarize, the FRR of facial recognition is a little bit high. It is 0.25%. Sometimes, it cannot verify properly. It is because the light, glasses, cap may affect the system to verify. Although the FRR is a little bit high, the FAR is 0. It shows that the system have a high reliable. And the system have a high accuracy to verify the user.

59

Chapter 8
8.1 Overview

Conclusions and Further Development

Base on the important of biometrics technology, it is popular and user-friendly to displace many older technologies and systems in the future technology development. 8.2 Contribution of Final Year Project The achievements and contributions of this project can be summarizes as follows:We are developed the three parts of the recognition system. There are Administration Tools, Building Security System and Clubhouse System. It is ready to apply in the building. This recognition is convenience and safety for security management. We also need to improve our technology, security and method for biometrics system built up process and developed any great ideas. They are no need to remember the word of password for house entry. It is because the entry password always changed a time. The householder may forget the password or remember the wrong one. Now, they only use their face to make an entry and no need to bring smartcard and remember the password.

8.3 Discussion on the Project Limitation When a person sometime wears glasses, sometime not wear glasses. Our facial recognition system may verify failed for their glasses or cap. It is because our system is followed the capture face data to compare the persons face. So, the person enrolls the face record that he has no wear any glasses or anything on his face. If the person wears glasses or cap to verify, it may verify failed. On the other hand, if the area has not enough light or in a dark area. It also may distort the verify %. It may verify failed. It is because if the area has not enough light, then the camera cannot capture the face data fully and immediately.

60

8.4 Further Proposal After this project, we have other further ideas. The further ideas are below:z z z z z Administration Tools can generate the report of householder or visitor. Add Chinese interface of the building security system. Send the email or signal to householder when visitor come. Payroll monthly statement for members. Car entry and exit recognition system for car park Use face recognition to identify the householder and open the gate Record the entry and exit log for security The householder no need to bring the car park card for entry used

61

References
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]
Introduction of Biometrics http://www.hrsltd.com/identification_technology/biometrics.htm History of Biometrics http://library.thinkquest.org/TQ0313041/scrottyhistory.htm How does it work? http://www.findbiometrics.com/Pages/guide2.html Applications in Biometrics http://www.findbiometrics.com/index.html#applications Fig. 2.1 Biometric identification and encrypted data system http://www.pressi.com/gb/image/61510.html Fig. 2.2 Biometric access control system (Exys Security system) http://www.exys.co.za/resume.html Fig. 2.3 Country entry and exit control system http://www.komotv.com/news/story.asp?ID=17825 Fig. 2.4 Hand geometry control system http://www.inspectech.us/Securitysolutions_biometric.cfm Fig. 2.5 Biometric experiment system http://www.intellisystem.it/eventi/TIMcatania2003/Tim2003.htm Fig. 2.6 Presse Fotos ekey fingerprint system http://www.ekey.at/presse/fotos.asp Fig. 2.7 Biometric reader clocking system http://www.tensor.co.uk/english/biometric-clocking-system.htm Fig. 2.8 Office access control system http://www.clarinetsys.com/en/kiosk.htm Fig. 2.9 Windows lcqon recognition system http://www.acroprint.com/acroprintstore/Solutions/biometrics-faq.aspx Fig. 2.10 Breaker facial searching system http://www.asia-soft.com/frs/en/projects/obraz/ Fig. 2.11 Biometric Patient Tracking System http://www.questbiometrics.com/biometrics-timekeeper-software.html Fig. 2.12 fingerID system with biometrics in USA http://msnbc.msn.com/id/3999879 Introduction of fingerprint recognition http://www.bergdata.com/downloads/Introduction%20to%20Fingerprint.pdf Fig. 3.1 Types of fingerprint

62

[19] [20] [21] [22]

Fig. 3.2 Optical Fingerprint Sensors http://www.bergdata.com/downloads/Introduction%20to%20Fingerprint.pdf Fig. 3.3 Surface Pressure Sensor http://www.bergdata.com/downloads/Introduction%20to%20Fingerprint.pdf Fig. 3.4 Capacitive Sensors http://www.bergdata.com/downloads/Introduction%20to%20Fingerprint.pdf

Introduction of facial recognition


http://www.findbiometrics.com/Pages/face_articles/face_2.html http://www.c-vis.com/htd/frt.html

[23] [24] [25] [26] [27] [28]

Fig. 3.5 Facial geometry example http://www.c-vis.com/htd/frt.html Fig. 3.6 Correct recognition example http://www.c-vis.com/htd/frt.html Fig. 3.7 Facial recognition in airport http://www.c-vis.com/htd/frt.html Fig. 4.1 Marcomedia Flash http://www.adobe.com/products/flash/flashpro/ Fig. 4.2 Adobe Photoshop http://www.adobe.com/products/photoshop/ Fig. 4.3 Visual Basic 6.0 http://msdn.microsoft.com/vbrun/ Tutorial and example of VB and MySQL http://www.vbmysql.com Tutorial of embedded Flash in VB6 http://www.adobe.com/devnet/flash/articles/flash_vb.pdf http://www.vbcode.com

63

Appendices Appendix A: Team member workload


Chan Ka Lun, Peae (leader) z Design interface of Householder mode z Design interface of Visitor mode z Design interface of enrolment mode z Design interface of administrator mode z Programming of Householder mode z Programming of Visitor mode z Programming of enrolment mode z Programming of administrator mode z Build up database system Tsang Man Piu z Design interface of Clubhouse login system z Design interface of Clubhouse payroll system z Programming of Clubhouse login system z Programming of Clubhouse payroll system

64

Appendix B: Project plan PROJECT PLAN

Course Student Name Project Title Project Supervisor Date Project Objective(s)

: 41381/3A : Chan Ka Lun, Tsang Man Piu : Apply Multi-Biometrics Recognition Systems for Intelligent House Management : Mr. MK Lam : 7 October, 2005 (Week 4) : - Developed to use humans face and fingerprint to in place of the words of password and key. - Development of Multi-Biometrics Recognition System to instead of traditional security

Week No. Survey & Research Work flow & Database draft design Interface draft design Read SmartGates manual and SDK Read Futronic Fingerprint SDK Database & Interface programming Programming Testing Project report & presentation

10

12

14

16

18

20

22

24

26

28

30

32

34

36

38

Project Resources Plan z PC with development environment Equipment: z Webcam z Fingerprint device z Touch screen Tools: z Microsoft Visio for drawing diagram z Microsoft Word for typing report z Microsoft PowerPoint for presentation z Adobe Photoshop for interface design z Macromedia Flash for interface design z Microsoft Visual Basic 6.0 for system programming z Titanium SmartGate Biometric System SDK z Futronic Fingerprint SDK

65

Appendix C: Programming code


z The class module of system CRijndael.cls This class module is used to generate the 64 character filename of the template.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 Option Explicit Private Private Private Private m_lOnBits(30) As Long m_l2Power(30) As Long m_bytOnBits(7) As Byte m_byt2Power(7) As Byte

Private m_InCo(3) As Byte Private Private Private Private Private Private Private Private Private Private Private Private Private Private m_fbsub(255) m_rbsub(255) m_ptab(255) m_ltab(255) m_ftable(255) m_rtable(255) m_rco(29) As Byte As Byte As Byte As Byte As Long As Long As Long

m_Nk As Long m_Nb As Long m_Nr As Long m_fi(23) As Byte m_ri(23) As Byte m_fkey(119) As Long m_rkey(119) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (ByVal Destination As Any, ByVal Source As Any, ByVal Length As Long) '******************************************************************************* ' Class_Initialize (SUB) '******************************************************************************* Private Sub Class_Initialize() m_InCo(0) = &HB m_InCo(1) = &HD m_InCo(2) = &H9 m_InCo(3) = &HE ' Could have done this with a loop calculating each value, but simply ' assigning the values is quicker - BITS SET FROM RIGHT m_bytOnBits(0) = 1 ' 00000001 m_bytOnBits(1) = 3 ' 00000011 m_bytOnBits(2) = 7 ' 00000111 m_bytOnBits(3) = 15 ' 00001111 m_bytOnBits(4) = 31 ' 00011111 m_bytOnBits(5) = 63 ' 00111111 m_bytOnBits(6) = 127 ' 01111111 m_bytOnBits(7) = 255 ' 11111111 ' Could have done this with a loop calculating each value, but simply ' assigning the values is quicker - POWERS OF 2 m_byt2Power(0) = 1 ' 00000001 m_byt2Power(1) = 2 ' 00000010 m_byt2Power(2) = 4 ' 00000100 m_byt2Power(3) = 8 ' 00001000 m_byt2Power(4) = 16 ' 00010000 m_byt2Power(5) = 32 ' 00100000 m_byt2Power(6) = 64 ' 01000000 m_byt2Power(7) = 128 ' 10000000 ' Could have done this with a loop calculating each value, but simply ' assigning the values is quicker - BITS SET FROM RIGHT m_lOnBits(0) = 1 ' 00000000000000000000000000000001 m_lOnBits(1) = 3 ' 00000000000000000000000000000011 m_lOnBits(2) = 7 ' 00000000000000000000000000000111

66

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140

m_lOnBits(3) = 15 ' 00000000000000000000000000001111 m_lOnBits(4) = 31 ' 00000000000000000000000000011111 m_lOnBits(5) = 63 ' 00000000000000000000000000111111 m_lOnBits(6) = 127 ' 00000000000000000000000001111111 m_lOnBits(7) = 255 ' 00000000000000000000000011111111 m_lOnBits(8) = 511 ' 00000000000000000000000111111111 m_lOnBits(9) = 1023 ' 00000000000000000000001111111111 m_lOnBits(10) = 2047 ' 00000000000000000000011111111111 m_lOnBits(11) = 4095 ' 00000000000000000000111111111111 m_lOnBits(12) = 8191 ' 00000000000000000001111111111111 m_lOnBits(13) = 16383 ' 00000000000000000011111111111111 m_lOnBits(14) = 32767 ' 00000000000000000111111111111111 m_lOnBits(15) = 65535 ' 00000000000000001111111111111111 m_lOnBits(16) = 131071 ' 00000000000000011111111111111111 m_lOnBits(17) = 262143 ' 00000000000000111111111111111111 m_lOnBits(18) = 524287 ' 00000000000001111111111111111111 m_lOnBits(19) = 1048575 ' 00000000000011111111111111111111 m_lOnBits(20) = 2097151 ' 00000000000111111111111111111111 m_lOnBits(21) = 4194303 ' 00000000001111111111111111111111 m_lOnBits(22) = 8388607 ' 00000000011111111111111111111111 m_lOnBits(23) = 16777215 ' 00000000111111111111111111111111 m_lOnBits(24) = 33554431 ' 00000001111111111111111111111111 m_lOnBits(25) = 67108863 ' 00000011111111111111111111111111 m_lOnBits(26) = 134217727 ' 00000111111111111111111111111111 m_lOnBits(27) = 268435455 ' 00001111111111111111111111111111 m_lOnBits(28) = 536870911 ' 00011111111111111111111111111111 m_lOnBits(29) = 1073741823 ' 00111111111111111111111111111111 m_lOnBits(30) = 2147483647 ' 01111111111111111111111111111111 ' Could have done this with a loop calculating each value, but simply ' assigning the values is quicker - POWERS OF 2 m_l2Power(0) = 1 ' 00000000000000000000000000000001 m_l2Power(1) = 2 ' 00000000000000000000000000000010 m_l2Power(2) = 4 ' 00000000000000000000000000000100 m_l2Power(3) = 8 ' 00000000000000000000000000001000 m_l2Power(4) = 16 ' 00000000000000000000000000010000 m_l2Power(5) = 32 ' 00000000000000000000000000100000 m_l2Power(6) = 64 ' 00000000000000000000000001000000 m_l2Power(7) = 128 ' 00000000000000000000000010000000 m_l2Power(8) = 256 ' 00000000000000000000000100000000 m_l2Power(9) = 512 ' 00000000000000000000001000000000 m_l2Power(10) = 1024 ' 00000000000000000000010000000000 m_l2Power(11) = 2048 ' 00000000000000000000100000000000 m_l2Power(12) = 4096 ' 00000000000000000001000000000000 m_l2Power(13) = 8192 ' 00000000000000000010000000000000 m_l2Power(14) = 16384 ' 00000000000000000100000000000000 m_l2Power(15) = 32768 ' 00000000000000001000000000000000 m_l2Power(16) = 65536 ' 00000000000000010000000000000000 m_l2Power(17) = 131072 ' 00000000000000100000000000000000 m_l2Power(18) = 262144 ' 00000000000001000000000000000000 m_l2Power(19) = 524288 ' 00000000000010000000000000000000 m_l2Power(20) = 1048576 ' 00000000000100000000000000000000 m_l2Power(21) = 2097152 ' 00000000001000000000000000000000 m_l2Power(22) = 4194304 ' 00000000010000000000000000000000 m_l2Power(23) = 8388608 ' 00000000100000000000000000000000 m_l2Power(24) = 16777216 ' 00000001000000000000000000000000 m_l2Power(25) = 33554432 ' 00000010000000000000000000000000 m_l2Power(26) = 67108864 ' 00000100000000000000000000000000 m_l2Power(27) = 134217728 ' 00001000000000000000000000000000 m_l2Power(28) = 268435456 ' 00010000000000000000000000000000 m_l2Power(29) = 536870912 ' 00100000000000000000000000000000 m_l2Power(30) = 1073741824 ' 01000000000000000000000000000000 End Sub '******************************************************************************* ' LShift (FUNCTION) '******************************************************************************* Private Function LShift(ByVal lValue As Long, _ ByVal iShiftBits As Integer) As Long If iShiftBits = 0 Then LShift = lValue Exit Function ElseIf iShiftBits = 31 Then If lValue And 1 Then LShift = &H80000000 Else

67

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216

LShift = 0 End If Exit Function ElseIf iShiftBits < 0 Or iShiftBits > 31 Then Err.Raise 6 End If If (lValue And m_l2Power(31 - iShiftBits)) Then LShift = ((lValue And m_lOnBits(31 - (iShiftBits + 1))) * _ m_l2Power(iShiftBits)) Or &H80000000 Else LShift = ((lValue And m_lOnBits(31 - iShiftBits)) * _ m_l2Power(iShiftBits)) End If End Function '******************************************************************************* ' RShift (FUNCTION) '******************************************************************************* Private Function RShift(ByVal lValue As Long, _ ByVal iShiftBits As Integer) As Long If iShiftBits = 0 Then RShift = lValue Exit Function ElseIf iShiftBits = 31 Then If lValue And &H80000000 Then RShift = 1 Else RShift = 0 End If Exit Function ElseIf iShiftBits < 0 Or iShiftBits > 31 Then Err.Raise 6 End If RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits) If (lValue And &H80000000) Then RShift = (RShift Or (&H40000000 \ m_l2Power(iShiftBits - 1))) End If End Function '******************************************************************************* ' LShiftByte (FUNCTION) '******************************************************************************* Private Function LShiftByte(ByVal bytValue As Byte, _ ByVal bytShiftBits As Byte) As Byte If bytShiftBits = 0 Then LShiftByte = bytValue Exit Function ElseIf bytShiftBits = 7 Then If bytValue And 1 Then LShiftByte = &H80 Else LShiftByte = 0 End If Exit Function ElseIf bytShiftBits < 0 Or bytShiftBits > 7 Then Err.Raise 6 End If LShiftByte = ((bytValue And m_bytOnBits(7 - bytShiftBits)) * _ m_byt2Power(bytShiftBits)) End Function '******************************************************************************* ' RShiftByte (FUNCTION) '******************************************************************************* Private Function RShiftByte(ByVal bytValue As Byte, _ ByVal bytShiftBits As Byte) As Byte If bytShiftBits = 0 Then RShiftByte = bytValue Exit Function ElseIf bytShiftBits = 7 Then If bytValue And &H80 Then RShiftByte = 1

68

217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292

Else RShiftByte = 0 End If Exit Function ElseIf bytShiftBits < 0 Or bytShiftBits > 7 Then Err.Raise 6 End If RShiftByte = bytValue \ m_byt2Power(bytShiftBits) End Function '******************************************************************************* ' RotateLeft (FUNCTION) '******************************************************************************* Private Function RotateLeft(ByVal lValue As Long, _ ByVal iShiftBits As Integer) As Long RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 - iShiftBits)) End Function ''******************************************************************************* '' RotateLeftByte (FUNCTION) '******************************************************************************* Private Function RotateLeftByte(ByVal bytValue As Byte, _ ByVal bytShiftBits As Byte) As Byte RotateLeftByte = LShiftByte(bytValue, bytShiftBits) Or _ RShiftByte(bytValue, (8 - bytShiftBits)) End Function '******************************************************************************* ' Pack (FUNCTION) '******************************************************************************* Private Function Pack(b() As Byte) As Long Dim lCount As Long Dim lTemp As Long For lCount = 0 To 3 lTemp = b(lCount) Pack = Pack Or LShift(lTemp, (lCount * 8)) Next End Function '******************************************************************************* ' PackFrom (FUNCTION) '******************************************************************************* Private Function PackFrom(b() As Byte, _ ByVal k As Long) As Long Dim lCount As Long Dim lTemp As Long For lCount = 0 To 3 lTemp = b(lCount + k) PackFrom = PackFrom Or LShift(lTemp, (lCount * 8)) Next End Function '******************************************************************************* ' Unpack (SUB) '******************************************************************************* Private Sub Unpack(ByVal a As Long, _ b() As Byte) b(0) = a And m_lOnBits(7) b(1) = RShift(a, 8) And m_lOnBits(7) b(2) = RShift(a, 16) And m_lOnBits(7) b(3) = RShift(a, 24) And m_lOnBits(7) End Sub '******************************************************************************* ' UnpackFrom (SUB) '******************************************************************************* Private Sub UnpackFrom(ByVal a As Long, _ b() As Byte, _ ByVal k As Long) b(0 + k) = a And m_lOnBits(7) b(1 + k) = RShift(a, 8) And m_lOnBits(7) b(2 + k) = RShift(a, 16) And m_lOnBits(7) b(3 + k) = RShift(a, 24) And m_lOnBits(7)

69

293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368

End Sub '******************************************************************************* ' xtime (FUNCTION) '******************************************************************************* Private Function xtime(ByVal a As Byte) As Byte Dim b As Byte If (a And &H80) Then b = &H1B Else b = 0 End If a = LShiftByte(a, 1) a = a Xor b xtime = a End Function '******************************************************************************* ' bmul (FUNCTION) '******************************************************************************* Private Function bmul(ByVal x As Byte, _ y As Byte) As Byte If x <> 0 And y <> 0 Then bmul = m_ptab((CLng(m_ltab(x)) + CLng(m_ltab(y))) Mod 255) Else bmul = 0 End If End Function '******************************************************************************* ' SubByte (FUNCTION) '******************************************************************************* Private Function SubByte(ByVal a As Long) As Long Dim b(3) As Byte Unpack b(0) = b(1) = b(2) = b(3) = a, b m_fbsub(b(0)) m_fbsub(b(1)) m_fbsub(b(2)) m_fbsub(b(3))

SubByte = Pack(b) End Function '******************************************************************************* ' product (FUNCTION) '******************************************************************************* Private Function product(ByVal x As Long, _ ByVal y As Long) As Long Dim xb(3) As Byte Dim yb(3) As Byte Unpack x, xb Unpack y, yb product = bmul(xb(0), yb(0)) Xor bmul(xb(1), yb(1)) Xor bmul(xb(2), yb(2)) _ Xor bmul(xb(3), yb(3)) End Function '******************************************************************************* ' InvMixCol (FUNCTION) '******************************************************************************* Private Function InvMixCol(ByVal x As Long) As Long Dim y As Long Dim m As Long Dim b(3) As Byte m = Pack(m_InCo) b(3) = product(m, m = RotateLeft(m, b(2) = product(m, m = RotateLeft(m, b(1) = product(m, m = RotateLeft(m,

x) 24) x) 24) x) 24)

70

369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444

b(0) = product(m, x) y = Pack(b) InvMixCol = y End Function '******************************************************************************* ' ByteSub (FUNCTION) '******************************************************************************* Private Function ByteSub(ByVal x As Byte) As Byte Dim y As Byte y x x y x y x y x y y = = = = = = = = = = = m_ptab(255 - m_ltab(x)) y RotateLeftByte(x, 1) y Xor x RotateLeftByte(x, 1) y Xor x RotateLeftByte(x, 1) y Xor x RotateLeftByte(x, 1) y Xor x y Xor &H63

ByteSub = y End Function '******************************************************************************* ' gentables (SUB) '******************************************************************************* Public Sub gentables() Dim i As Long Dim y As Byte Dim b(3) As Byte Dim ib As Byte m_ltab(0) m_ptab(0) m_ltab(1) m_ptab(1) m_ltab(3) = = = = = 0 1 0 3 1

For i = 2 To 255 m_ptab(i) = m_ptab(i - 1) Xor xtime(m_ptab(i - 1)) m_ltab(m_ptab(i)) = i Next m_fbsub(0) = &H63 m_rbsub(&H63) = 0 For i = 1 To 255 ib = i y = ByteSub(ib) m_fbsub(i) = y m_rbsub(y) = i Next y = 1 For i = 0 To 29 m_rco(i) = y y = xtime(y) Next For i = 0 To 255 y = m_fbsub(i) b(3) = y Xor xtime(y) b(2) = y b(1) = y b(0) = xtime(y) m_ftable(i) = Pack(b) y = m_rbsub(i) b(3) = bmul(m_InCo(0), b(2) = bmul(m_InCo(1), b(1) = bmul(m_InCo(2), b(0) = bmul(m_InCo(3),

y) y) y) y)

71

445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520

m_rtable(i) = Pack(b) Next End Sub '******************************************************************************* ' gkey (SUB) '******************************************************************************* Public Sub gkey(ByVal nb As Long, _ ByVal nk As Long, _ key() As Byte) Dim Dim Dim Dim Dim Dim Dim Dim Dim i j k m N C1 C2 C3 CipherKey(7) As Long As Long As Long As Long As Long As Long As Long As Long As Long

m_Nb = nb m_Nk = nk If m_Nb >= m_Nk Then m_Nr = 6 + m_Nb Else m_Nr = 6 + m_Nk End If C1 = 1 If m_Nb C2 = C3 = Else C2 = C3 = End If

< 8 Then 2 3 3 4

For j = 0 To nb - 1 m = j * 3 m_fi(m) = (j + C1) Mod nb m_fi(m + 1) = (j + C2) Mod nb m_fi(m + 2) = (j + C3) Mod nb m_ri(m) = (nb + j - C1) Mod nb m_ri(m + 1) = (nb + j - C2) Mod nb m_ri(m + 2) = (nb + j - C3) Mod nb Next N = m_Nb * (m_Nr + 1) For i = 0 To m_Nk - 1 j = i * 4 CipherKey(i) = PackFrom(key, j) Next For i = 0 To m_Nk - 1 m_fkey(i) = CipherKey(i) Next j = m_Nk k = 0 Do While j < N m_fkey(j) = m_fkey(j - m_Nk) Xor _ SubByte(RotateLeft(m_fkey(j - 1), 24)) Xor m_rco(k) If m_Nk <= 6 Then i = 1 Do While i < m_Nk And (i + j) < N m_fkey(i + j) = m_fkey(i + j - m_Nk) Xor _ m_fkey(i + j - 1) i = i + 1 Loop Else ' Problem fixed here i = 1

72

521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595

Do While i < 4 And (i + j) < N m_fkey(i + j) = m_fkey(i + j m_fkey(i + j - 1) i = i + 1 Loop If j + 4 < N Then m_fkey(j + 4) = m_fkey(j + 4 SubByte(m_fkey(j + 3)) End If i = 5 Do While i < m_Nk And (i + j) < m_fkey(i + j) = m_fkey(i + j m_fkey(i + j - 1) i = i + 1 Loop End If j = j + m_Nk k = k + 1 Loop For j = 0 To m_Nb - 1 m_rkey(j + N - nb) = m_fkey(j) Next

- m_Nk) Xor _

- m_Nk) Xor _

N - m_Nk) Xor _

i = m_Nb Do While i < N - m_Nb k = N - m_Nb - i For j = 0 To m_Nb - 1 m_rkey(k + j) = InvMixCol(m_fkey(i + j)) Next i = i + m_Nb Loop j = N - m_Nb Do While j < N m_rkey(j - N + m_Nb) = m_fkey(j) j = j + 1 Loop End Sub '******************************************************************************* ' encrypt (SUB) '******************************************************************************* Public Sub Encrypt(buff() As Byte) Dim i As Long Dim j As Long Dim k As Long Dim m As Long Dim a(7) As Long Dim b(7) As Long Dim x() As Long Dim y() As Long Dim t() As Long For i = 0 To m_Nb - 1 j = i * 4 a(i) = PackFrom(buff, j) a(i) = a(i) Xor m_fkey(i) Next k = m_Nb x = a y = b For i = 1 To m_Nr - 1 For j = 0 To m_Nb - 1 m = j * 3 y(j) = m_fkey(k) Xor m_ftable(x(j) And m_lOnBits(7)) Xor _ RotateLeft(m_ftable(RShift(x(m_fi(m)), 8) And m_lOnBits(7)), 8) Xor _ RotateLeft(m_ftable(RShift(x(m_fi(m + 1)), 16) And m_lOnBits(7)), 16) Xor _ RotateLeft(m_ftable(RShift(x(m_fi(m + 2)), 24) And m_lOnBits(7)), 24) k = k + 1 Next

73

596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670

t = x x = y y = t Next For j = 0 To m_Nb - 1 m = j * 3 y(j) = m_fkey(k) Xor m_fbsub(x(j) And m_lOnBits(7)) Xor _ RotateLeft(m_fbsub(RShift(x(m_fi(m)), 8) And m_lOnBits(7)), 8) Xor _ RotateLeft(m_fbsub(RShift(x(m_fi(m + 1)), 16) And m_lOnBits(7)), 16) Xor _ RotateLeft(m_fbsub(RShift(x(m_fi(m + 2)), 24) And m_lOnBits(7)), 24) k = k + 1 Next For i = 0 To m_Nb - 1 j = i * 4 UnpackFrom y(i), buff, j x(i) = 0 y(i) = 0 Next End Sub '******************************************************************************* ' decrypt (SUB) '******************************************************************************* Public Sub Decrypt(buff() As Byte) Dim i As Long Dim j As Long Dim k As Long Dim m As Long Dim a(7) As Long Dim b(7) As Long Dim x() As Long Dim y() As Long Dim t() As Long For i = 0 To m_Nb - 1 j = i * 4 a(i) = PackFrom(buff, j) a(i) = a(i) Xor m_rkey(i) Next k = m_Nb x = a y = b For i = 1 To m_Nr - 1 For j = 0 To m_Nb - 1 m = j * 3 y(j) = m_rkey(k) Xor m_rtable(x(j) And m_lOnBits(7)) Xor _ RotateLeft(m_rtable(RShift(x(m_ri(m)), 8) And m_lOnBits(7)), 8) Xor _ RotateLeft(m_rtable(RShift(x(m_ri(m + 1)), 16) And m_lOnBits(7)), 16) Xor _ RotateLeft(m_rtable(RShift(x(m_ri(m + 2)), 24) And m_lOnBits(7)), 24) k = k + 1 Next t = x x = y y = t Next For j = 0 To m_Nb - 1 m = j * 3 y(j) = m_rkey(k) Xor m_rbsub(x(j) And m_lOnBits(7)) Xor _ RotateLeft(m_rbsub(RShift(x(m_ri(m)), 8) And m_lOnBits(7)), 8) Xor _ RotateLeft(m_rbsub(RShift(x(m_ri(m + 1)), 16) And m_lOnBits(7)), 16) Xor _ RotateLeft(m_rbsub(RShift(x(m_ri(m + 2)), 24) And m_lOnBits(7)), 24) k = k + 1 Next For i = 0 To m_Nb - 1 j = i * 4 UnpackFrom y(i), buff, j x(i) = 0

74

671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746

y(i) = 0 Next End Sub ''******************************************************************************* '' CopyBytesASP (SUB) '' '' Slower non-API function you can use to copy array data ''******************************************************************************* 'Private Sub CopyBytesASP(bytDest() As Byte, _ ' lDestStart As Long, _ ' bytSource() As Byte, _ ' lSourceStart As Long, _ ' lLength As Long) ' Dim lCount As Long ' ' lCount = 0 ' Do ' bytDest(lDestStart + lCount) = bytSource(lSourceStart + lCount) ' lCount = lCount + 1 ' Loop Until lCount = lLength 'End Sub '******************************************************************************* ' IsInitialized (FUNCTION) '******************************************************************************* Private Function IsInitialized(ByRef vArray As Variant) As Boolean On Error Resume Next IsInitialized = IsNumeric(UBound(vArray)) End Function '******************************************************************************* ' EncryptData (FUNCTION) ' ' Takes the message, whatever the size, and password in one call and does ' everything for you to return an encoded/encrypted message '******************************************************************************* Public Function EncryptData(bytMessage() As Byte, _ bytPassword() As Byte) As Byte() Dim bytKey(31) As Byte Dim bytIn() As Byte Dim bytOut() As Byte Dim bytTemp(31) As Byte Dim lCount As Long Dim lLength As Long Dim lEncodedLength As Long Dim bytLen(3) As Byte Dim lPosition As Long If Not IsInitialized(bytMessage) Then Exit Function End If If Not IsInitialized(bytPassword) Then Exit Function End If ' Use first 32 bytes of the password for the key For lCount = 0 To UBound(bytPassword) bytKey(lCount) = bytPassword(lCount) If lCount = 31 Then Exit For End If Next ' Prepare the key; assume 256 bit block and key size gentables gkey 8, 8, bytKey ' We are going to put the message size on the front of the message ' in the first 4 bytes. If the length is more than a max int we are ' in trouble lLength = UBound(bytMessage) + 1 lEncodedLength = lLength + 4 ' The encoded length includes the 4 bytes stuffed on the front

75

747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822

' and is padded out to be modulus 32 If lEncodedLength Mod 32 <> 0 Then lEncodedLength = lEncodedLength + 32 - (lEncodedLength Mod 32) End If ReDim bytIn(lEncodedLength - 1) ReDim bytOut(lEncodedLength - 1) ' Put the length on the front '* Unpack lLength, bytIn CopyMemory VarPtr(bytIn(0)), VarPtr(lLength), 4 ' Put the rest of the message after it '* CopyBytesASP bytIn, 4, bytMessage, 0, lLength CopyMemory VarPtr(bytIn(4)), VarPtr(bytMessage(0)), lLength ' Encrypt a block at a time For lCount = 0 To lEncodedLength - 1 Step 32 '* CopyBytesASP bytTemp, 0, bytIn, lCount, 32 CopyMemory VarPtr(bytTemp(0)), VarPtr(bytIn(lCount)), 32 Encrypt bytTemp '* CopyBytesASP bytOut, lCount, bytTemp, 0, 32 CopyMemory VarPtr(bytOut(lCount)), VarPtr(bytTemp(0)), 32 Next EncryptData = bytOut End Function '******************************************************************************* ' DecryptData (FUNCTION) ' ' Opposite of Encryptdata '******************************************************************************* Public Function DecryptData(bytIn() As Byte, _ bytPassword() As Byte) As Byte() Dim bytMessage() As Byte Dim bytKey(31) As Byte Dim bytOut() As Byte Dim bytTemp(31) As Byte Dim lCount As Long Dim lLength As Long Dim lEncodedLength As Long Dim bytLen(3) As Byte Dim lPosition As Long If Not IsInitialized(bytIn) Then Exit Function End If If Not IsInitialized(bytPassword) Then Exit Function End If lEncodedLength = UBound(bytIn) + 1 If lEncodedLength Mod 32 <> 0 Then Exit Function End If ' Use first 32 bytes of the password for the key For lCount = 0 To UBound(bytPassword) bytKey(lCount) = bytPassword(lCount) If lCount = 31 Then Exit For End If Next ' Prepare the key; assume 256 bit block and key size gentables gkey 8, 8, bytKey ' The output array needs to be the same size as the input array ReDim bytOut(lEncodedLength - 1) ' Decrypt a block at a time For lCount = 0 To lEncodedLength - 1 Step 32 '* CopyBytesASP bytTemp, 0, bytIn, lCount, 32 CopyMemory VarPtr(bytTemp(0)), VarPtr(bytIn(lCount)), 32 Decrypt bytTemp

76

823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842

'* CopyBytesASP bytOut, lCount, bytTemp, 0, 32 CopyMemory VarPtr(bytOut(lCount)), VarPtr(bytTemp(0)), 32 Next ' Get the original length of the string from the first 4 bytes '* lLength = Pack(bytOut) CopyMemory VarPtr(lLength), VarPtr(bytOut(0)), 4 ' Make sure the length is consistent with our data If lLength > lEncodedLength - 4 Then Exit Function End If ' Prepare the output message byte array ReDim bytMessage(lLength - 1) '* CopyBytesASP bytMessage, 0, bytOut, 4, lLength CopyMemory VarPtr(bytMessage(0)), VarPtr(bytOut(4)), lLength DecryptData = bytMessage End Function

The modules of Futronic fingerprint in Building Security System FP_BiOpers.bas Control of Futronic fingerprint scanner
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 Public Const INVALID_HANDLE_VALUE = -1 Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (Var() As Any) As Long Declare Function VarPtr Lib "msvbvm60.dll" (Var As Any) As Long Public Declare Function MessageBeep Lib "user32" (ByVal wType As Long) As Long Public Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long Public LastSignal As Long Dim i As Integer

' ' cbControl - user's callback function for control the enrollment or ' verification execution flow. ' Argument list: ' usrContext (input) - user-defined context information; ' StateMask (input) - a bit mask indicating what arguments are provided; ' pResponse (output) - API function execution control is achieved through ' this value; ' Signal (input) - this signal should be used to interact with a user; ' pBitmap (input) - a pointer to the bitmap to be displayed. ' Sub cbControl(ByVal usrContext As Byte, ByVal StateMask As Long, ByVal pResponse As Long, _ ByVal Signal As Long, ByRef pBitmap As FTR_BITMAP) ' frame show If (StateMask And FTR_STATE_FRAME_PROVIDED) = FTR_STATE_FRAME_PROVIDED Then UpdateImage (pBitmap.ftrBitmap.pData) End If ' message print If (StateMask And FTR_STATE_SIGNAL_PROVIDED) = FTR_STATE_SIGNAL_PROVIDED Then If Signal <> LastSignal Then Select Case Signal Case FTR_SIGNAL_TOUCH_SENSOR 'Demo.messagebox.Caption = "Put your finger on the scaner" i = i + 1 V_Mode.FingerImage.Picture = V_Mode.FingerImageList.ListImages(i).Picture UpdateWindow V_Mode.hwnd Case FTR_SIGNAL_TAKE_OFF 'Demo.messagebox.Caption = "Take off your finger from the scaner" i = i + 1 V_Mode.FingerImage.Picture = V_Mode.FingerImageList.ListImages(i).Picture UpdateWindow V_Mode.hwnd

77

46 47 48 49 50 51 52 53 54 55 56 57 58 59

End Select LastSignal = Signal End If End If pResponse = FTR_CONTINUE 'reset the index of FingerImageList If (i = 6) Then i = 0 End If

End Sub

FP_DataBase.bas It is used to save the fingerprint template to drive and insert record to database.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (Destination As Any, Source As Any, ByVal Length As Long) ' ' AddRecord - add new record to database. ' Argument list: ' data - pointer of data for store; ' dLen - size of data. Function AddFinger(data As Long, dLen As Long, path As String, filename As String) As Boolean Dim key As String * 16 key = "tester" ' write "DB record" LBound FPName = path & filename & ".tml" Open FPName For Binary Access Write As #1 Put #1, , dLen Put #1, , key Dim DataArr() As Byte ReDim DataArr(dLen) Call CopyMemory(DataArr(0), ByVal data, dLen) Put #1, , DataArr Close #1 End Function

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

FP_SDK_API.bas It stores the API of Futronic fingerprint

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Futronic SDK types ' ' Generic byte data. Type FTR_DATA dwSize As Long pData As Long End Type

' Length of data in bytes. ' Data pointer.

' Futronic SDK image data Type FTR_BITMAP ftrWidth As Long ' width in pixels ftrHeight As Long ' height in pixels ftrBitmap As FTR_DATA ' bitmap as FTR_DATA type End Type ' Array of identify records Type FTR_IDENTIFY_ARRAY TotalNumber As Long ' number of FTR_IDENTIFY_RECORD pMembers As Long ' pointer on FTR_IDENTIFY_RECORD type

78

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97

End Type ' Identify record description Type FTR_IDENTIFY_RECORD KeyValue As String * 16 ' external key pData As Long ' pointer on FTR_DATA type End Type ' Match record description Type FTR_MATCHED_RECORD KeyValue As String * 16 ' external key FarAttained As Long End Type ' Array of match records Type FTR_MATCHED_ARRAY TotalNumber As Long pMembers As Long End Type

' number of FTR_MATCHED_RECORD ' pointer on FTR_MATCHED_RECORD

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Futronic SDK constants ' ' Return code values. Public Const FTR_RETCODE_ERROR_BASE As Integer = 1 Public Const FTR_RETCODE_DEVICE_BASE As Integer = 200 codes. Public Const FTR_RETCODE_OK As Integer = 0 Public Public Public Public Public Public Public Public Public Public Public Public Const Const Const Const Const Const Const Const Const Const Const Const

' Base value for the error codes. ' Base value for the device error

' Successful function completion.

FTR_RETCODE_NO_MEMORY As Integer = FTR_RETCODE_ERROR_BASE + 1 FTR_RETCODE_INVALID_ARG As Integer = FTR_RETCODE_ERROR_BASE + 2 FTR_RETCODE_ALREADY_IN_USE As Integer = FTR_RETCODE_ERROR_BASE + 3 FTR_RETCODE_INVALID_PURPOSE As Integer = FTR_RETCODE_ERROR_BASE + 4 FTR_RETCODE_INTERNAL_ERROR As Integer = FTR_RETCODE_ERROR_BASE + 5 FTR_RETCODE_UNABLE_TO_CAPTURE As Integer = FTR_RETCODE_ERROR_BASE + 6 FTR_RETCODE_CANCELED_BY_USER As Integer = FTR_RETCODE_ERROR_BASE + 7 FTR_RETCODE_NO_MORE_RETRIES As Integer = FTR_RETCODE_ERROR_BASE + 8 FTR_RETCODE_FRAME_SOURCE_NOT_SET As Integer = FTR_RETCODE_DEVICE_BASE + 1 FTR_RETCODE_DEVICE_NOT_CONNECTED As Integer = FTR_RETCODE_DEVICE_BASE + 2 FTR_RETCODE_DEVICE_FAILURE As Integer = FTR_RETCODE_DEVICE_BASE + 3 FTR_RETCODE_EMPTY_FRAME As Integer = FTR_RETCODE_DEVICE_BASE + 4

' Values used for the parameter definition (FTRSetParam and FTRGetParam). Public Const FTR_PARAM_IMAGE_WIDTH As Long = 1 Public Const FTR_PARAM_IMAGE_HEIGHT As Long = 2 Public Const FTR_PARAM_IMAGE_SIZE As Long = 3 Public Const FTR_PARAM_CB_FRAME_SOURCE As Long = 4 Public Const FTR_PARAM_CB_CONTROL As Long = 5 Public Const FTR_PARAM_MAX_TEMPLATE_SIZE As Long = 6 Public Const FTR_PARAM_MAX_FAR_REQUESTED As Long = 7 Public Const FTR_PARAM_MAX_MODELS As Long = 10 ' Available frame sources. These device identifiers are intended to be used ' with the FTR_PARAM_CB_FRAME_SOURCE parameter. Public Const FSD_FUTRONIC_USB As Long = 1 ' Futronic USB Fingerprint Scanner Device. ' ' User callback function definitions ' ' State bit mask values for user callback function. Public Const FTR_STATE_FRAME_PROVIDED As Long = 1 Public Const FTR_STATE_SIGNAL_PROVIDED As Long = 2 ' Signal values. Public Const FTR_SIGNAL_UNDEFINED As Long = 0 Public Const FTR_SIGNAL_TOUCH_SENSOR As Long = 1 Public Const FTR_SIGNAL_TAKE_OFF As Long = 2 ' Response values Public Const FTR_CANCEL As Long = 1 Public Const FTR_CONTINUE As Long = 2 ' Values used for the purpose definition Public Const FTR_PURPOSE_IDENTIFY As Long = 2

79

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123

Public Const FTR_PURPOSE_ENROLL As Long = 3

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Futronic SDK function prototypes ' Declare Function FTRInitialize Lib "FtrAPI.DLL" () As Integer Declare Function FTRTerminate Lib "FtrAPI.DLL" () As Integer Declare Function FTRSetParam Lib "FtrAPI.DLL" _ (ByVal Param As Long, ByVal value As Any) As Integer Declare Function FTRGetParam Lib "FtrAPI.DLL" _ (ByVal Param As Long, ByRef value As Any) As Integer Declare Function FTRCaptureFrame Lib "FtrAPI.DLL" _ (ByVal usrContext As Any, ByRef pFrameBuf As Any) As Integer Declare Function FTREnroll Lib "FtrAPI.DLL" _ (ByVal usrContext As Any, ByVal Purpose As Long, ByRef pTemplate As FTR_DATA) As Integer Declare Function FTRVerify Lib "FtrAPI.DLL" _ (ByVal usrContext As Any, ByRef pTemplate As FTR_DATA, ByRef pResult As Boolean, _ ByRef pFARVerify As Long) As Integer Declare Function FTRSetBaseTemplate Lib "FtrAPI.DLL" _ (ByRef pTemplate As FTR_DATA) As Integer Declare Function FTRIdentify Lib "FtrAPI.DLL" _ (ByRef pAIdent As FTR_IDENTIFY_ARRAY, ByRef pdwMatchCnt As Long, _ ByRef pAMatch As FTR_MATCHED_ARRAY) As Long

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

FP_ViewWnd.bas It is used for create the area to show fingerprint image.


Const Const Const Const Const Const Const Const Const WM_PAINT = &HF WM_ERASEBKGND = &H14 WM_DESTROY = &H2 COLOR_WINDOWTEXT = 8 WS_CHILD = &H40000000 WS_VISIBLE = &H10000000 WS_EX_DLGMODALFRAME = &H1& BI_RGB = 0& DIB_RGB_COLORS = 0 ' color table in RGBs

Public Public Public Public Public Public Public Public Public

Public Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Public Type PAINTSTRUCT hdc As Long fErase As Long rcPaint As RECT fRestore As Long fIncUpdate As Long rgbReserved(32) As Byte End Type Public Type WNDCLASS style As Long lpfnwndproc As Long cbClsextra As Long cbWndExtra2 As Long hInstance As Long hIcon As Long hCursor As Long hbrBackground As Long lpszMenuName As String lpszClassName As String End Type Public Type RGBQUAD rgbBlue As Byte rgbGreen As Byte rgbRed As Byte rgbReserved As Byte

80

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

End Type Public Type PALETTEENTRY peRed As Byte peGreen As Byte peBlue As Byte peFlags As Byte End Type Public Type LOGPALETTE palVersion As Integer palNumEntries As Integer palPalEntry(255) As PALETTEENTRY End Type Public Type BITMAPINFOHEADER '40 bytes biSize As Long biWidth As Long biHeight As Long biPlanes As Integer biBitCount As Integer biCompression As Long biSizeImage As Long biXPelsPerMeter As Long biYPelsPerMeter As Long biClrUsed As Long biClrImportant As Long End Type Public Type BITMAPINFO bmiHeader As BITMAPINFOHEADER bmiColors As RGBQUAD End Type Public Declare Function BeginPaint Lib "user32" (ByVal hwnd As Long, lpPaint As PAINTSTRUCT) As Long Public Declare Function EndPaint Lib "user32" (ByVal hwnd As Long, lpPaint As PAINTSTRUCT) As Long Public Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Public Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" _ (ByVal hInstance As Long, ByVal lpCursorName As String) As Long Public Declare Function RegisterClass Lib "user32" Alias "RegisterClassA" (ByRef Class As WNDCLASS) As Long Public Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" _ (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, _ ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _ ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, _ ByVal hInstance As Long, lpParam As Any) As Long Public Declare Function CreatePalette Lib "gdi32" (lpLogPalette As LOGPALETTE) As Long Public Declare Function SelectPalette Lib "gdi32" (ByVal hdc As Long, _ ByVal hPalette As Long, ByVal bForceBackground As Long) As Long Public Declare Function RealizePalette Lib "gdi32" (ByVal hdc As Long) As Long Public Declare Function SetDIBitsToDevice Lib "gdi32" _ (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, _ ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, ByVal NumScans As Long, _ Bits As Any, BitsInfo As Any, ByVal wUsage As Long) As Long Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long

81

113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Application data ' Public Const szShowClassName As String = "ShowWndClass" Public hSWnd As Long Public w_SWnd As Long Public h_SWnd As Long Public Public Public Public ' show window handle ' width of show window ' heigth of show window

lpDIBHeader() As Byte lpDIBData() As Byte lpPolLitra As LOGPALETTE hPGrayscale As Long

' ' UpdateImage - updates data and shows the current fingerprint image. ' Argument list: ' srcData - new fingerprint image. ' Sub UpdateImage(ByVal srcData As Long) Dim iCyc As Long Dim hdc As Long ' rotate an image while copying data to the DIB data For iCyc = 0 To h_SWnd - 1 Call CopyMemory(lpDIBData((h_SWnd - iCyc - 1) * w_SWnd), _ ByVal (srcData + iCyc * w_SWnd), w_SWnd) Next iCyc ' show the fingerprint image hdc = GetDC(hSWnd) DIBShow (hdc) Call ReleaseDC(hSWnd, hdc) End Sub

' ' DIBShow - shows the captured fingerprint image. ' Argument list: ' hdc - show window device context. ' Sub DIBShow(ByVal hdc As Long) Call SelectPalette(hdc, hPGrayscale, 0) Call RealizePalette(hdc) Call SetDIBitsToDevice(hdc, 0, 0, w_SWnd, h_SWnd, _ 0, 0, 0, h_SWnd, lpDIBData(0), lpDIBHeader(0), DIB_RGB_COLORS) End Sub ' ' PrepareView - allocates memory & initializes data for fingerprint viewing. ' Argument list: ' w, h, d - width, height and color depth of fingerprint image. ' Return value: ' True - success; ' False - error. ' Function PrepareView(w As Long, h As Long, d As Integer) As Boolean Dim dib_BMInfo As BITMAPINFO Dim dib_bmiColors(255) As RGBQUAD Dim iCyc As Long ' support the 256-colors DIB only If d <> 8 Then PrepareView = False Exit Function End If ' allocate memory for DIB image ReDim lpDIBHeader(Len(dib_BMInfo) + Len(dib_BMInfo.bmiColors) * 255)

82

189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264

ReDim lpDIBData(w * h) ' fill the DIB header dib_BMInfo.bmiHeader.biSize = Len(dib_BMInfo.bmiHeader) dib_BMInfo.bmiHeader.biWidth = w dib_BMInfo.bmiHeader.biHeight = h dib_BMInfo.bmiHeader.biPlanes = 1 dib_BMInfo.bmiHeader.biBitCount = d dib_BMInfo.bmiHeader.biCompression = BI_RGB ' fill the logical palette lpPolLitra.palVersion = 768 lpPolLitra.palNumEntries = 256 ' initialize logical and DIB palettes to grayscale For iCyc = 0 To 255 dib_bmiColors(iCyc).rgbBlue = iCyc dib_bmiColors(iCyc).rgbGreen = iCyc dib_bmiColors(iCyc).rgbRed = iCyc lpPolLitra.palPalEntry(iCyc).peBlue = iCyc lpPolLitra.palPalEntry(iCyc).peGreen = iCyc lpPolLitra.palPalEntry(iCyc).peRed = iCyc Next iCyc ' prepare DIB header Call CopyMemory(lpDIBHeader(0), dib_BMInfo.bmiHeader, _ Len(dib_BMInfo.bmiHeader)) Call CopyMemory(lpDIBHeader(40), dib_bmiColors(0), _ Len(dib_bmiColors(0)) * 256) ' create a grayscale palette hPGrayscale = CreatePalette(lpPolLitra) PrepareView = True End Function

' ' GetFunAddr - get function address ' Function GetFunAddr(ByVal lngFnPtr As Long) As Long GetFunAddr = lngFnPtr End Function

' ' ShowWndProc - view window callback function ' Function ShowWndProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, _ ByVal lParam As Long) As Long Dim hdc As Long Dim ps As PAINTSTRUCT Select Case msg Case WM_PAINT hdc = BeginPaint(hwnd, ps) DIBShow (hdc) Call EndPaint(hwnd, ps) Case WM_ERASEBKGND ShowWndProc = 1 Exit Function Case WM_DESTROY ShowWndProc = 0 Exit Function End Select ShowWndProc = DefWindowProc(hwnd, msg, wParam, lParam) End Function

' ' weRegShowWnd - register window class for viewing fingerprint image ' Return value: ' 0 - error while register window class

83

265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318

Function weRegShowWnd() As Long Dim Class As WNDCLASS Class.style = 0 Class.lpfnwndproc = GetFunAddr(AddressOf ShowWndProc) Class.cbClsextra = 0 Class.cbWndExtra2 = 0 Class.hInstance = VB.App.hInstance Class.hIcon = 0 Class.hCursor = 0 Class.hbrBackground = COLOR_WINDOWTEXT + 1 Class.lpszMenuName = Empty Class.lpszClassName = szShowClassName weRegShowWnd = RegisterClass(Class) End Function

' ' CreateShowWnd - create window for viewing fingerprint image ' Argument list: ' hParent - parent window; ' x, y - upper left corner in parent; ' w, h - window's width and height. ' Return value: ' 0 - error creating. ' Function CreateShowWnd(ByVal hParent As Long, ByVal x As Long, ByVal y As Long, _ ByVal w As Long, ByVal h As Long) As Long ' store show window dimension w_SWnd = w h_SWnd = h ' register window class weRegShowWnd ' prepare data for view fingerprint image If PrepareView(w, h, 8) = False Then CreateShowWnd = 0 Exit Function End If ' create show window hSWnd = CreateWindowEx(0, szShowClassName, 0&, WS_CHILD + WS_VISIBLE + WS_EX_DLGMODALFRAME, _ x, y, w, h, hParent, 0, VB.App.hInstance, 0&) CreateShowWnd = hSWnd If hSWnd = 0 Then Exit Function End If UpdateWindow (hParent) End Function

The modules of Administration Tools and Building Security System MySQLADODB.bas It is used to connect the MySQL database.
1 2 3 4 5 6 7 8 9 10 11 12 13 Public conn As New ADODB.Connection Public strServerIP As String Public Function openDBcn() If conn.State = 1 Then conn.Close strServerIP = getContent("serverIP") conn.CursorLocation = adUseClient 'connect MySQL database server conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _

84

14 15 16 17 18 19 20

& "SERVER=" & strServerIP & ";" _ & "DATABASE=ive_fyp;" _ & "UID=ive;" _ & "PWD=ive;" _ & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 163841 conn.Open End Function

ReadINI.bas It is used to read the config.ini file. It is used for create the area to show fingerprint image.
' escape character in Info file ' Set Info file length ' Info Name ' Info Content

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

Option Explicit Public Const strInfoExcapeChr = "#" Public Const intInfoLength = 1024

Public strInfoName(intInfoLength) As String Public strInfoContent(intInfoLength) As String ' Program start function Sub main() Call readInfo(App.path & "\config.ini", False) 'MsgBox getContent("serverIP") Call openDBcn Select_Mode.Show End Sub

Public Sub readInfo(strInfoPath As String, blnReload As Boolean) Dim strLineTmp As String Dim lngAssignPos As Long Dim idxCnt As Long ' Check the Info File var is blank or not If Len(strInfoPath) = 0 Then 'MsgBox() Exit Sub End If ' to Erase the array or not If blnReload Then Erase strInfoName() Erase strInfoContent() strInfoName(0) = "" strInfoContent(0) = "" End If ' Open input file "startCD.inf" Open strInfoPath For Input As #1 idxCnt = -1 While Not EOF(1) Line Input #1, strLineTmp Select Case Left$(strLineTmp, Case strInfoExcapeChr ' Nothing to Do and go Case Chr(13) ' Nothing to Do and go Case Chr(10) ' Nothing to Do and go Case Else idxCnt = idxCnt + 1 1) to next line to next line to next line

lngAssignPos = InStr(1, strLineTmp, "=") 'MsgBox lngAssignPos strInfoName(idxCnt) = Left(strLineTmp, lngAssignPos - 1)

85

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

strInfoContent(idxCnt) = Right(strLineTmp, Len(strLineTmp) - lngAssignPos) 'MsgBox strInfoName(idxCnt) & " - " & strInfoContent(idxCnt) End Select Wend Close #1 'MsgBox strLineTmp End Sub ' Get Information Content string in loaded array with Information Name Public Function getContent(strInformationName As String) Dim i As Integer Dim strFoundContent As String strFoundContent = "" For i = LBound(strInfoName) To UBound(strInfoName) ' Compare the Information Name If strInfoName(i) = strInformationName Then strFoundContent = strInfoContent(i) End If Next i getContent = strFoundContent End Function

The programming codes of form in Administration Tools frmAdmin.frm It is the tools main form.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 Option Dim Dim Dim Dim Explicit RemotePath As String ComputerName As String FolderName As String PhotoName As String

Private Sub cmdHAdd_Click() frmAdd.Show (vbModal) End Sub Private Sub cmdHDelete_Click() Dim intHID As Integer intHID = Mid(lvwHHolder.SelectedItem.key, 4, Len(lvwHHolder.SelectedItem.key) - 3) If lvwHHolder.SelectedItem.Selected Then If MsgBox("Are you sure delete this householder?", vbExclamation + vbYesNo, "Delete Record") = vbYes Then conn.Execute "DELETE FROM fyp_tblHouseHolder WHERE intHolderID = " & intHID & ";" showRecord End If End If End Sub Private Sub cmdHEdit_Click() If SelectedHHID = 0 Then MsgBox "Please select householder to edit.", vbExclamation, "Message" Else frmEdit.Show (vbModal) End If End Sub Private Sub cmdHHLSearch_Click() showRecord End Sub Private Sub cmdHRefresh_Click()

86

37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

'lvwHHolder.Refresh showRecord End Sub Private Sub cmdHSearch_Click() lvwHHolder.ListItems.Clear showRecord End Sub Private Sub cmdVSearch_Click() showRecord End Sub Private Sub Form_Load() ComputerName = strServerIP 'set computer name FolderName = "userdata\visitor" 'set folder name (optional) RemotePath = "\\" & ComputerName & "\" & FolderName & "\" 'set the remote path to store file 'close all frame fraHHolder.Visible = False fraHHolderLog.Visible = False fraVisitorLog.Visible = False 'set all DTPicker date dtpVSelectDay.Value = Format(Now, "dd/mm/yyyy") dtpHHLFrom.Value = Format(Now, "dd/mm/yyyy") dtpHHLTo.Value = Format(Now, "dd/mm/yyyy") End Sub Private Sub lvwHHolder_ItemClick(ByVal Item As MSComctlLib.ListItem) SelectedHHID = Mid(lvwHHolder.SelectedItem.key, 4, Len(lvwHHolder.SelectedItem.key) - 3) End Sub Private Sub lvwVisitor_BeforeLabelEdit(Cancel As Integer) Cancel = 1 End Sub Private Sub lvwVisitor_ItemClick(ByVal Item As MSComctlLib.ListItem) Dim intVID As Integer intVID = Mid(lvwVisitor.SelectedItem.key, 4, Len(lvwVisitor.SelectedItem.key) - 3) Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset rs.Open "SELECT * FROM fyp_tblVisitor WHERE intVisitorID = " & intVID & ";", conn, adOpenStatic, adLockReadOnly imgVPhoto.Picture = LoadPicture(RemotePath & rs!chrFaceData & ".bmp") End Sub Private Sub mnuExit_Click() End End Sub Private Sub mnuHHDB_Click() fraHHolder.Visible = True fraHHolderLog.Visible = False fraVisitorLog.Visible = False showRecord End Sub Private Sub showRecord() Dim rs1 As ADODB.Recordset Dim rs2 As ADODB.Recordset Dim rs3 As ADODB.Recordset Dim Dim Dim Dim strPhotoName As String strBuilding As String strHName As String strHHLName As String

Dim datSelDate As Date

87

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 " _ 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180

Dim datDateFrom As Date Dim datDateTo As Date Dim intHHID As Integer Dim intHHLID As Integer Dim idxVisitor As Long Dim idxHHolder As Long Dim idxHHLog As Long strBuilding = "%" datSelDate = dtpVSelectDay.Value datDateFrom = dtpHHLFrom.Value datDateTo = dtpHHLTo.Value If cboBuilding.Text <> "All" Then strBuilding = cboBuilding.Text 'msgBox strBuilding End If strHName = "%" If txtHHName.Text <> "" Then strHName = txtHHName.Text End If intHHID = 0 If txtHHID.Text <> "" Then intHHID = Val(txtHHID.Text) strHName = "" End If strHHLName = "" If txtHHLName.Text <> "" Then strHHLName = txtHHLName.Text End If intHHLID = 0 If txtHHLID.Text <> "" Then intHHLID = Val(txtHHLID.Text) strHHLName = "" End If Set rs1 = New ADODB.Recordset rs1.Open "SELECT * FROM fyp_tblHouseholder h, fyp_tblBuilding b, fyp_tblFloorFlat f & "WHERE (b.intBuildingID = h.intBuildingID AND f.intFFID = h.intFFID) AND " _ & "(h.intHolderID = " & intHHID & " OR " _ & "h.chrHolderName LIKE '" & strHName & "') ORDER BY intHolderID ASC;", conn, adOpenStatic, adLockReadOnly lvwHHolder.ListItems.Clear idxHHolder = 0 While Not rs1.EOF idxHHolder = idxHHolder + 1 lvwHHolder.ListItems.Add idxHHolder, "hID" & rs1("intHolderID"), rs1("intHolderID") lvwHHolder.ListItems.Item(idxHHolder).ListSubItems.Add 1, , rs1("chrHolderName") lvwHHolder.ListItems.Item(idxHHolder).ListSubItems.Add 2, , rs1("chrGender") lvwHHolder.ListItems.Item(idxHHolder).ListSubItems.Add 3, , rs1("datBirth") lvwHHolder.ListItems.Item(idxHHolder).ListSubItems.Add 4, , rs1("chrHKID") lvwHHolder.ListItems.Item(idxHHolder).ListSubItems.Add 5, , rs1("datRegDate") lvwHHolder.ListItems.Item(idxHHolder).ListSubItems.Add 6, , rs1("chrBuildingName") lvwHHolder.ListItems.Item(idxHHolder).ListSubItems.Add 7, , rs1("chrFloor") & rs1("chrFlat") lvwHHolder.Refresh rs1.MoveNext Wend Set rs2 = New ADODB.Recordset rs2.Open "SELECT v.intVisitorID, v.datEntry, b.chrBuildingName, " _ & "CONCAT(f.chrFloor, f.chrFlat) AS 'Flat', v.chrFaceData, v.chrFingerData " _ & "FROM fyp_tblVisitor v, fyp_tblBuilding b, fyp_tblFloorFlat f " _ & "WHERE b.intBuildingID = v.intBuildingID AND f.intFFID = v.intFFID AND " _

88

181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248

& "b.chrBuildingName LIKE '" & strBuilding & "' AND " _ & "(v.datEntry >= '" & Format(datSelDate, "yyyy-mm-dd") & " 00:00:00' AND " _ & "v.datEntry <= '" & Format(datSelDate, "yyyy-mm-dd") & " 23:59:59');", conn, adOpenStatic, adLockReadOnly lvwVisitor.ListItems.Clear idxVisitor = 0 While Not rs2.EOF idxVisitor = idxVisitor + 1 lvwVisitor.ListItems.Add idxVisitor, "vID" & rs2("intVisitorID"), rs2("intVisitorID") lvwVisitor.ListItems.Item(idxVisitor).ListSubItems.Add 1, , rs2("datEntry") lvwVisitor.ListItems.Item(idxVisitor).ListSubItems.Add 2, , rs2("chrBuildingName") lvwVisitor.ListItems.Item(idxVisitor).ListSubItems.Add 3, , rs2("Flat") lvwVisitor.Refresh rs2.MoveNext Wend Set rs3 = New ADODB.Recordset Clipboard.SetText "SELECT * FROM fyp_tblHolderLog l, fyp_tblHouseHolder h " _ & "WHERE l.intHolderID = h.intHolderID AND " _ & "(l.intHolderID = " & intHHLID & " OR h.chrHolderName LIKE '" & strHHLName & "' OR" _ & "(l.datInTime >= '" & Format(datDateFrom, "yyyy-mm-dd") & " 00:00:00' AND " _ & "l.datInTime <= '" & Format(datDateTo, "yyyy-mm-dd") & " 23:59:59'));" rs3.Open "SELECT * FROM fyp_tblHolderLog l, fyp_tblHouseHolder h " _ & "WHERE l.intHolderID = h.intHolderID AND " _ & "(l.intHolderID = " & intHHLID & " OR h.chrHolderName LIKE '" & strHHLName & "') AND " _ & "(l.datInTime >= '" & Format(datDateFrom, "yyyy-mm-dd") & " 00:00:00' AND " _ & "l.datInTime <= '" & Format(datDateTo, "yyyy-mm-dd") & " 23:59:59');", conn, adOpenStatic, adLockReadOnly lvwHHLog.ListItems.Clear idxHHLog = 0 While Not rs3.EOF idxHHLog = idxHHLog + 1 lvwHHLog.ListItems.Add idxHHLog, "lID" & rs3("intLogID"), rs3("intHolderID") lvwHHLog.ListItems.Item(idxHHLog).ListSubItems.Add 1, , rs3("chrHolderName") lvwHHLog.ListItems.Item(idxHHLog).ListSubItems.Add 2, , rs3("datInTime") lvwHHLog.Refresh rs3.MoveNext Wend End Sub Private Sub mnuHHLog_Click() fraHHolderLog.Visible = True fraHHolder.Visible = False fraVisitorLog.Visible = False End Sub Private Sub mnuVLog_Click() fraVisitorLog.Visible = True fraHHolder.Visible = False fraHHolderLog.Visible = False Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset rs.Open "SELECT * FROM fyp_tblbuilding;", conn, adOpenStatic, adLockReadOnly cboBuilding.Clear cboBuilding.AddItem "All" cboBuilding.Text = "All" While Not rs.EOF

89

249 250 251 252 253 254 255

cboBuilding.AddItem rs("chrBuildingName") rs.MoveNext Wend End Sub

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

frmAdd.frm It is a form of add new householder.


Explicit RemotePath As String ComputerName As String FolderName As String AESFilename As String

Option Dim Dim Dim Dim

Private Sub cmdClose_Click() Unload Me End Sub Private Sub cmdEnroll_Click() 'start the capture timer tmrStartCap.Interval = 3000 tmrStartCap.Enabled = True End Sub Private Sub cmdSave_Click() If AESFilename = "" Then MsgBox "Please enroll the face.", vbCritical, "Message" Else AddHHolder End If End Sub Private Sub cmdStartCam_Click() InitiateCam cmdEnroll.Enabled = True End Sub Private Sub cmdStopCam_Click() UninitiateCam cmdEnroll.Enabled = False End Sub Private Sub Form_Load() ComputerName = strServerIP 'set computer name FolderName = "userdata\householder" 'set folder name (optional) RemotePath = "\\" & ComputerName & "\" & FolderName & "\" 'set the remote path to store file 'set the maxlength of all textbox txtName.MaxLength = 255 txtYear.MaxLength = 4 txtMonth.MaxLength = 2 txtDay.MaxLength = 2 txtHKID1.MaxLength = 2 txtHKID2.MaxLength = 6 txtHKID3.MaxLength = 1 'reset all combo box cboGender.Text = cboGender.List(0) cboBuilding.Text = cboBuilding.List(0) cboFloor.Text = cboFloor.List(0) cboFlat.Text = cboFlat.List(0) cmdEnroll.Enabled = False tmrStartCap.Enabled = False 'MsgBox "Please enroll the face first.", vbInformation, "Message" End Sub Private Sub InitiateCam()

90

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134

'Initiate the webcam Webcam.SetSizeType 1 Webcam.SetEyeThreshold 180000 Webcam.SetThreshold 80000 Webcam.InitSmartGate Webcam.Show picCamMask.Visible = False End Sub Private Sub UninitiateCam() 'Uninitiate the webcam Webcam.Unshow Webcam.UninitSmartGate picCamMask.Visible = True End Sub Private Sub Form_Unload(Cancel As Integer) UninitiateCam End Sub Private Sub GenName() Dim AESKey As CRijndael Dim plainText() As Byte Dim encText() As Byte Dim encPassword() As Byte Dim lCount As Long Dim lLength As Long Set AESKey = New CRijndael 'set AESKey from class modules

plainText = Format(Now, "yymmddhhmmss") encPassword = "" 'default no password encText = AESKey.EncryptData(plainText, encPassword) AESFilename = "" For lCount = 0 To UBound(encText) AESFilename = AESFilename & Right("0" & Hex(encText(lCount)), 2) Next End Sub Private Sub tmrStartCap_Timer() GenName 'generate the filename to AES format If (Webcam.SaveToBmpImageT(RemotePath & AESFilename & ".bmp", 320, 240)) Then 'save bitmap from camera Webcam.AppendData RemotePath & AESFilename & ".bmp", RemotePath & AESFilename & ".usr" 'save the template file from bitmap MsgBox "Face Enrollment Successful!", vbInformation, "Face Enrollment" Else MsgBox "Face Enrollment Failed!\nPlease try again!", vbCritical, "Face Enrollment" End If 'stop the timer after 3 seconds If tmrStartCap.Interval = 3000 Then tmrStartCap.Enabled = False End If End Sub Private Sub AddHHolder() Dim rs1 As ADODB.Recordset Dim rs2 As ADODB.Recordset Dim datBirth As Date Dim strHKID As String Set rs1 = New ADODB.Recordset rs1.Open "SELECT intBuildingID FROM fyp_tblBuilding WHERE chrBuildingName LIKE '" & cboBuilding.Text & "';", conn, adOpenStatic, adLockReadOnly Set rs2 = New ADODB.Recordset rs2.Open "SELECT intFFID FROM fyp_tblFloorFlat WHERE chrFloor = '" & cboFloor.Text & "' AND chrFlat = '" & cboFlat.Text & "';", conn, adOpenStatic, adLockReadOnly datBirth = txtYear.Text & "/" & txtMonth.Text & "/" & txtDay.Text strHKID = UCase(txtHKID1.Text) & txtHKID2.Text & "(" & txtHKID3.Text & ")" 'insert visitor record

91

135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

conn.Execute "INSERT INTO fyp_tblHouseHolder VALUES ('', '" & txtName.Text & "', '" & cboGender.Text & "', '" & Format(datBirth, "YYYY-MM-DD") & "', '" _ & strHKID & "', '" & Format(Now, "YYYY-MM-DD HH:MM:SS") & "', '" & AESFilename & "', '" & rs1!intBuildingID & "', " & rs2!intFFID & ");", , adExecuteNoRecords rs1.Close Set rs1 = Nothing rs2.Close Set rs2 = Nothing MsgBox "Success to save the householder in database", vbInformation, "Save New Householder" 'reset all AESFilename = "" txtName.Text = "" txtYear.Text = "" txtMonth.Text = "" txtDay.Text = "" txtHKID1.Text = "" txtHKID2.Text = "" txtHKID3.Text = "" cboGender.Text = cboGender.List(0) cboBuilding.Text = cboBuilding.List(0) cboFloor.Text = cboFloor.List(0) cboFlat.Text = cboFlat.List(0) UninitiateCam cmdEnroll.Enabled = False End Sub

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

frmEdit.frm It is a form of edit selected householder.


Explicit RemotePath As String ComputerName As String FolderName As String AESFilename As String HHID As Integer

Option Dim Dim Dim Dim Dim

Private Sub cmdClose_Click() Unload Me End Sub Private Sub cmdEnroll_Click() 'start the capture timer tmrStartCap.Interval = 3000 tmrStartCap.Enabled = True End Sub Private Sub cmdSave_Click() UpdateHHolder End Sub Private Sub cmdStartCam_Click() InitiateCam cmdEnroll.Enabled = True End Sub Private Sub cmdStopCam_Click() UninitiateCam cmdEnroll.Enabled = False End Sub Private Sub Form_Load() Dim strBirth As String ComputerName = strServerIP 'set computer name FolderName = "userdata\householder" 'set folder name (optional)

92

37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

RemotePath = "\\" & ComputerName & "\" & FolderName & "\" file

'set the remote path to store

'find the householder id and put data in textbox and combobox HHID = SelectedHHID Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset rs.Open "SELECT * FROM fyp_tblHouseHolder h, fyp_tblFloorFlat f WHERE h.intHolderID = " & HHID & " AND f.intFFID = h.intFFID;", conn, adOpenStatic, adLockReadOnly strBirth = Format(rs!datBirth, "yyyy-mm-dd") AESFilename = rs!chrUserData 'format the strBirth easy to read

txtName.Text = rs!chrHolderName txtYear.Text = Left(strBirth, 4) txtMonth.Text = Mid(strBirth, 6, 2) txtDay.Text = Right(strBirth, 2) txtHKID1.Text = Mid(rs!chrHKID, 1, 1) txtHKID2.Text = Mid(rs!chrHKID, 2, 6) txtHKID3.Text = Mid(rs!chrHKID, 9, 1) If (rs!chrGender = "M") Then cboGender.Text = cboGender.List(0) ElseIf (rs!chrGender = "F") Then cboGender.Text = cboGender.List(1) End If cboBuilding.Text = cboBuilding.List(Val(rs!intBuildingID) - 1) cboFloor.Text = cboFloor.List(Val(rs!chrFloor) - 1) cboFlat.Text = cboFlat.List(Asc(rs!chrFlat) - 65) 'disable some textbox to prevent modify txtName.Enabled = False txtYear.Enabled = False txtMonth.Enabled = False txtDay.Enabled = False txtHKID1.Enabled = False txtHKID2.Enabled = False txtHKID3.Enabled = False cboGender.Enabled = False 'set the maxlength of all textbox txtName.MaxLength = 255 txtYear.MaxLength = 4 txtMonth.MaxLength = 2 txtDay.MaxLength = 2 txtHKID1.MaxLength = 2 txtHKID2.MaxLength = 6 txtHKID3.MaxLength = 1 cmdEnroll.Enabled = False tmrStartCap.Enabled = False picHolderImage.Picture = LoadPicture(RemotePath & rs!chrUserData & ".bmp") previous enrolled pic 'MsgBox "Please enroll the face first.", vbInformation, "Message" End Sub Private Sub InitiateCam() 'Initiate the webcam Webcam.SetSizeType 1 Webcam.SetEyeThreshold 180000 Webcam.SetThreshold 80000 Webcam.InitSmartGate Webcam.Show picHolderImage.Visible = False picCamMask.Visible = False End Sub Private Sub UninitiateCam() 'Uninitiate the webcam Webcam.Unshow Webcam.UninitSmartGate picCamMask.Visible = True End Sub 'load the

93

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178

Private Sub Form_Unload(Cancel As Integer) UninitiateCam End Sub Private Sub GenName() Dim AESKey As CRijndael Dim plainText() As Byte Dim encText() As Byte Dim encPassword() As Byte Dim lCount As Long Dim lLength As Long Set AESKey = New CRijndael 'set AESKey from class modules

plainText = Format(Now, "yymmddhhmmss") encPassword = "" 'default no password encText = AESKey.EncryptData(plainText, encPassword) AESFilename = "" For lCount = 0 To UBound(encText) AESFilename = AESFilename & Right("0" & Hex(encText(lCount)), 2) Next End Sub Private Sub tmrStartCap_Timer() GenName 'generate the filename to AES format If (Webcam.SaveToBmpImageT(RemotePath & AESFilename & ".bmp", 320, 240)) Then 'save bitmap from camera Webcam.AppendData RemotePath & AESFilename & ".bmp", RemotePath & AESFilename & ".usr" 'save the template file from bitmap MsgBox "Face Enrollment Successful!", vbInformation, "Face Enrollment" Else MsgBox "Face Enrollment Failed!\nPlease try again!", vbCritical, "Face Enrollment" End If 'stop the timer after 3 seconds If tmrStartCap.Interval = 3000 Then tmrStartCap.Enabled = False End If End Sub Private Sub UpdateHHolder() Dim rs1 As ADODB.Recordset Dim rs2 As ADODB.Recordset Set rs1 = New ADODB.Recordset rs1.Open "SELECT intBuildingID FROM fyp_tblBuilding WHERE chrBuildingName LIKE '" & cboBuilding.Text & "';", conn, adOpenStatic, adLockReadOnly Set rs2 = New ADODB.Recordset rs2.Open "SELECT intFFID FROM fyp_tblFloorFlat WHERE chrFloor = '" & cboFloor.Text & "' AND chrFlat = '" & cboFlat.Text & "';", conn, adOpenStatic, adLockReadOnly conn.Execute "UPDATE fyp_tblHouseHolder SET datRegDate = '" & Format(Now, "YYYY-MM-DD") & "', intBuildingID = " & rs1!intBuildingID & _ ", intFFID = " & rs2!intFFID & ", chrUserData = '" & AESFilename & "' WHERE intHolderID = " & HHID & ";" rs1.Close Set rs1 = Nothing rs2.Close Set rs2 = Nothing MsgBox "Successful update householder detail in database.", vbInformation, "Update Householder" End Sub

Private Sub AddHHolder() Dim rs1 As ADODB.Recordset Dim rs2 As ADODB.Recordset Dim datBirth As Date Dim strHKID As String

94

179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219

Set rs1 = New ADODB.Recordset rs1.Open "SELECT intBuildingID FROM fyp_tblBuilding WHERE chrBuildingName LIKE '" & cboBuilding.Text & "';", conn, adOpenStatic, adLockReadOnly Set rs2 = New ADODB.Recordset rs2.Open "SELECT intFFID FROM fyp_tblFloorFlat WHERE chrFloor = '" & cboFloor.Text & "' AND chrFlat = '" & cboFlat.Text & "';", conn, adOpenStatic, adLockReadOnly datBirth = txtYear.Text & "/" & txtMonth.Text & "/" & txtDay.Text strHKID = UCase(txtHKID1.Text) & txtHKID2.Text & "(" & txtHKID3.Text & ")" 'insert visitor record conn.Execute "INSERT INTO fyp_tblHouseHolder VALUES ('', '" & txtName.Text & "', '" & cboGender.Text & "', '" & Format(datBirth, "YYYY-MM-DD") & "', '" _ & strHKID & "', '" & Format(Now, "YYYY-MM-DD HH:MM:SS") & "', '" & AESFilename & "', '" & rs1!intBuildingID & "', " & rs2!intFFID & ");", , adExecuteNoRecords rs1.Close Set rs1 = Nothing rs2.Close Set rs2 = Nothing MsgBox "Success to save the householder in database.", vbInformation, "Save New Householder" 'reset all AESFilename = "" txtName.Text = "" txtYear.Text = "" txtMonth.Text = "" txtDay.Text = "" txtHKID1.Text = "" txtHKID2.Text = "" txtHKID3.Text = "" cboGender.Text = cboGender.List(0) cboBuilding.Text = cboBuilding.List(0) cboFloor.Text = cboFloor.List(0) cboFlat.Text = cboFlat.List(0) UninitiateCam cmdEnroll.Enabled = False End Sub

The programming codes of form in Building Security System Select_Mode.frm It is the mode selection form.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Private Sub btnClose_Click() End End Sub Private Sub Form_Load() mode.Movie = App.path & "\interface\select.swf" mode.Play End Sub Private Sub mode_FSCommand(ByVal command As String, ByVal args As String) Select Case command Case "householder" H_Mode.Show Case "visitor" V_Mode.Show End Select End Sub

95


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

H_Mode.frm It is householder mode form.


Explicit RemotePath As String ComputerName As String FolderName As String

Option Dim Dim Dim

Private Sub Form_Load() ComputerName = strServerIP 'set computer name FolderName = "userdata\householder" 'set folder name (optional) RemotePath = "\\" & ComputerName & "\" & FolderName & "\" 'set the remote path to store file 'set the filename of flash and play Interface.Movie = App.path & "\interface\householder.swf" Interface.Play Webcam.Visible = False End Sub Private Sub Form_Unload(Cancel As Integer) 'Unshow and Uninitate the webcam UninitiateCam End Sub Private Sub StartCam_Timer() Webcam.Visible = True 'stop the timer after 2 seconds If StartCam.Interval = 2000 Then StartCam.Enabled = False 'start the capture timer StartCap.Interval = 3000 StartCap.Enabled = True End If End Sub Private Sub StartCap_Timer() SearchUser End Sub Private Sub InitiateCam() 'Initiate the webcam Webcam.SetSizeType 1 Webcam.SetEyeThreshold 180000 Webcam.SetThreshold 80000 Webcam.InitSmartGate Webcam.Show Webcam.Visible = True End Sub Private Sub UninitiateCam() 'Uninitiate the webcam Webcam.Visible = False Webcam.Unshow Webcam.UninitSmartGate End Sub Private Sub SearchUser() Dim rs As ADODB.Recordset Dim success As Boolean Dim aaa As String success = False Set rs = New ADODB.Recordset rs.Open "SELECT intHolderID, chrHolderName, chrUserData FROM fyp_tblHouseHolder;", conn, adOpenStatic, adLockReadOnly Do Until rs.EOF Or success = True

96

71 Then 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

If Webcam.LoadUserData(RemotePath & rs!chrUserData & ".usr", 1) And Webcam.Verify() 'save log of householder in table "fyp_tblHolderLog" conn.Execute "INSERT INTO fyp_tblHolderLog VALUES ('', '" & rs!intHolderID & "', '" & Format(Now, "YYYY-MM-DD HH:MM:SS") & "');", , adExecuteNoRecords success = True 'show successful message box Interface.SetVariable "VBCommand", "identifySuccess" Interface.SetVariable "Username", rs!chrHolderName 'uninitiate the cam when success StartCap.Enabled = False UninitiateCam Else rs.MoveNext End If Loop 'show failed message box when cannot verify If (success = False) Then Interface.SetVariable "VBCommand", "identifyFailed" 'start the capture timer StartCap.Interval = 3000 StartCap.Enabled = True End If rs.Close Set rs = Nothing End Sub Private Sub Interface_FSCommand(ByVal command As String, ByVal args As String) Select Case command Case "openCam" InitiateCam 'start the capture timer StartCap.Interval = 3000 StartCap.Enabled = True Case "closeCam" UninitiateCam Case "unload" UnloadForm.Interval = 1000 UnloadForm.Enabled = True End Select End Sub Private Sub UnloadForm_Timer() Interface.Stop Unload Me End Sub

1 2 3 4 5 6 7 8 9 10 11 12 13 14

V_Mode.frm It is visitor mode form.


Explicit AESFilename As String FaceName As String FingerName As String RemotePath As String ComputerName As String FolderName As String strFloor As String strFlat As String

Option Dim Dim Dim Dim Dim Dim Dim Dim

Private Sub Enroll_Click() GenName 'generate the filename to AES format Webcam.SaveToBmpImageT RemotePath & AESFilename & ".bmp", 320, 240 'save bitmap from camera Webcam.AppendData RemotePath & AESFilename & ".bmp", RemotePath & AESFilename & ".usr" 'save the template file from bitmap

97

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85

'Insert visitor record in database AddVisitor End Sub Private Sub Form_Load() ComputerName = strServerIP 'set computer name FolderName = "userdata\visitor" 'set folder name (optional) RemotePath = "\\" & ComputerName & "\" & FolderName & "\" 'set the remote path to store file 'set the filename of flash and play Interface.Movie = App.path & "\interface\visitor.swf" Interface.Play Webcam.Visible = False FingerImage.Visible = False End Sub Private Sub Form_Unload(Cancel As Integer) 'Unshow and Uninitate the webcam UninitiateCam 'uninitiate the fingerprint device UninitFinger End Sub Private Sub StartFace_Timer() GenName 'generate the filename to AES format FaceName = AESFilename 'put the generated filename in FaceName If (Webcam.SaveToBmpImageT(RemotePath & FaceName & ".bmp", 320, 240) = True) Then 'save bitmap from camera Webcam.AppendData RemotePath & FaceName & ".bmp", RemotePath & FaceName & ".usr" 'save the template file from bitmap UninitiateCam 'close the cam Interface.SetVariable "VBCommand", "gotoFinger" 'pass the value to flash and run the function End If 'stop the timer after 3 seconds If StartFace.Interval = 3000 Then StartFace.Enabled = False End If End Sub Private Sub GenName() Dim AESKey As CRijndael Dim plainText() As Byte Dim encText() As Byte Dim encPassword() As Byte Dim lCount As Long Dim lLength As Long Set AESKey = New CRijndael 'set AESKey from class modules

plainText = Format(Now, "yymmddhhmmss") encPassword = "" 'default no password encText = AESKey.EncryptData(plainText, encPassword) AESFilename = "" For lCount = 0 To UBound(encText) AESFilename = AESFilename & Right("0" & Hex(encText(lCount)), 2) Next End Sub Private Sub AddVisitor() Dim rs As ADODB.Recordset conn.CursorLocation = adUseClient Set rs = New ADODB.Recordset rs.Open "SELECT intFFID FROM fyp_tblFloorFlat WHERE chrFloor = '" & strFloor & "' AND chrFlat = '" & strFlat & "';", conn, adOpenStatic, adLockReadOnly

98

86 87

'insert visitor record conn.Execute "INSERT INTO fyp_tblVisitor VALUES ('', '" & FaceName & "', '" & FingerName & "', '" & Format(Now, "YYYY-MM-DD HH:MM:SS") & "', 1, " & rs!intFFID & ");", , adExecuteNoRecords rs.Close Set rs = Nothing End Sub Private Sub InitiateCam() 'Initiate the webcam Webcam.SetSizeType 1 Webcam.SetEyeThreshold 180000 Webcam.SetThreshold 80000 Webcam.InitSmartGate Webcam.Show Webcam.Visible = True End Sub Private Sub UninitiateCam() 'Uninitiate the webcam Webcam.Visible = False Webcam.Unshow Webcam.UninitSmartGate End Sub Private Sub Interface_FSCommand(ByVal command As String, ByVal args As String) Select Case command Case "floorflat" strFloor = Left$(args, Len(args) - 1) strFlat = Right$(args, 1) Case "openCam" InitiateCam Case "startFace" StartFace.Interval = 3000 StartFace.Enabled = True Case "startFinger" InitFinger Case "endFinger" FingerImage.Visible = False Case "unload" UnloadForm.Interval = 1000 UnloadForm.Enabled = True End Select End Sub Private Sub InitFinger() Dim TemplateSize As Long Dim lpTemplateBytes() As Byte Dim template As FTR_DATA FingerImage.Visible = True 'initialize Futronic fingerprint SDK FTRInitialize 'set dSDK settings: 'frame source Dim value As Long value = FSD_FUTRONIC_USB FTRSetParam FTR_PARAM_CB_FRAME_SOURCE, value 'user's calbacks FTRSetParam FTR_PARAM_CB_CONTROL, AddressOf cbControl 'FAR setting value = 110000 'default threshold setting FTRSetParam FTR_PARAM_MAX_FAR_REQUESTED, value 'Max Models value = 3 'set the number of times to scan FTRSetParam FTR_PARAM_MAX_MODELS, value 'create the image area for fingerprint bitmap Dim hSWnd As Long

88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

99

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197

hSWnd = CreateShowWnd(V_Mode.hwnd, 460, 100, 320, 400) ' prepare memory for template store FTRGetParam FTR_PARAM_MAX_TEMPLATE_SIZE, TemplateSize ReDim lpTemplateBytes(0 To TemplateSize - 1) ' prepare arguments template.pData = VarPtr(lpTemplateBytes(0)) ' enroll operation FTREnroll 0&, FTR_PURPOSE_ENROLL, template 'generate the filename GenName FingerName = AESFilename ' write template to file If (AddFinger(template.pData, template.dwSize, RemotePath, FingerName)) Then UninitFinger 'uninitiate the fingerprint device End If 'finally, insert visitor record in database AddVisitor 'call flash play movie when the finger success. Interface.SetVariable "VBCommand", "succFinger" End Sub Private Sub UninitFinger() 'uninitialize Futronic fingerprint SDK FTRTerminate End Sub Private Sub UnloadForm_Timer() Interface.Stop Unload Me End Sub

z Programming code of Clubhouse system Clubhouse login system: Project1, Form2


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Private Sub SearchUser() Dim conn As ADODB.Connection Dim success As Boolean Dim tmp As Integer Dim bbq1 As ADODB.Recordset Dim bbq2 As ADODB.Recordset success = False Set conn = New ADODB.Connection conn.CursorLocation = adUseClient 'connect MySQL database server conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=127.0.0.1;" _ & "DATABASE=ive_fyp;" _ & "UID=ive;" _ & "PWD=ive;" _ & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 163841 conn.Open Set bbq1 = New ADODB.Recordset bbq1.Open "SELECT intHolderID, chrHolderName, chrUserData FROM fyp_tblHouseHolder;", conn Set bbq2 = New ADODB.Recordset bbq2.Open "SELECT intHolderID, datInTime FROM fyp_tblclub where fyp_tblclub.intHolderID = '" & bbq1!intHolderID & "' ;", conn Do Until bbq1.EOF Or success = True If Webcam.LoadUserData(RemotePath & bbq1!chrUserData & ".usr", 1) And Webcam.Verify() Then

100

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

success = True Text1.Text = bbq2!datInTime Timetake.Visible = True Timetake.Text = "Your Logout time is" Text2.Text = Time Text3.Text = "See you! " + bbq1!chrHolderName + "! Logout successful!" conn.Execute "UPDATE fyp_tblclub SET datOutTime = '" & Format(Now, "HH:MM:SS") & "' WHERE fyp_tblclub.intHolderID = '" & bbq1!intHolderID & "' ;" Command1.Enabled = True Else bbq1.MoveNext End If Loop If (success = False) Then Text3.Text = "Sorry, Logout Failed! Please try again!" End If bbq1.Close Set bbq1 = Nothing End Sub

101

You might also like