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

ii
TABLE OF CONTENTS

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

Chapter 1 Introduction 1
1.1 Overview 1
1.2 Background Information 1
1.3 Structure of the Final Year Project Report 1
Chapter 2 Literature Review 3
2.1 Introduction 3
2.2 Introduction to Biometrics Technologies 3
2.2.1 What is Biometrics? 3
2.2.2 History of Biometrics 3
2.2.3 How does it work? 4
2.2.4 Applications in Biometrics 6
2.2.5 Template size of each Biometrics Technology 7
2.3 Examples of biometrics system in my life 7
2.4 Examples of biometrics system layout 8
2.5 Examples of hardware design 10
2.6 Examples of software interface design 11
2.7 Summary 12
Chapter 3 Development Methodology for
Multi-Biometrics Recognition System 13
3.1 Introduction 13
3.2 Design Consideration of Hardware System 13
3.3 Design Consideration of Software 17
3.4 Graphics Design and Layout 17
3.5 Structure of Database Design 19
iii
Chapter 4 Details of the Multi-Biometrics Recognition
System 20
4.1 Overview 20
4.2 Workflow of Recognition System 21
4.3 Function of Recognition System 22
4.3.1 Function of Administration tools 22
4.3.2 Function of Building security system 23
4.3.3 Function of Clubhouse system 23
4.4 Hardware of Recognition System 24
4.5 Development Software use 25
4.6 Software needs and setup 26
4.7 Database Structure 28
4.7.1 Relational between tables 28
4.7.2 Householder 29
4.7.3 Householder Log 29
4.7.4 Visitor 30
4.7.5 Building 30
4.7.6 Floor and Flat 31
4.7.7 Clubhouse 31
4.8 Graphics Design and Layout 32
4.8.1 Administration Tools layout design 32
4.8.2 Building security system layout design 34
4.8.3 Clubhouse system layout design 35
Chapter 5 Evaluation of Multi-Biometrics Recognition
Systems 38
5.1 Overview 38
5.2 Principle of Biometric Enrolment and Verification 38
5.3 Summary 38
Chapter 6 Application Procedure of Multi-Biometrics
Recognition Systems 39
6.1 Administration tools 39
6.1.1 Add new householder 39
6.1.2 Edit householder 43
6.1.3 Delete householder 45
6.1.4 Householder entry log 46
6.1.5 Visitor entry log 47
6.2 Building Security System 49
iv
6.2.1 Householder mode 49
6.2.2 Visitor mode 51
6.3 Clubhouse system 54
6.3.1 Clubhouse login and logout system 54
6.3.2 Clubhouse payroll system 57
Chapter 7 Verification of the Multi-Biometrics
Recognition Systems 59
7.1 Overview 59
7.2 Verification of Result 59
7.3 Summary 59
Chapter 8 Conclusion and Further Development 60
8.1 Overview 60
8.2 Contribution of Final Year Project 60
8.3 Discussion on the Project Limitation 60
8.4 Further Proposal 61
References 62
Appendices 64
Appendix A: Team member workload 64
Appendix B: Project plan 65
Appendix C: Programming code 66

v
LIST OF FIGURES

page
Fig. 2.1 Biometric identification and encrypted data system 8
Fig. 2.2 Biometric access control system (Exys Security system) 8
Fig. 2.3 Country entry and exit control system 8
Fig. 2.4 Hand geometry control system 9
Fig. 2.5 Biometric experiment system 9
Fig. 2.6 Presse Fotos ekey fingerprint system 10
Fig. 2.7 Biometric reader clocking system 10
Fig. 2.8 Office access control system 10
Fig. 2.9 Windows lcqon recognition system 11
Fig. 2.10 Breaker facial searching system 11
Fig. 2.11 Biometric Patient Tracking System 11
Fig. 2.12 fingerID system with biometrics in USA 11
Fig. 3.1 Types of fingerprint 13
Fig. 3.2 Optical Fingerprint Sensors 14
Fig. 3.3 Surface Pressure Sensor 14
Fig. 3.4 Capacitive Sensors 14
Fig. 3.5 Facial geometry example 15
Fig. 3.6 Correct recognition example 15
Fig. 3.7 Facial recognition in airport 16
Fig. 3.8 First Visitor mode layout 17
Fig. 3.9 Second Visitor mode layout 18
Fig. 3.10 Clubhouse mode layout 18
Fig. 3.11 Database schema of Biometrics System 19
Fig. 4.1 Structure of System 20
Fig. 4.2 Workflow of Building security system 21
Fig. 4.3 Workflow of Clubhouse system 22
Fig. 4.4 Marcomedia Flash 25
Fig. 4.5 Adobe Photoshop 25
Fig. 4.6 Visual Basic 6.0 25
Fig. 4.7 Create MySQL user 26
Fig. 4.8 Restore the backup file 27
Fig. 4.9 Permission of the folder 27
Fig. 4.10 Folder of householder and visitor 28
Fig. 4.11 Database Structure of Systems 28
vi
Fig. 4.12 Main page of Administration Tools 32
Fig. 4.13 Database Management of Householder 32
Fig. 4.14 Entry Log of Householder 33
Fig. 4.15 Entry Log of Visitor 33
Fig. 4.16 Selection mode of building security system 34
Fig. 4.17 Householder mode of building security system 34
Fig. 4.18 Visitor mode of building security system 35
Fig. 4.19 Language Selection mode of clubhouse system 35
Fig. 4.20 Selection mode of clubhouse system 36
Fig. 4.21 Login mode of clubhouse system 36
Fig. 4.22 Choose facilities mode of clubhouse system 37
Fig. 4.23 Logout mode of clubhouse system 37
Fig. 6.1 Select Database Management 39
Fig. 6.2 Click the Add New button 39
Fig. 6.3 Add user windows 40
Fig. 6.4 Procedure of face enrollment 40
Fig. 6.5 Successful message of face enrollment 41
Fig. 6.6 Successful message of add new householder 41
Fig. 6.7 Error message of add new householder 42
Fig. 6.8 New householder in the list 42
Fig. 6.9 Click the Edit button 43
Fig. 6.10 Enroll new face 43
Fig. 6.11 Successful message of face enrollment 44
Fig. 6.12 Successful message of update householder 44
Fig. 6.13 Delete the householder 45
Fig. 6.14 Confirm to delete householder 45
Fig. 6.15 Select Entry Log of householder 46
Fig. 6.16 Query of Householder Entry Log 46
Fig. 6.17 Result of Householder Entry Log 47
Fig. 6.18 Select Entry Log of visitor 47
Fig. 6.19 Query of Visitor Entry Log 48
Fig. 6.20 Show the photo of visitor 48
Fig. 6.21 Mode selection of Building Security System 49
Fig. 6.22 Procedure of identify the householder 49
Fig. 6.23 Error message when cannot identify the householder 50
Fig. 6.24 Householder identify complete 50
Fig. 6.25 Mode selection of Building Security System 51
Fig. 6.26 Procedure of enter the floor and flat 51
vii
Fig. 6.27 Error message of enter wrong floor 52
Fig. 6.28 Procedure of face capture 52
Fig. 6.29 Procedure of fingerprint capture 53
Fig. 6.30 Visitor register complete 53
Fig. 6.31 Step 1 of process clubhouse system 54
Fig. 6.32 Step 2 of process clubhouse system 54
Fig. 6.33 Step 3 of process clubhouse system 55
Fig. 6.34 Step 4 of process clubhouse system 55
Fig. 6.35 Step 5 of process clubhouse system 56
Fig. 6.36 Step 6 of process clubhouse system 56
Fig. 6.37 Step 1 of process clubhouse payroll system 57
Fig. 6.38 Step 2 of process of clubhouse payroll system 57
Fig. 6.39 Step 3 of process of clubhouse payroll system 58


viii
LIST OF TABLES

page
Table 2.1 Template size of each Biometrics Technology 7
Table 4.1 Database structure of householder 29
Table 4.2 Database structure of householder log 29
Table 4.3 Database structure of visitor 30
Table 4.4 Database structure of building 30
Table 4.5 Database structure of floor and flat 31
Table 4.6 Database structure of clubhouse 31
Table 7.1 FRR rate of facial recognition 59
Table 7.2 FAR rate of facial recognition 59


ix
LIST OF APPENDICES

page
Appendix A Team member workload 64
Appendix B Project plan 65
Appendix C Programming code 66
1
Chapter 1 Introduction

1.1 Overview
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.
2

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.
3
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:
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
4
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.

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


6
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]
Physical Access Control
Logical Access Control
J ustice/Law Enforcement
Time and Attendance
Border Control/Airports
HIPAA
Financial/Transactional
Integrators/Resellers
Safes, Door Locks




7
2.2.5 Template size of each Biometrics Technology

Biometrics Technology Template size per record
Iris 256 Bytes
Fingerprint 512-1000 Bytes
Facial >512 Bytes
Hand Geometry 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.



8
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]
9

Fig. 2.4 Hand geometry control system [8]


Fig. 2.5 Biometric experiment system [9]
10
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]
11
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]
12
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.
13
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 J apanese. 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]
14
There are 6 types of sensors for fingerprint recognition:
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.
15
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]
16
All of this makes face recognition ideal for high traffic areas open to the general public,
such as:
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]
17
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

18

Fig. 3.9 Second Visitor mode layout


Fig. 3.10 Clubhouse mode layout
.
19
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

20
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


21
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
Facial Recognition
Check database &
identify
Open door
Input Floor and
Flat
Enroll Face
Enroll Fingerprint
Open door
Visitor
Vaild
Invaild
Householder

Fig. 4.2 Workflow of Building security system
22
Entry
Select
Login/Logout
Login mode
Store login time
to database
Facial
recognize
Check
database
Invaild
Logout mode
Facial
recognize
Check
database
Store logout time
to database
Invaild
Login
Logout
vaild vaild

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,
23
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.
24
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:
More securable than passwords by intercepting use and approach of
Unauthorized people whose identification is not registered.
Free from inconvenience to upgrade and remember passwords and the company
It can save much cost to manage passwords.
Fast and exact perception with high technology of finger print identification.
Adopted dsp system that is to calculate moving direction and distance without
Password by the image perceiving sensor.
No roller and soft movement thanks to less rubbing resistance.
Finally, fingerprint is easy too use, user-friendly and too cheap in the kinds of
biometrics devices.
25
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.
26
4.6 Software needs and setup
The basic software needs to install of the system are below:
Flash Player 8.0
TiFace Runtime
TiFace SmartGate SDK
Futronic Fingerprint SDK

The server and driver of the system needs are below:
MySQL Server 4.0.x
MySQL ODBC 3.51 Driver

For easy to manage the database, we suggest to install these software are below:
MySQL Administrator
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
27
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
28
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
29
4.7.2 Householder

Table: fyp_tblHouseHolder
Description: Store the detail of householder
Key Field Name Data Type Description
intHolderID INT(5) HouseHolders ID
chrHolderName VARCHAR(255) HouseHolders Name
chrGender CHAR(1) HouseHolders Gender
datBirth DATE HouseHolder Birthday
chrHKID VARCHAR(11) HouseHolders HKID Number
datRegDate DATE Register Date
chrUserData VARCHAR(64) Template Filename of Face Enroll
intBuildingID INT(2) Building ID
intFFID INT(3) 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 Field Name Data Type Description
intLogID INT(8) Log ID
intHolderID INT(5) Householders ID
datInTime DATETIME Login Date and Time
Table 4.2 Database structure of householder log

30
4.7.4 Visitor

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

4.7.5 Building

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

31
4.7.6 Floor and Flat

Table: fyp_tblFloorFlat
Description: Store the floor and flat
Key Field Name Data Type Description
intFFID INT(3) Floor and Flat ID
chrFloor CHAR(2) Floor Number
chrFlat CHAR(1) 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 Field Name Data Type Description
intLogID INT Log ID
intHolderID INT(5) Householders ID
datInTime DATETIME Login Date and Time
datOutTime DATETIME Logout Date and Time
intPrice INT(5) Price of using clubhouse
Table 4.6 Database structure of clubhouse

32
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 2. List of the householder
3. Add new householder 4. Edit selected householder
5. Delete selected householder 6. Refresh the List of householder
33

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 2. Query search
3. Photo of the visitor

34
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 2. Camera box
3. Message box 4. Exit button

35

Fig. 4.18 Visitor mode of building security system

1. Date and Time 2. Display of floor and flat
3. Message box 4. Number and character keypad
5. Exit button

4.8.3 Clubhouse system layout

Fig. 4.19 Language Selection mode of clubhouse system

1. Mode selection button

36

Fig. 4.20 Selection mode of clubhouse system

1. Mode selection button


Fig. 4.21 Login mode of clubhouse system

1. Camera box 2. Message box
3. Login button

37

Fig. 4.22 Choose facilities mode of clubhouse system

1. Camera box 2. Message box
3. Login button 4. Facilities button


Fig. 4.23 Logout mode of clubhouse system

1. Camera box 2. Message box
3. Logout button

38
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.
39
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
40
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
41
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

42
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
43
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
44
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
45
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
46
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
47
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

48
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

49
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
50
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
51
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

52
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
53
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
54
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
55
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

56
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
57
6.3.2 Process of clubhouse payroll system
Step1. When you pay the clubhouse free, you may go to our clubhouse payroll
system.

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
58
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

59
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)
No. of false rejection
(b)
False Rejection Rate (FRR)
b / (a +b)
15 5 0.25
Table 7.1 FRR rate of facial recognition

No. of correct rejection
(a)
No. of false
acceptance (b)
False Acceptance Rate (FAR)
b / (a +b)
20 0 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.

60
Chapter 8 Conclusions and Further Development

8.1 Overview
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.
61
8.4 Further Proposal
After this project, we have other further ideas. The further ideas are below:-
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
62
References

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

63
[19] Fig. 3.2 Optical Fingerprint Sensors
http://www.bergdata.com/downloads/Introduction%20to%20Fingerprint.pdf
[20] Fig. 3.3 Surface Pressure Sensor
http://www.bergdata.com/downloads/Introduction%20to%20Fingerprint.pdf
[21] Fig. 3.4 Capacitive Sensors
http://www.bergdata.com/downloads/Introduction%20to%20Fingerprint.pdf
[22] Introduction of facial recognition
http://www.findbiometrics.com/Pages/face_articles/face_2.html
http://www.c-vis.com/htd/frt.html
[23] Fig. 3.5 Facial geometry example
http://www.c-vis.com/htd/frt.html
[24] Fig. 3.6 Correct recognition example
http://www.c-vis.com/htd/frt.html
[25] Fig. 3.7 Facial recognition in airport
http://www.c-vis.com/htd/frt.html
[26] Fig. 4.1 Marcomedia Flash
http://www.adobe.com/products/flash/flashpro/
[27] Fig. 4.2 Adobe Photoshop
http://www.adobe.com/products/photoshop/
[28] 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

64
Appendices

Appendix A: Team member workload

Chan Ka Lun, Peae (leader)
Design interface of Householder mode
Design interface of Visitor mode
Design interface of enrolment mode
Design interface of administrator mode
Programming of Householder mode
Programming of Visitor mode
Programming of enrolment mode
Programming of administrator mode
Build up database system

Tsang Man Piu
Design interface of Clubhouse login system
Design interface of Clubhouse payroll system
Programming of Clubhouse login system
Programming of Clubhouse payroll system
65
Appendix B: Project plan
PROJECT PLAN

Course : 41381/3A
Student Name : Chan Ka Lun, Tsang Man Piu
Project Title : Apply Multi-Biometrics Recognition Systems for Intelligent
House Management
Project Supervisor : Mr. MK Lam
Date : 7 October, 2005 (Week 4)
Project Objective(s) : - 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. 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38
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


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

The class module of system
CRijndael.cls
This class module is used to generate the 64 character filename of the
template.
1 Opt i on Expl i ci t
2
3 Pr i vat e m_l OnBi t s( 30) As Long
4 Pr i vat e m_l 2Power ( 30) As Long
5 Pr i vat e m_byt OnBi t s( 7) As Byt e
6 Pr i vat e m_byt 2Power ( 7) As Byt e
7
8 Pr i vat e m_I nCo( 3) As Byt e
9
10 Pr i vat e m_f bsub( 255) As Byt e
11 Pr i vat e m_r bsub( 255) As Byt e
12 Pr i vat e m_pt ab( 255) As Byt e
13 Pr i vat e m_l t ab( 255) As Byt e
14 Pr i vat e m_f t abl e( 255) As Long
15 Pr i vat e m_r t abl e( 255) As Long
16 Pr i vat e m_r co( 29) As Long
17
18 Pr i vat e m_Nk As Long
19 Pr i vat e m_Nb As Long
20 Pr i vat e m_Nr As Long
21 Pr i vat e m_f i ( 23) As Byt e
22 Pr i vat e m_r i ( 23) As Byt e
23 Pr i vat e m_f key( 119) As Long
24 Pr i vat e m_r key( 119) As Long
25
26 Pr i vat e Decl ar e Sub CopyMemor y Li b " ker nel 32" Al i as " Rt l MoveMemor y" _
27 ( ByVal Dest i nat i on As Any, ByVal Sour ce As Any, ByVal Lengt h As Long)
28
29 ' *******************************************************************************
30 ' Cl ass_I ni t i al i ze ( SUB)
31 ' *******************************************************************************
32 Pr i vat e Sub Cl ass_I ni t i al i ze( )
33 m_I nCo( 0) = &HB
34 m_I nCo( 1) = &HD
35 m_I nCo( 2) = &H9
36 m_I nCo( 3) = &HE
37
38 ' Coul d have done t hi s wi t h a l oop cal cul at i ng each val ue, but si mpl y
39 ' assi gni ng t he val ues i s qui cker - BI TS SET FROM RI GHT
40 m_byt OnBi t s( 0) = 1 ' 00000001
41 m_byt OnBi t s( 1) = 3 ' 00000011
42 m_byt OnBi t s( 2) = 7 ' 00000111
43 m_byt OnBi t s( 3) = 15 ' 00001111
44 m_byt OnBi t s( 4) = 31 ' 00011111
45 m_byt OnBi t s( 5) = 63 ' 00111111
46 m_byt OnBi t s( 6) = 127 ' 01111111
47 m_byt OnBi t s( 7) = 255 ' 11111111
48
49 ' Coul d have done t hi s wi t h a l oop cal cul at i ng each val ue, but si mpl y
50 ' assi gni ng t he val ues i s qui cker - POWERS OF 2
51 m_byt 2Power ( 0) = 1 ' 00000001
52 m_byt 2Power ( 1) = 2 ' 00000010
53 m_byt 2Power ( 2) = 4 ' 00000100
54 m_byt 2Power ( 3) = 8 ' 00001000
55 m_byt 2Power ( 4) = 16 ' 00010000
56 m_byt 2Power ( 5) = 32 ' 00100000
57 m_byt 2Power ( 6) = 64 ' 01000000
58 m_byt 2Power ( 7) = 128 ' 10000000
59
60 ' Coul d have done t hi s wi t h a l oop cal cul at i ng each val ue, but si mpl y
61 ' assi gni ng t he val ues i s qui cker - BI TS SET FROM RI GHT
62 m_l OnBi t s( 0) = 1 ' 00000000000000000000000000000001
63 m_l OnBi t s( 1) = 3 ' 00000000000000000000000000000011
64 m_l OnBi t s( 2) = 7 ' 00000000000000000000000000000111
67
65 m_l OnBi t s( 3) = 15 ' 00000000000000000000000000001111
66 m_l OnBi t s( 4) = 31 ' 00000000000000000000000000011111
67 m_l OnBi t s( 5) = 63 ' 00000000000000000000000000111111
68 m_l OnBi t s( 6) = 127 ' 00000000000000000000000001111111
69 m_l OnBi t s( 7) = 255 ' 00000000000000000000000011111111
70 m_l OnBi t s( 8) = 511 ' 00000000000000000000000111111111
71 m_l OnBi t s( 9) = 1023 ' 00000000000000000000001111111111
72 m_l OnBi t s( 10) = 2047 ' 00000000000000000000011111111111
73 m_l OnBi t s( 11) = 4095 ' 00000000000000000000111111111111
74 m_l OnBi t s( 12) = 8191 ' 00000000000000000001111111111111
75 m_l OnBi t s( 13) = 16383 ' 00000000000000000011111111111111
76 m_l OnBi t s( 14) = 32767 ' 00000000000000000111111111111111
77 m_l OnBi t s( 15) = 65535 ' 00000000000000001111111111111111
78 m_l OnBi t s( 16) = 131071 ' 00000000000000011111111111111111
79 m_l OnBi t s( 17) = 262143 ' 00000000000000111111111111111111
80 m_l OnBi t s( 18) = 524287 ' 00000000000001111111111111111111
81 m_l OnBi t s( 19) = 1048575 ' 00000000000011111111111111111111
82 m_l OnBi t s( 20) = 2097151 ' 00000000000111111111111111111111
83 m_l OnBi t s( 21) = 4194303 ' 00000000001111111111111111111111
84 m_l OnBi t s( 22) = 8388607 ' 00000000011111111111111111111111
85 m_l OnBi t s( 23) = 16777215 ' 00000000111111111111111111111111
86 m_l OnBi t s( 24) = 33554431 ' 00000001111111111111111111111111
87 m_l OnBi t s( 25) = 67108863 ' 00000011111111111111111111111111
88 m_l OnBi t s( 26) = 134217727 ' 00000111111111111111111111111111
89 m_l OnBi t s( 27) = 268435455 ' 00001111111111111111111111111111
90 m_l OnBi t s( 28) = 536870911 ' 00011111111111111111111111111111
91 m_l OnBi t s( 29) = 1073741823 ' 00111111111111111111111111111111
92 m_l OnBi t s( 30) = 2147483647 ' 01111111111111111111111111111111
93
94 ' Coul d have done t hi s wi t h a l oop cal cul at i ng each val ue, but si mpl y
95 ' assi gni ng t he val ues i s qui cker - POWERS OF 2
96 m_l 2Power ( 0) = 1 ' 00000000000000000000000000000001
97 m_l 2Power ( 1) = 2 ' 00000000000000000000000000000010
98 m_l 2Power ( 2) = 4 ' 00000000000000000000000000000100
99 m_l 2Power ( 3) = 8 ' 00000000000000000000000000001000
100 m_l 2Power ( 4) = 16 ' 00000000000000000000000000010000
101 m_l 2Power ( 5) = 32 ' 00000000000000000000000000100000
102 m_l 2Power ( 6) = 64 ' 00000000000000000000000001000000
103 m_l 2Power ( 7) = 128 ' 00000000000000000000000010000000
104 m_l 2Power ( 8) = 256 ' 00000000000000000000000100000000
105 m_l 2Power ( 9) = 512 ' 00000000000000000000001000000000
106 m_l 2Power ( 10) = 1024 ' 00000000000000000000010000000000
107 m_l 2Power ( 11) = 2048 ' 00000000000000000000100000000000
108 m_l 2Power ( 12) = 4096 ' 00000000000000000001000000000000
109 m_l 2Power ( 13) = 8192 ' 00000000000000000010000000000000
110 m_l 2Power ( 14) = 16384 ' 00000000000000000100000000000000
111 m_l 2Power ( 15) = 32768 ' 00000000000000001000000000000000
112 m_l 2Power ( 16) = 65536 ' 00000000000000010000000000000000
113 m_l 2Power ( 17) = 131072 ' 00000000000000100000000000000000
114 m_l 2Power ( 18) = 262144 ' 00000000000001000000000000000000
115 m_l 2Power ( 19) = 524288 ' 00000000000010000000000000000000
116 m_l 2Power ( 20) = 1048576 ' 00000000000100000000000000000000
117 m_l 2Power ( 21) = 2097152 ' 00000000001000000000000000000000
118 m_l 2Power ( 22) = 4194304 ' 00000000010000000000000000000000
119 m_l 2Power ( 23) = 8388608 ' 00000000100000000000000000000000
120 m_l 2Power ( 24) = 16777216 ' 00000001000000000000000000000000
121 m_l 2Power ( 25) = 33554432 ' 00000010000000000000000000000000
122 m_l 2Power ( 26) = 67108864 ' 00000100000000000000000000000000
123 m_l 2Power ( 27) = 134217728 ' 00001000000000000000000000000000
124 m_l 2Power ( 28) = 268435456 ' 00010000000000000000000000000000
125 m_l 2Power ( 29) = 536870912 ' 00100000000000000000000000000000
126 m_l 2Power ( 30) = 1073741824 ' 01000000000000000000000000000000
127 End Sub
128
129 ' *******************************************************************************
130 ' LShi f t ( FUNCTI ON)
131 ' *******************************************************************************
132 Pr i vat e Funct i on LShi f t ( ByVal l Val ue As Long, _
133 ByVal i Shi f t Bi t s As I nt eger ) As Long
134 I f i Shi f t Bi t s = 0 Then
135 LShi f t = l Val ue
136 Exi t Funct i on
137 El seI f i Shi f t Bi t s = 31 Then
138 I f l Val ue And 1 Then
139 LShi f t = &H80000000
140 El se
68
141 LShi f t = 0
142 End I f
143 Exi t Funct i on
144 El seI f i Shi f t Bi t s < 0 Or i Shi f t Bi t s > 31 Then
145 Er r . Rai se 6
146 End I f
147
148 I f ( l Val ue And m_l 2Power ( 31 - i Shi f t Bi t s) ) Then
149 LShi f t = ( ( l Val ue And m_l OnBi t s( 31 - ( i Shi f t Bi t s + 1) ) ) * _
150 m_l 2Power ( i Shi f t Bi t s) ) Or &H80000000
151 El se
152 LShi f t = ( ( l Val ue And m_l OnBi t s( 31 - i Shi f t Bi t s) ) * _
153 m_l 2Power ( i Shi f t Bi t s) )
154 End I f
155 End Funct i on
156
157 ' *******************************************************************************
158 ' RShi f t ( FUNCTI ON)
159 ' *******************************************************************************
160 Pr i vat e Funct i on RShi f t ( ByVal l Val ue As Long, _
161 ByVal i Shi f t Bi t s As I nt eger ) As Long
162 I f i Shi f t Bi t s = 0 Then
163 RShi f t = l Val ue
164 Exi t Funct i on
165 El seI f i Shi f t Bi t s = 31 Then
166 I f l Val ue And &H80000000 Then
167 RShi f t = 1
168 El se
169 RShi f t = 0
170 End I f
171 Exi t Funct i on
172 El seI f i Shi f t Bi t s < 0 Or i Shi f t Bi t s > 31 Then
173 Er r . Rai se 6
174 End I f
175
176 RShi f t = ( l Val ue And &H7FFFFFFE) \ m_l 2Power ( i Shi f t Bi t s)
177
178 I f ( l Val ue And &H80000000) Then
179 RShi f t = ( RShi f t Or ( &H40000000 \ m_l 2Power ( i Shi f t Bi t s - 1) ) )
180 End I f
181 End Funct i on
182
183 ' *******************************************************************************
184 ' LShi f t Byt e ( FUNCTI ON)
185 ' *******************************************************************************
186 Pr i vat e Funct i on LShi f t Byt e( ByVal byt Val ue As Byt e, _
187 ByVal byt Shi f t Bi t s As Byt e) As Byt e
188 I f byt Shi f t Bi t s = 0 Then
189 LShi f t Byt e = byt Val ue
190 Exi t Funct i on
191 El seI f byt Shi f t Bi t s = 7 Then
192 I f byt Val ue And 1 Then
193 LShi f t Byt e = &H80
194 El se
195 LShi f t Byt e = 0
196 End I f
197 Exi t Funct i on
198 El seI f byt Shi f t Bi t s < 0 Or byt Shi f t Bi t s > 7 Then
199 Er r . Rai se 6
200 End I f
201
202 LShi f t Byt e = ( ( byt Val ue And m_byt OnBi t s( 7 - byt Shi f t Bi t s) ) * _
203 m_byt 2Power ( byt Shi f t Bi t s) )
204 End Funct i on
205
206 ' *******************************************************************************
207 ' RShi f t Byt e ( FUNCTI ON)
208 ' *******************************************************************************
209 Pr i vat e Funct i on RShi f t Byt e( ByVal byt Val ue As Byt e, _
210 ByVal byt Shi f t Bi t s As Byt e) As Byt e
211 I f byt Shi f t Bi t s = 0 Then
212 RShi f t Byt e = byt Val ue
213 Exi t Funct i on
214 El seI f byt Shi f t Bi t s = 7 Then
215 I f byt Val ue And &H80 Then
216 RShi f t Byt e = 1
69
217 El se
218 RShi f t Byt e = 0
219 End I f
220 Exi t Funct i on
221 El seI f byt Shi f t Bi t s < 0 Or byt Shi f t Bi t s > 7 Then
222 Er r . Rai se 6
223 End I f
224
225 RShi f t Byt e = byt Val ue \ m_byt 2Power ( byt Shi f t Bi t s)
226 End Funct i on
227
228 ' *******************************************************************************
229 ' Rot at eLef t ( FUNCTI ON)
230 ' *******************************************************************************
231 Pr i vat e Funct i on Rot at eLef t ( ByVal l Val ue As Long, _
232 ByVal i Shi f t Bi t s As I nt eger ) As Long
233 Rot at eLef t = LShi f t ( l Val ue, i Shi f t Bi t s) Or RShi f t ( l Val ue, ( 32 - i Shi f t Bi t s) )
234 End Funct i on
235
236 ' ' *******************************************************************************
237 ' ' Rot at eLef t Byt e ( FUNCTI ON)
238 ' *******************************************************************************
239 Pr i vat e Funct i on Rot at eLef t Byt e( ByVal byt Val ue As Byt e, _
240 ByVal byt Shi f t Bi t s As Byt e) As Byt e
241 Rot at eLef t Byt e = LShi f t Byt e( byt Val ue, byt Shi f t Bi t s) Or _
242 RShi f t Byt e( byt Val ue, ( 8 - byt Shi f t Bi t s) )
243 End Funct i on
244
245 ' *******************************************************************************
246 ' Pack ( FUNCTI ON)
247 ' *******************************************************************************
248 Pr i vat e Funct i on Pack( b( ) As Byt e) As Long
249 Di ml Count As Long
250 Di ml Temp As Long
251
252 For l Count = 0 To 3
253 l Temp = b( l Count )
254 Pack = Pack Or LShi f t ( l Temp, ( l Count * 8) )
255 Next
256 End Funct i on
257
258 ' *******************************************************************************
259 ' PackFr om( FUNCTI ON)
260 ' *******************************************************************************
261 Pr i vat e Funct i on PackFr om( b( ) As Byt e, _
262 ByVal k As Long) As Long
263 Di ml Count As Long
264 Di ml Temp As Long
265
266 For l Count = 0 To 3
267 l Temp = b( l Count + k)
268 PackFr om= PackFr omOr LShi f t ( l Temp, ( l Count * 8) )
269 Next
270 End Funct i on
271
272 ' *******************************************************************************
273 ' Unpack ( SUB)
274 ' *******************************************************************************
275 Pr i vat e Sub Unpack( ByVal a As Long, _
276 b( ) As Byt e)
277 b( 0) = a And m_l OnBi t s( 7)
278 b( 1) = RShi f t ( a, 8) And m_l OnBi t s( 7)
279 b( 2) = RShi f t ( a, 16) And m_l OnBi t s( 7)
280 b( 3) = RShi f t ( a, 24) And m_l OnBi t s( 7)
281 End Sub
282
283 ' *******************************************************************************
284 ' UnpackFr om( SUB)
285 ' *******************************************************************************
286 Pr i vat e Sub UnpackFr om( ByVal a As Long, _
287 b( ) As Byt e, _
288 ByVal k As Long)
289 b( 0 + k) = a And m_l OnBi t s( 7)
290 b( 1 + k) = RShi f t ( a, 8) And m_l OnBi t s( 7)
291 b( 2 + k) = RShi f t ( a, 16) And m_l OnBi t s( 7)
292 b( 3 + k) = RShi f t ( a, 24) And m_l OnBi t s( 7)
70
293 End Sub
294
295 ' *******************************************************************************
296 ' xt i me ( FUNCTI ON)
297 ' *******************************************************************************
298 Pr i vat e Funct i on xt i me( ByVal a As Byt e) As Byt e
299 Di mb As Byt e
300
301 I f ( a And &H80) Then
302 b = &H1B
303 El se
304 b = 0
305 End I f
306
307 a = LShi f t Byt e( a, 1)
308 a = a Xor b
309
310 xt i me = a
311 End Funct i on
312
313 ' *******************************************************************************
314 ' bmul ( FUNCTI ON)
315 ' *******************************************************************************
316 Pr i vat e Funct i on bmul ( ByVal x As Byt e, _
317 y As Byt e) As Byt e
318 I f x <> 0 And y <> 0 Then
319 bmul = m_pt ab( ( CLng( m_l t ab( x) ) + CLng( m_l t ab( y) ) ) Mod 255)
320 El se
321 bmul = 0
322 End I f
323 End Funct i on
324
325 ' *******************************************************************************
326 ' SubByt e ( FUNCTI ON)
327 ' *******************************************************************************
328 Pr i vat e Funct i on SubByt e( ByVal a As Long) As Long
329 Di mb( 3) As Byt e
330
331 Unpack a, b
332 b( 0) = m_f bsub( b( 0) )
333 b( 1) = m_f bsub( b( 1) )
334 b( 2) = m_f bsub( b( 2) )
335 b( 3) = m_f bsub( b( 3) )
336
337 SubByt e = Pack( b)
338 End Funct i on
339
340 ' *******************************************************************************
341 ' pr oduct ( FUNCTI ON)
342 ' *******************************************************************************
343 Pr i vat e Funct i on pr oduct ( ByVal x As Long, _
344 ByVal y As Long) As Long
345 Di mxb( 3) As Byt e
346 Di myb( 3) As Byt e
347
348 Unpack x, xb
349 Unpack y, yb
350 pr oduct = bmul ( xb( 0) , yb( 0) ) Xor bmul ( xb( 1) , yb( 1) ) Xor bmul ( xb( 2) , yb( 2) ) _
351 Xor bmul ( xb( 3) , yb( 3) )
352 End Funct i on
353
354 ' *******************************************************************************
355 ' I nvMi xCol ( FUNCTI ON)
356 ' *******************************************************************************
357 Pr i vat e Funct i on I nvMi xCol ( ByVal x As Long) As Long
358 Di my As Long
359 Di mm As Long
360 Di mb( 3) As Byt e
361
362 m= Pack( m_I nCo)
363 b( 3) = pr oduct ( m, x)
364 m= Rot at eLef t ( m, 24)
365 b( 2) = pr oduct ( m, x)
366 m= Rot at eLef t ( m, 24)
367 b( 1) = pr oduct ( m, x)
368 m= Rot at eLef t ( m, 24)
71
369 b( 0) = pr oduct ( m, x)
370 y = Pack( b)
371
372 I nvMi xCol = y
373 End Funct i on
374
375 ' *******************************************************************************
376 ' Byt eSub ( FUNCTI ON)
377 ' *******************************************************************************
378 Pr i vat e Funct i on Byt eSub( ByVal x As Byt e) As Byt e
379 Di my As Byt e
380
381 y = m_pt ab( 255 - m_l t ab( x) )
382 x = y
383 x = Rot at eLef t Byt e( x, 1)
384 y = y Xor x
385 x = Rot at eLef t Byt e( x, 1)
386 y = y Xor x
387 x = Rot at eLef t Byt e( x, 1)
388 y = y Xor x
389 x = Rot at eLef t Byt e( x, 1)
390 y = y Xor x
391 y = y Xor &H63
392
393 Byt eSub = y
394 End Funct i on
395
396 ' *******************************************************************************
397 ' gent abl es ( SUB)
398 ' *******************************************************************************
399 Publ i c Sub gent abl es( )
400 Di mi As Long
401 Di my As Byt e
402 Di mb( 3) As Byt e
403 Di mi b As Byt e
404
405 m_l t ab( 0) = 0
406 m_pt ab( 0) = 1
407 m_l t ab( 1) = 0
408 m_pt ab( 1) = 3
409 m_l t ab( 3) = 1
410
411 For i = 2 To 255
412 m_pt ab( i ) = m_pt ab( i - 1) Xor xt i me( m_pt ab( i - 1) )
413 m_l t ab( m_pt ab( i ) ) = i
414 Next
415
416 m_f bsub( 0) = &H63
417 m_r bsub( &H63) = 0
418
419 For i = 1 To 255
420 i b = i
421 y = Byt eSub( i b)
422 m_f bsub( i ) = y
423 m_r bsub( y) = i
424 Next
425
426 y = 1
427 For i = 0 To 29
428 m_r co( i ) = y
429 y = xt i me( y)
430 Next
431
432 For i = 0 To 255
433 y = m_f bsub( i )
434 b( 3) = y Xor xt i me( y)
435 b( 2) = y
436 b( 1) = y
437 b( 0) = xt i me( y)
438 m_f t abl e( i ) = Pack( b)
439
440 y = m_r bsub( i )
441 b( 3) = bmul ( m_I nCo( 0) , y)
442 b( 2) = bmul ( m_I nCo( 1) , y)
443 b( 1) = bmul ( m_I nCo( 2) , y)
444 b( 0) = bmul ( m_I nCo( 3) , y)
72
445 m_r t abl e( i ) = Pack( b)
446 Next
447 End Sub
448
449 ' *******************************************************************************
450 ' gkey ( SUB)
451 ' *******************************************************************************
452 Publ i c Sub gkey( ByVal nb As Long, _
453 ByVal nk As Long, _
454 key( ) As Byt e)
455
456 Di mi As Long
457 Di mj As Long
458 Di mk As Long
459 Di mm As Long
460 Di mN As Long
461 Di mC1 As Long
462 Di mC2 As Long
463 Di mC3 As Long
464 Di mCi pher Key( 7) As Long
465
466 m_Nb = nb
467 m_Nk = nk
468
469 I f m_Nb >= m_Nk Then
470 m_Nr = 6 + m_Nb
471 El se
472 m_Nr = 6 + m_Nk
473 End I f
474
475 C1 = 1
476 I f m_Nb < 8 Then
477 C2 = 2
478 C3 = 3
479 El se
480 C2 = 3
481 C3 = 4
482 End I f
483
484 For j = 0 To nb - 1
485 m= j * 3
486
487 m_f i ( m) = ( j + C1) Mod nb
488 m_f i ( m+ 1) = ( j + C2) Mod nb
489 m_f i ( m+ 2) = ( j + C3) Mod nb
490 m_r i ( m) = ( nb + j - C1) Mod nb
491 m_r i ( m+ 1) = ( nb + j - C2) Mod nb
492 m_r i ( m+ 2) = ( nb + j - C3) Mod nb
493 Next
494
495 N = m_Nb * ( m_Nr + 1)
496
497 For i = 0 To m_Nk - 1
498 j = i * 4
499 Ci pher Key( i ) = PackFr om( key, j )
500 Next
501
502 For i = 0 To m_Nk - 1
503 m_f key( i ) = Ci pher Key( i )
504 Next
505
506 j = m_Nk
507 k = 0
508 Do Whi l e j < N
509 m_f key( j ) = m_f key( j - m_Nk) Xor _
510 SubByt e( Rot at eLef t ( m_f key( j - 1) , 24) ) Xor m_r co( k)
511 I f m_Nk <= 6 Then
512 i = 1
513 Do Whi l e i < m_Nk And ( i + j ) < N
514 m_f key( i + j ) = m_f key( i + j - m_Nk) Xor _
515 m_f key( i + j - 1)
516 i = i + 1
517 Loop
518 El se
519 ' Pr obl emf i xed her e
520 i = 1
73
521 Do Whi l e i < 4 And ( i + j ) < N
522 m_f key( i + j ) = m_f key( i + j - m_Nk) Xor _
523 m_f key( i + j - 1)
524 i = i + 1
525 Loop
526 I f j + 4 < N Then
527 m_f key( j + 4) = m_f key( j + 4 - m_Nk) Xor _
528 SubByt e( m_f key( j + 3) )
529 End I f
530 i = 5
531 Do Whi l e i < m_Nk And ( i + j ) < N
532 m_f key( i + j ) = m_f key( i + j - m_Nk) Xor _
533 m_f key( i + j - 1)
534 i = i + 1
535 Loop
536 End I f
537
538 j = j + m_Nk
539 k = k + 1
540 Loop
541
542 For j = 0 To m_Nb - 1
543 m_r key( j + N - nb) = m_f key( j )
544 Next
545
546 i = m_Nb
547 Do Whi l e i < N - m_Nb
548 k = N - m_Nb - i
549 For j = 0 To m_Nb - 1
550 m_r key( k + j ) = I nvMi xCol ( m_f key( i + j ) )
551 Next
552 i = i + m_Nb
553 Loop
554
555 j = N - m_Nb
556 Do Whi l e j < N
557 m_r key( j - N + m_Nb) = m_f key( j )
558 j = j + 1
559 Loop
560 End Sub
561
562 ' *******************************************************************************
563 ' encr ypt ( SUB)
564 ' *******************************************************************************
565 Publ i c Sub Encr ypt ( buf f ( ) As Byt e)
566 Di mi As Long
567 Di mj As Long
568 Di mk As Long
569 Di mm As Long
570 Di ma( 7) As Long
571 Di mb( 7) As Long
572 Di mx( ) As Long
573 Di my( ) As Long
574 Di mt ( ) As Long
575
576 For i = 0 To m_Nb - 1
577 j = i * 4
578
579 a( i ) = PackFr om( buf f , j )
580 a( i ) = a( i ) Xor m_f key( i )
581 Next
582
583 k = m_Nb
584 x = a
585 y = b
586
587 For i = 1 To m_Nr - 1
588 For j = 0 To m_Nb - 1
589 m= j * 3
590 y( j ) = m_f key( k) Xor m_f t abl e( x( j ) And m_l OnBi t s( 7) ) Xor _
591 Rot at eLef t ( m_f t abl e( RShi f t ( x( m_f i ( m) ) , 8) And m_l OnBi t s( 7) ) , 8) Xor _
592 Rot at eLef t ( m_f t abl e( RShi f t ( x( m_f i ( m+ 1) ) , 16) And m_l OnBi t s( 7) ) , 16) Xor
_
593 Rot at eLef t ( m_f t abl e( RShi f t ( x( m_f i ( m+ 2) ) , 24) And m_l OnBi t s( 7) ) , 24)
594 k = k + 1
595 Next
74
596 t = x
597 x = y
598 y = t
599 Next
600
601 For j = 0 To m_Nb - 1
602 m= j * 3
603 y( j ) = m_f key( k) Xor m_f bsub( x( j ) And m_l OnBi t s( 7) ) Xor _
604 Rot at eLef t ( m_f bsub( RShi f t ( x( m_f i ( m) ) , 8) And m_l OnBi t s( 7) ) , 8) Xor _
605 Rot at eLef t ( m_f bsub( RShi f t ( x( m_f i ( m+ 1) ) , 16) And m_l OnBi t s( 7) ) , 16) Xor _
606 Rot at eLef t ( m_f bsub( RShi f t ( x( m_f i ( m+ 2) ) , 24) And m_l OnBi t s( 7) ) , 24)
607 k = k + 1
608 Next
609
610 For i = 0 To m_Nb - 1
611 j = i * 4
612 UnpackFr omy( i ) , buf f , j
613 x( i ) = 0
614 y( i ) = 0
615 Next
616 End Sub
617
618 ' *******************************************************************************
619 ' decr ypt ( SUB)
620 ' *******************************************************************************
621 Publ i c Sub Decr ypt ( buf f ( ) As Byt e)
622 Di mi As Long
623 Di mj As Long
624 Di mk As Long
625 Di mmAs Long
626 Di ma( 7) As Long
627 Di mb( 7) As Long
628 Di mx( ) As Long
629 Di my( ) As Long
630 Di mt ( ) As Long
631
632 For i = 0 To m_Nb - 1
633 j = i * 4
634 a( i ) = PackFr om( buf f , j )
635 a( i ) = a( i ) Xor m_r key( i )
636 Next
637
638 k = m_Nb
639 x = a
640 y = b
641
642 For i = 1 To m_Nr - 1
643 For j = 0 To m_Nb - 1
644 m= j * 3
645 y( j ) = m_r key( k) Xor m_r t abl e( x( j ) And m_l OnBi t s( 7) ) Xor _
646 Rot at eLef t ( m_r t abl e( RShi f t ( x( m_r i ( m) ) , 8) And m_l OnBi t s( 7) ) , 8) Xor _
647 Rot at eLef t ( m_r t abl e( RShi f t ( x( m_r i ( m+ 1) ) , 16) And m_l OnBi t s( 7) ) , 16) Xor
_
648 Rot at eLef t ( m_r t abl e( RShi f t ( x( m_r i ( m+ 2) ) , 24) And m_l OnBi t s( 7) ) , 24)
649 k = k + 1
650 Next
651 t = x
652 x = y
653 y = t
654 Next
655
656 For j = 0 To m_Nb - 1
657 m= j * 3
658
659 y( j ) = m_r key( k) Xor m_r bsub( x( j ) And m_l OnBi t s( 7) ) Xor _
660 Rot at eLef t ( m_r bsub( RShi f t ( x( m_r i ( m) ) , 8) And m_l OnBi t s( 7) ) , 8) Xor _
661 Rot at eLef t ( m_r bsub( RShi f t ( x( m_r i ( m+ 1) ) , 16) And m_l OnBi t s( 7) ) , 16) Xor _
662 Rot at eLef t ( m_r bsub( RShi f t ( x( m_r i ( m+ 2) ) , 24) And m_l OnBi t s( 7) ) , 24)
663 k = k + 1
664 Next
665
666 For i = 0 To m_Nb - 1
667 j = i * 4
668
669 UnpackFr omy( i ) , buf f , j
670 x( i ) = 0
75
671 y( i ) = 0
672 Next
673 End Sub
674
675 ' ' *******************************************************************************
676 ' ' CopyByt esASP ( SUB)
677 ' '
678 ' ' Sl ower non- API f unct i on you can use t o copy ar r ay dat a
679 ' ' *******************************************************************************
680 ' Pr i vat e Sub CopyByt esASP( byt Dest ( ) As Byt e, _
681 ' l Dest St ar t As Long, _
682 ' byt Sour ce( ) As Byt e, _
683 ' l Sour ceSt ar t As Long, _
684 ' l Lengt h As Long)
685 ' Di ml Count As Long
686 '
687 ' l Count = 0
688 ' Do
689 ' byt Dest ( l Dest St ar t + l Count ) = byt Sour ce( l Sour ceSt ar t + l Count )
690 ' l Count = l Count + 1
691 ' Loop Unt i l l Count = l Lengt h
692 ' End Sub
693
694 ' *******************************************************************************
695 ' I sI ni t i al i zed ( FUNCTI ON)
696 ' *******************************************************************************
697 Pr i vat e Funct i on I sI ni t i al i zed( ByRef vAr r ay As Var i ant ) As Bool ean
698 On Er r or Resume Next
699
700 I sI ni t i al i zed = I sNumer i c( UBound( vAr r ay) )
701 End Funct i on
702
703 ' *******************************************************************************
704 ' Encr ypt Dat a ( FUNCTI ON)
705 '
706 ' Takes t he message, what ever t he si ze, and passwor d i n one cal l and does
707 ' ever yt hi ng f or you t o r et ur n an encoded/ encr ypt ed message
708 ' *******************************************************************************
709 Publ i c Funct i on Encr ypt Dat a( byt Message( ) As Byt e, _
710 byt Passwor d( ) As Byt e) As Byt e( )
711 Di mbyt Key( 31) As Byt e
712 Di mbyt I n( ) As Byt e
713 Di mbyt Out ( ) As Byt e
714 Di mbyt Temp( 31) As Byt e
715 Di ml Count As Long
716 Di ml Lengt h As Long
717 Di ml EncodedLengt h As Long
718 Di mbyt Len( 3) As Byt e
719 Di ml Posi t i on As Long
720
721 I f Not I sI ni t i al i zed( byt Message) Then
722 Exi t Funct i on
723 End I f
724 I f Not I sI ni t i al i zed( byt Passwor d) Then
725 Exi t Funct i on
726 End I f
727
728 ' Use f i r st 32 byt es of t he passwor d f or t he key
729 For l Count = 0 To UBound( byt Passwor d)
730 byt Key( l Count ) = byt Passwor d( l Count )
731 I f l Count = 31 Then
732 Exi t For
733 End I f
734 Next
735
736 ' Pr epar e t he key; assume 256 bi t bl ock and key si ze
737 gent abl es
738 gkey 8, 8, byt Key
739
740 ' We ar e goi ng t o put t he message si ze on t he f r ont of t he message
741 ' i n t he f i r st 4 byt es. I f t he l engt h i s mor e t han a max i nt we ar e
742 ' i n t r oubl e
743 l Lengt h = UBound( byt Message) + 1
744 l EncodedLengt h = l Lengt h + 4
745
746 ' The encoded l engt h i ncl udes t he 4 byt es st uf f ed on t he f r ont
76
747 ' and i s padded out t o be modul us 32
748 I f l EncodedLengt h Mod 32 <> 0 Then
749 l EncodedLengt h = l EncodedLengt h + 32 - ( l EncodedLengt h Mod 32)
750 End I f
751 ReDi mbyt I n( l EncodedLengt h - 1)
752 ReDi mbyt Out ( l EncodedLengt h - 1)
753
754 ' Put t he l engt h on t he f r ont
755 ' * Unpack l Lengt h, byt I n
756 CopyMemor y Var Pt r ( byt I n( 0) ) , Var Pt r ( l Lengt h) , 4
757 ' Put t he r est of t he message af t er i t
758 ' * CopyByt esASP byt I n, 4, byt Message, 0, l Lengt h
759 CopyMemor y Var Pt r ( byt I n( 4) ) , Var Pt r ( byt Message( 0) ) , l Lengt h
760
761 ' Encr ypt a bl ock at a t i me
762 For l Count = 0 To l EncodedLengt h - 1 St ep 32
763 ' * CopyByt esASP byt Temp, 0, byt I n, l Count , 32
764 CopyMemor y Var Pt r ( byt Temp( 0) ) , Var Pt r ( byt I n( l Count ) ) , 32
765 Encr ypt byt Temp
766 ' * CopyByt esASP byt Out , l Count , byt Temp, 0, 32
767 CopyMemor y Var Pt r ( byt Out ( l Count ) ) , Var Pt r ( byt Temp( 0) ) , 32
768 Next
769
770 Encr ypt Dat a = byt Out
771 End Funct i on
772
773 ' *******************************************************************************
774 ' Decr ypt Dat a ( FUNCTI ON)
775 '
776 ' Opposi t e of Encr ypt dat a
777 ' *******************************************************************************
778 Publ i c Funct i on Decr ypt Dat a( byt I n( ) As Byt e, _
779 byt Passwor d( ) As Byt e) As Byt e( )
780 Di mbyt Message( ) As Byt e
781 Di mbyt Key( 31) As Byt e
782 Di mbyt Out ( ) As Byt e
783 Di mbyt Temp( 31) As Byt e
784 Di ml Count As Long
785 Di ml Lengt h As Long
786 Di ml EncodedLengt h As Long
787 Di mbyt Len( 3) As Byt e
788 Di ml Posi t i on As Long
789
790 I f Not I sI ni t i al i zed( byt I n) Then
791 Exi t Funct i on
792 End I f
793 I f Not I sI ni t i al i zed( byt Passwor d) Then
794 Exi t Funct i on
795 End I f
796
797 l EncodedLengt h = UBound( byt I n) + 1
798
799 I f l EncodedLengt h Mod 32 <> 0 Then
800 Exi t Funct i on
801 End I f
802
803 ' Use f i r st 32 byt es of t he passwor d f or t he key
804 For l Count = 0 To UBound( byt Passwor d)
805 byt Key( l Count ) = byt Passwor d( l Count )
806 I f l Count = 31 Then
807 Exi t For
808 End I f
809 Next
810
811 ' Pr epar e t he key; assume 256 bi t bl ock and key si ze
812 gent abl es
813 gkey 8, 8, byt Key
814
815 ' The out put ar r ay needs t o be t he same si ze as t he i nput ar r ay
816 ReDi mbyt Out ( l EncodedLengt h - 1)
817
818 ' Decr ypt a bl ock at a t i me
819 For l Count = 0 To l EncodedLengt h - 1 St ep 32
820 ' * CopyByt esASP byt Temp, 0, byt I n, l Count , 32
821 CopyMemor y Var Pt r ( byt Temp( 0) ) , Var Pt r ( byt I n( l Count ) ) , 32
822 Decr ypt byt Temp
77
823 ' * CopyByt esASP byt Out , l Count , byt Temp, 0, 32
824 CopyMemor y Var Pt r ( byt Out ( l Count ) ) , Var Pt r ( byt Temp( 0) ) , 32
825 Next
826
827 ' Get t he or i gi nal l engt h of t he st r i ng f r omt he f i r st 4 byt es
828 ' * l Lengt h = Pack( byt Out )
829 CopyMemor y Var Pt r ( l Lengt h) , Var Pt r ( byt Out ( 0) ) , 4
830
831 ' Make sur e t he l engt h i s consi st ent wi t h our dat a
832 I f l Lengt h > l EncodedLengt h - 4 Then
833 Exi t Funct i on
834 End I f
835
836 ' Pr epar e t he out put message byt e ar r ay
837 ReDi mbyt Message( l Lengt h - 1)
838 ' * CopyByt esASP byt Message, 0, byt Out , 4, l Lengt h
839 CopyMemor y Var Pt r ( byt Message( 0) ) , Var Pt r ( byt Out ( 4) ) , l Lengt h
840
841 Decr ypt Dat a = byt Message
842 End Funct i on

The modules of Futronic fingerprint in Building Security System
FP_BiOpers.bas
Control of Futronic fingerprint scanner
1 Publ i c Const I NVALI D_HANDLE_VALUE = - 1
2
3 Decl ar e Funct i on Var Pt r Ar r ay Li b " msvbvm60. dl l " Al i as " Var Pt r " ( Var ( ) As Any) As Long
4 Decl ar e Funct i on Var Pt r Li b " msvbvm60. dl l " ( Var As Any) As Long
5
6 Publ i c Decl ar e Funct i on MessageBeep Li b " user 32" ( ByVal wType As Long) As Long
7 Publ i c Decl ar e Funct i on Updat eWi ndow Li b " user 32" ( ByVal hwnd As Long) As Long
8 Publ i c Last Si gnal As Long
9
10 Di mi As I nt eger
11
12
13 '
14 ' cbCont r ol - user ' s cal l back f unct i on f or cont r ol t he enr ol l ment or
15 ' ver i f i cat i on execut i on f l ow.
16 ' Ar gument l i st :
17 ' usr Cont ext ( i nput ) - user - def i ned cont ext i nf or mat i on;
18 ' St at eMask ( i nput ) - a bi t mask i ndi cat i ng what ar gument s ar e pr ovi ded;
19 ' pResponse ( out put ) - API f unct i on execut i on cont r ol i s achi eved t hr ough
20 ' t hi s val ue;
21 ' Si gnal ( i nput ) - t hi s si gnal shoul d be used t o i nt er act wi t h a user ;
22 ' pBi t map ( i nput ) - a poi nt er t o t he bi t map t o be di spl ayed.
23 '
24 Sub cbCont r ol ( ByVal usr Cont ext As Byt e, ByVal St at eMask As Long, ByVal pResponse As Long,
_
25 ByVal Si gnal As Long, ByRef pBi t map As FTR_BI TMAP)
26
27 ' f r ame show
28 I f ( St at eMask And FTR_STATE_FRAME_PROVI DED) = FTR_STATE_FRAME_PROVI DED Then
29 Updat eI mage ( pBi t map. f t r Bi t map. pDat a)
30 End I f
31
32 ' message pr i nt
33 I f ( St at eMask And FTR_STATE_SI GNAL_PROVI DED) = FTR_STATE_SI GNAL_PROVI DED Then
34 I f Si gnal <> Last Si gnal Then
35 Sel ect Case Si gnal
36 Case FTR_SI GNAL_TOUCH_SENSOR
37 ' Demo. messagebox. Capt i on = " Put your f i nger on t he scaner "
38 i = i + 1
39 V_Mode. Fi nger I mage. Pi ct ur e =
V_Mode. Fi nger I mageLi st . Li st I mages( i ) . Pi ct ur e
40 Updat eWi ndow V_Mode. hwnd
41 Case FTR_SI GNAL_TAKE_OFF
42 ' Demo. messagebox. Capt i on = " Take of f your f i nger f r omt he scaner "
43 i = i + 1
44 V_Mode. Fi nger I mage. Pi ct ur e =
V_Mode. Fi nger I mageLi st . Li st I mages( i ) . Pi ct ur e
45 Updat eWi ndow V_Mode. hwnd
78
46 End Sel ect
47 Last Si gnal = Si gnal
48 End I f
49 End I f
50
51 pResponse = FTR_CONTI NUE
52
53 ' r eset t he i ndex of Fi nger I mageLi st
54 I f ( i = 6) Then
55 i = 0
56 End I f
57
58
59 End Sub

FP_DataBase.bas
It is used to save the fingerprint template to drive and insert record to
database.
1 Publ i c Decl ar e Sub CopyMemor y Li b " ker nel 32" Al i as " Rt l MoveMemor y" _
2 ( Dest i nat i on As Any, Sour ce As Any, ByVal Lengt h As Long)
3
4 '
5 ' AddRecor d - add new r ecor d t o dat abase.
6 ' Ar gument l i st :
7 ' dat a - poi nt er of dat a f or st or e;
8 ' dLen - si ze of dat a.
9 Funct i on AddFi nger ( dat a As Long, dLen As Long, pat h As St r i ng, f i l ename As St r i ng) As Bool ean
10
11 Di mkey As St r i ng * 16
12
13 key = " t est er "
14
15 ' wr i t e "DB r ecor d" LBound
16 FPName = pat h & f i l ename & " . t ml "
17 Open FPName For Bi nar y Access Wr i t e As #1
18 Put #1, , dLen
19 Put #1, , key
20 Di mDat aAr r ( ) As Byt e
21 ReDi mDat aAr r ( dLen)
22 Cal l CopyMemor y( Dat aAr r ( 0) , ByVal dat a, dLen)
23 Put #1, , Dat aAr r
24 Cl ose #1
25
26 End Funct i on

FP_SDK_API.bas
It stores the API of Futronic fingerprint
1 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
2 '
3 ' Fut r oni c SDK t ypes
4 '
5
6 ' Gener i c byt e dat a.
7 Type FTR_DATA
8 dwSi ze As Long ' Lengt h of dat a i n byt es.
9 pDat a As Long ' Dat a poi nt er .
10 End Type
11
12 ' Fut r oni c SDK i mage dat a
13 Type FTR_BI TMAP
14 f t r Wi dt h As Long ' wi dt h i n pi xel s
15 f t r Hei ght As Long ' hei ght i n pi xel s
16 f t r Bi t map As FTR_DATA ' bi t map as FTR_DATA t ype
17 End Type
18
19 ' Ar r ay of i dent i f y r ecor ds
20 Type FTR_I DENTI FY_ARRAY
21 Tot al Number As Long ' number of FTR_I DENTI FY_RECORD
22 pMember s As Long ' poi nt er on FTR_I DENTI FY_RECORD t ype
79
23 End Type
24
25 ' I dent i f y r ecor d descr i pt i on
26 Type FTR_I DENTI FY_RECORD
27 KeyVal ue As St r i ng * 16 ' ext er nal key
28 pDat a As Long ' poi nt er on FTR_DATA t ype
29 End Type
30
31 ' Mat ch r ecor d descr i pt i on
32 Type FTR_MATCHED_RECORD
33 KeyVal ue As St r i ng * 16 ' ext er nal key
34 Far At t ai ned As Long
35 End Type
36
37 ' Ar r ay of mat ch r ecor ds
38 Type FTR_MATCHED_ARRAY
39 Tot al Number As Long ' number of FTR_MATCHED_RECORD
40 pMember s As Long ' poi nt er on FTR_MATCHED_RECORD
41 End Type
42
43
44 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
45 '
46 ' Fut r oni c SDK const ant s
47 '
48
49 ' Ret ur n code val ues.
50 Publ i c Const FTR_RETCODE_ERROR_BASE As I nt eger = 1 ' Base val ue f or t he er r or codes.
51 Publ i c Const FTR_RETCODE_DEVI CE_BASE As I nt eger =200 ' Base val ue f or t he devi ce er r or
codes.
52
53 Publ i c Const FTR_RETCODE_OK As I nt eger = 0 ' Successf ul f unct i on compl et i on.
54
55 Publ i c Const FTR_RETCODE_NO_MEMORY As I nt eger = FTR_RETCODE_ERROR_BASE + 1
56 Publ i c Const FTR_RETCODE_I NVALI D_ARG As I nt eger = FTR_RETCODE_ERROR_BASE + 2
57 Publ i c Const FTR_RETCODE_ALREADY_I N_USE As I nt eger = FTR_RETCODE_ERROR_BASE + 3
58 Publ i c Const FTR_RETCODE_I NVALI D_PURPOSE As I nt eger = FTR_RETCODE_ERROR_BASE + 4
59 Publ i c Const FTR_RETCODE_I NTERNAL_ERROR As I nt eger = FTR_RETCODE_ERROR_BASE + 5
60 Publ i c Const FTR_RETCODE_UNABLE_TO_CAPTURE As I nt eger = FTR_RETCODE_ERROR_BASE + 6
61 Publ i c Const FTR_RETCODE_CANCELED_BY_USER As I nt eger = FTR_RETCODE_ERROR_BASE + 7
62 Publ i c Const FTR_RETCODE_NO_MORE_RETRI ES As I nt eger = FTR_RETCODE_ERROR_BASE + 8
63
64 Publ i c Const FTR_RETCODE_FRAME_SOURCE_NOT_SET As I nt eger = FTR_RETCODE_DEVI CE_BASE + 1
65 Publ i c Const FTR_RETCODE_DEVI CE_NOT_CONNECTED As I nt eger = FTR_RETCODE_DEVI CE_BASE + 2
66 Publ i c Const FTR_RETCODE_DEVI CE_FAI LURE As I nt eger = FTR_RETCODE_DEVI CE_BASE + 3
67 Publ i c Const FTR_RETCODE_EMPTY_FRAME As I nt eger = FTR_RETCODE_DEVI CE_BASE + 4
68
69 ' Val ues used f or t he par amet er def i ni t i on ( FTRSet Par amand FTRGet Par am) .
70 Publ i c Const FTR_PARAM_I MAGE_WI DTH As Long = 1
71 Publ i c Const FTR_PARAM_I MAGE_HEI GHT As Long = 2
72 Publ i c Const FTR_PARAM_I MAGE_SI ZE As Long = 3
73 Publ i c Const FTR_PARAM_CB_FRAME_SOURCE As Long = 4
74 Publ i c Const FTR_PARAM_CB_CONTROL As Long = 5
75 Publ i c Const FTR_PARAM_MAX_TEMPLATE_SI ZE As Long = 6
76 Publ i c Const FTR_PARAM_MAX_FAR_REQUESTED As Long = 7
77 Publ i c Const FTR_PARAM_MAX_MODELS As Long = 10
78 ' Avai l abl e f r ame sour ces. These devi ce i dent i f i er s ar e i nt ended t o be used
79 ' wi t h t he FTR_PARAM_CB_FRAME_SOURCE par amet er .
80 Publ i c Const FSD_FUTRONI C_USB As Long =1 ' Fut r oni c USB Fi nger pr i nt Scanner Devi ce.
81
82 '
83 ' User cal l back f unct i on def i ni t i ons
84 '
85 ' St at e bi t mask val ues f or user cal l back f unct i on.
86 Publ i c Const FTR_STATE_FRAME_PROVI DED As Long = 1
87 Publ i c Const FTR_STATE_SI GNAL_PROVI DED As Long = 2
88 ' Si gnal val ues.
89 Publ i c Const FTR_SI GNAL_UNDEFI NED As Long = 0
90 Publ i c Const FTR_SI GNAL_TOUCH_SENSOR As Long = 1
91 Publ i c Const FTR_SI GNAL_TAKE_OFF As Long = 2
92 ' Response val ues
93 Publ i c Const FTR_CANCEL As Long = 1
94 Publ i c Const FTR_CONTI NUE As Long = 2
95
96 ' Val ues used f or t he pur pose def i ni t i on
97 Publ i c Const FTR_PURPOSE_I DENTI FY As Long = 2
80
98 Publ i c Const FTR_PURPOSE_ENROLL As Long = 3
99
100
101 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
102 '
103 ' Fut r oni c SDK f unct i on pr ot ot ypes
104 '
105 Decl ar e Funct i on FTRI ni t i al i ze Li b " Ft r API . DLL" ( ) As I nt eger
106 Decl ar e Funct i on FTRTer mi nat e Li b " Ft r API . DLL" ( ) As I nt eger
107 Decl ar e Funct i on FTRSet Par amLi b " Ft r API . DLL" _
108 ( ByVal Par amAs Long, ByVal val ue As Any) As I nt eger
109 Decl ar e Funct i on FTRGet Par amLi b " Ft r API . DLL" _
110 ( ByVal Par amAs Long, ByRef val ue As Any) As I nt eger
111 Decl ar e Funct i on FTRCapt ur eFr ame Li b " Ft r API . DLL" _
112 ( ByVal usr Cont ext As Any, ByRef pFr ameBuf As Any) As I nt eger
113 Decl ar e Funct i on FTREnr ol l Li b " Ft r API . DLL" _
114 ( ByVal usr Cont ext As Any, ByVal Pur pose As Long, ByRef pTempl at e As FTR_DATA) As I nt eger
115 Decl ar e Funct i on FTRVer i f y Li b " Ft r API . DLL" _
116 ( ByVal usr Cont ext As Any, ByRef pTempl at e As FTR_DATA, ByRef pResul t As Bool ean, _
117 ByRef pFARVer i f y As Long) As I nt eger
118 Decl ar e Funct i on FTRSet BaseTempl at e Li b " Ft r API . DLL" _
119 ( ByRef pTempl at e As FTR_DATA) As I nt eger
120 Decl ar e Funct i on FTRI dent i f y Li b " Ft r API . DLL" _
121 ( ByRef pAI dent As FTR_I DENTI FY_ARRAY, ByRef pdwMat chCnt As Long, _
122 ByRef pAMat ch As FTR_MATCHED_ARRAY) As Long
123

FP_ViewWnd.bas
It is used for create the area to show fingerprint image.
1 Publ i c Const WM_PAI NT = &HF
2 Publ i c Const WM_ERASEBKGND = &H14
3 Publ i c Const WM_DESTROY = &H2
4 Publ i c Const COLOR_WI NDOWTEXT = 8
5 Publ i c Const WS_CHI LD = &H40000000
6 Publ i c Const WS_VI SI BLE = &H10000000
7 Publ i c Const WS_EX_DLGMODALFRAME = &H1&
8 Publ i c Const BI _RGB = 0&
9 Publ i c Const DI B_RGB_COLORS = 0 ' col or t abl e i n RGBs
10
11 Publ i c Type RECT
12 Lef t As Long
13 Top As Long
14 Ri ght As Long
15 Bot t omAs Long
16 End Type
17
18 Publ i c Type PAI NTSTRUCT
19 hdc As Long
20 f Er ase As Long
21 r cPai nt As RECT
22 f Rest or e As Long
23 f I ncUpdat e As Long
24 r gbReser ved( 32) As Byt e
25 End Type
26
27 Publ i c Type WNDCLASS
28 st yl e As Long
29 l pf nwndpr oc As Long
30 cbCl sext r a As Long
31 cbWndExt r a2 As Long
32 hI nst ance As Long
33 hI con As Long
34 hCur sor As Long
35 hbr Backgr ound As Long
36 l pszMenuName As St r i ng
37 l pszCl assName As St r i ng
38 End Type
39
40 Publ i c Type RGBQUAD
41 r gbBl ue As Byt e
42 r gbGr een As Byt e
43 r gbRed As Byt e
44 r gbReser ved As Byt e
81
45 End Type
46
47 Publ i c Type PALETTEENTRY
48 peRed As Byt e
49 peGr een As Byt e
50 peBl ue As Byt e
51 peFl ags As Byt e
52 End Type
53
54 Publ i c Type LOGPALETTE
55 pal Ver si on As I nt eger
56 pal NumEnt r i es As I nt eger
57 pal Pal Ent r y( 255) As PALETTEENTRY
58 End Type
59
60 Publ i c Type BI TMAPI NFOHEADER ' 40 byt es
61 bi Si ze As Long
62 bi Wi dt h As Long
63 bi Hei ght As Long
64 bi Pl anes As I nt eger
65 bi Bi t Count As I nt eger
66 bi Compr essi on As Long
67 bi Si zeI mage As Long
68 bi XPel sPer Met er As Long
69 bi YPel sPer Met er As Long
70 bi Cl r Used As Long
71 bi Cl r I mpor t ant As Long
72 End Type
73
74 Publ i c Type BI TMAPI NFO
75 bmi Header As BI TMAPI NFOHEADER
76 bmi Col or s As RGBQUAD
77 End Type
78
79 Publ i c Decl ar e Funct i on Begi nPai nt Li b " user 32" ( ByVal hwnd As Long, l pPai nt As PAI NTSTRUCT)
As Long
80
81 Publ i c Decl ar e Funct i on EndPai nt Li b " user 32" ( ByVal hwnd As Long, l pPai nt As PAI NTSTRUCT)
As Long
82
83 Publ i c Decl ar e Funct i on Def Wi ndowPr oc Li b " user 32" Al i as " Def Wi ndowPr ocA" _
84 ( ByVal hwnd As Long, ByVal wMsg As Long, ByVal wPar amAs Long, ByVal l Par amAs Long)
As Long
85
86 Publ i c Decl ar e Funct i on LoadCur sor Li b " user 32" Al i as " LoadCur sor A" _
87 ( ByVal hI nst ance As Long, ByVal l pCur sor Name As St r i ng) As Long
88
89 Publ i c Decl ar e Funct i on Regi st er Cl ass Li b " user 32" Al i as " Regi st er Cl assA" ( ByRef Cl ass As
WNDCLASS) As Long
90
91 Publ i c Decl ar e Funct i on Cr eat eWi ndowEx Li b " user 32" Al i as " Cr eat eWi ndowExA" _
92 ( ByVal dwExSt yl e As Long, ByVal l pCl assName As St r i ng, ByVal l pWi ndowName As St r i ng,
_
93 ByVal dwSt yl e As Long, ByVal x As Long, ByVal y As Long, ByVal nWi dt h As Long, _
94 ByVal nHei ght As Long, ByVal hWndPar ent As Long, ByVal hMenu As Long, _
95 ByVal hI nst ance As Long, l pPar amAs Any) As Long
96
97 Publ i c Decl ar e Funct i on Cr eat ePal et t e Li b " gdi 32" ( l pLogPal et t e As LOGPALETTE) As Long
98
99 Publ i c Decl ar e Funct i on Sel ect Pal et t e Li b " gdi 32" ( ByVal hdc As Long, _
100 ByVal hPal et t e As Long, ByVal bFor ceBackgr ound As Long) As Long
101
102 Publ i c Decl ar e Funct i on Real i zePal et t e Li b " gdi 32" ( ByVal hdc As Long) As Long
103
104 Publ i c Decl ar e Funct i on Set DI Bi t sToDevi ce Li b " gdi 32" _
105 ( ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As
Long, _
106 ByVal Sr cX As Long, ByVal Sr cY As Long, ByVal Scan As Long, ByVal NumScans As Long,
_
107 Bi t s As Any, Bi t sI nf o As Any, ByVal wUsage As Long) As Long
108
109 Publ i c Decl ar e Funct i on Get DC Li b " user 32" ( ByVal hwnd As Long) As Long
110
111 Publ i c Decl ar e Funct i on Rel easeDC Li b " user 32" ( ByVal hwnd As Long, ByVal hdc As Long) As
Long
112
82
113 ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
114 '
115 ' Appl i cat i on dat a
116 '
117 Publ i c Const szShowCl assName As St r i ng = " ShowWndCl ass"
118
119 Publ i c hSWnd As Long ' show wi ndow handl e
120 Publ i c w_SWnd As Long ' wi dt h of show wi ndow
121 Publ i c h_SWnd As Long ' hei gt h of show wi ndow
122
123 Publ i c l pDI BHeader ( ) As Byt e
124 Publ i c l pDI BDat a( ) As Byt e
125 Publ i c l pPol Li t r a As LOGPALETTE
126 Publ i c hPGr ayscal e As Long
127
128
129 '
130 ' Updat eI mage - updat es dat a and shows t he cur r ent f i nger pr i nt i mage.
131 ' Ar gument l i st :
132 ' sr cDat a - new f i nger pr i nt i mage.
133 '
134 Sub Updat eI mage( ByVal sr cDat a As Long)
135 Di mi Cyc As Long
136 Di mhdc As Long
137
138 ' r ot at e an i mage whi l e copyi ng dat a t o t he DI B dat a
139 For i Cyc = 0 To h_SWnd - 1
140 Cal l CopyMemor y( l pDI BDat a( ( h_SWnd - i Cyc - 1) * w_SWnd) , _
141 ByVal ( sr cDat a + i Cyc * w_SWnd) , w_SWnd)
142 Next i Cyc
143
144 ' show t he f i nger pr i nt i mage
145 hdc = Get DC( hSWnd)
146 DI BShow ( hdc)
147 Cal l Rel easeDC( hSWnd, hdc)
148
149 End Sub
150
151
152 '
153 ' DI BShow - shows t he capt ur ed f i nger pr i nt i mage.
154 ' Ar gument l i st :
155 ' hdc - show wi ndow devi ce cont ext .
156 '
157 Sub DI BShow( ByVal hdc As Long)
158
159 Cal l Sel ect Pal et t e( hdc, hPGr ayscal e, 0)
160 Cal l Real i zePal et t e( hdc)
161
162 Cal l Set DI Bi t sToDevi ce( hdc, 0, 0, w_SWnd, h_SWnd, _
163 0, 0, 0, h_SWnd, l pDI BDat a( 0) , l pDI BHeader ( 0) , DI B_RGB_COLORS)
164
165 End Sub
166
167 '
168 ' Pr epar eVi ew - al l ocat es memor y & i ni t i al i zes dat a f or f i nger pr i nt vi ewi ng.
169 ' Ar gument l i st :
170 ' w, h, d - wi dt h, hei ght and col or dept h of f i nger pr i nt i mage.
171 ' Ret ur n val ue:
172 ' Tr ue - success;
173 ' Fal se - er r or .
174 '
175 Funct i on Pr epar eVi ew( w As Long, h As Long, d As I nt eger ) As Bool ean
176
177 Di mdi b_BMI nf o As BI TMAPI NFO
178 Di mdi b_bmi Col or s( 255) As RGBQUAD
179 Di mi Cyc As Long
180
181 ' suppor t t he 256- col or s DI B onl y
182 I f d <> 8 Then
183 Pr epar eVi ew = Fal se
184 Exi t Funct i on
185 End I f
186
187 ' al l ocat e memor y f or DI B i mage
188 ReDi ml pDI BHeader ( Len( di b_BMI nf o) + Len( di b_BMI nf o. bmi Col or s) * 255)
83
189 ReDi ml pDI BDat a( w * h)
190
191 ' f i l l t he DI B header
192 di b_BMI nf o. bmi Header . bi Si ze = Len( di b_BMI nf o. bmi Header )
193 di b_BMI nf o. bmi Header . bi Wi dt h = w
194 di b_BMI nf o. bmi Header . bi Hei ght = h
195 di b_BMI nf o. bmi Header . bi Pl anes = 1
196 di b_BMI nf o. bmi Header . bi Bi t Count = d
197 di b_BMI nf o. bmi Header . bi Compr essi on = BI _RGB
198
199 ' f i l l t he l ogi cal pal et t e
200 l pPol Li t r a. pal Ver si on = 768
201 l pPol Li t r a. pal NumEnt r i es = 256
202
203 ' i ni t i al i ze l ogi cal and DI B pal et t es t o gr ayscal e
204 For i Cyc = 0 To 255
205 di b_bmi Col or s( i Cyc) . r gbBl ue = i Cyc
206 di b_bmi Col or s( i Cyc) . r gbGr een = i Cyc
207 di b_bmi Col or s( i Cyc) . r gbRed = i Cyc
208 l pPol Li t r a. pal Pal Ent r y( i Cyc) . peBl ue = i Cyc
209 l pPol Li t r a. pal Pal Ent r y( i Cyc) . peGr een = i Cyc
210 l pPol Li t r a. pal Pal Ent r y( i Cyc) . peRed = i Cyc
211 Next i Cyc
212
213 ' pr epar e DI B header
214 Cal l CopyMemor y( l pDI BHeader ( 0) , di b_BMI nf o. bmi Header , _
215 Len( di b_BMI nf o. bmi Header ) )
216 Cal l CopyMemor y( l pDI BHeader ( 40) , di b_bmi Col or s( 0) , _
217 Len( di b_bmi Col or s( 0) ) * 256)
218
219 ' cr eat e a gr ayscal e pal et t e
220 hPGr ayscal e = Cr eat ePal et t e( l pPol Li t r a)
221
222 Pr epar eVi ew = Tr ue
223
224 End Funct i on
225
226
227 '
228 ' Get FunAddr - get f unct i on addr ess
229 '
230 Funct i on Get FunAddr ( ByVal l ngFnPt r As Long) As Long
231 Get FunAddr = l ngFnPt r
232 End Funct i on
233
234
235 '
236 ' ShowWndPr oc - vi ew wi ndow cal l back f unct i on
237 '
238 Funct i on ShowWndPr oc( ByVal hwnd As Long, ByVal msg As Long, ByVal wPar amAs Long, _
239 ByVal l Par amAs Long) As Long
240 Di mhdc As Long
241 Di mps As PAI NTSTRUCT
242
243 Sel ect Case msg
244 Case WM_PAI NT
245 hdc = Begi nPai nt ( hwnd, ps)
246 DI BShow ( hdc)
247 Cal l EndPai nt ( hwnd, ps)
248 Case WM_ERASEBKGND
249 ShowWndPr oc = 1
250 Exi t Funct i on
251 Case WM_DESTROY
252 ShowWndPr oc = 0
253 Exi t Funct i on
254 End Sel ect
255
256 ShowWndPr oc = Def Wi ndowPr oc( hwnd, msg, wPar am, l Par am)
257
258 End Funct i on
259
260
261 '
262 ' weRegShowWnd - r egi st er wi ndow cl ass f or vi ewi ng f i nger pr i nt i mage
263 ' Ret ur n val ue:
264 ' 0 - er r or whi l e r egi st er wi ndow cl ass
84
265 Funct i on weRegShowWnd( ) As Long
266 Di mCl ass As WNDCLASS
267
268 Cl ass. st yl e = 0
269 Cl ass. l pf nwndpr oc = Get FunAddr ( Addr essOf ShowWndPr oc)
270 Cl ass. cbCl sext r a = 0
271 Cl ass. cbWndExt r a2 = 0
272 Cl ass. hI nst ance = VB. App. hI nst ance
273 Cl ass. hI con = 0
274 Cl ass. hCur sor = 0
275 Cl ass. hbr Backgr ound = COLOR_WI NDOWTEXT + 1
276 Cl ass. l pszMenuName = Empt y
277 Cl ass. l pszCl assName = szShowCl assName
278
279 weRegShowWnd = Regi st er Cl ass( Cl ass)
280
281 End Funct i on
282
283
284 '
285 ' Cr eat eShowWnd - cr eat e wi ndow f or vi ewi ng f i nger pr i nt i mage
286 ' Ar gument l i st :
287 ' hPar ent - par ent wi ndow;
288 ' x, y - upper l ef t cor ner i n par ent ;
289 ' w, h - wi ndow' s wi dt h and hei ght .
290 ' Ret ur n val ue:
291 ' 0 - er r or cr eat i ng.
292 '
293 Funct i on Cr eat eShowWnd( ByVal hPar ent As Long, ByVal x As Long, ByVal y As Long, _
294 ByVal w As Long, ByVal h As Long) As Long
295
296 ' st or e show wi ndow di mensi on
297 w_SWnd = w
298 h_SWnd = h
299
300 ' r egi st er wi ndow cl ass
301 weRegShowWnd
302
303 ' pr epar e dat a f or vi ew f i nger pr i nt i mage
304 I f Pr epar eVi ew( w, h, 8) = Fal se Then
305 Cr eat eShowWnd = 0
306 Exi t Funct i on
307 End I f
308
309 ' cr eat e show wi ndow
310 hSWnd = Cr eat eWi ndowEx( 0, szShowCl assName, 0&, WS_CHI LD + WS_VI SI BLE +
WS_EX_DLGMODALFRAME, _
311 x, y, w, h, hPar ent , 0, VB. App. hI nst ance, 0&)
312 Cr eat eShowWnd = hSWnd
313 I f hSWnd = 0 Then
314 Exi t Funct i on
315 End I f
316 Updat eWi ndow ( hPar ent )
317
318 End Funct i on

The modules of Administration Tools and Building Security System
MySQLADODB.bas
It is used to connect the MySQL database.
1 Publ i c conn As New ADODB. Connect i on
2 Publ i c st r Ser ver I P As St r i ng
3
4 Publ i c Funct i on openDBcn( )
5
6 I f conn. St at e = 1 Then conn. Cl ose
7
8 st r Ser ver I P = get Cont ent ( " ser ver I P" )
9
10 conn. Cur sor Locat i on = adUseCl i ent
11
12 ' connect MySQL dat abase ser ver
13 conn. Connect i onSt r i ng = " DRI VER={MySQL ODBC 3. 51 Dr i ver }; " _
85
14 & " SERVER=" & st r Ser ver I P & " ; " _
15 & " DATABASE=i ve_f yp; " _
16 & " UI D=i ve; " _
17 & " PWD=i ve; " _
18 & " OPTI ON=" & 1 + 2 + 8 + 32 + 2048 + 163841
19 conn. Open
20 End Funct i on

ReadINI.bas
It is used to read the config.ini file.
It is used for create the area to show fingerprint image.
1 Opt i on Expl i ci t
2
3 Publ i c Const st r I nf oExcapeChr = " #" ' escape char act er i n I nf o f i l e
4 Publ i c Const i nt I nf oLengt h = 1024 ' Set I nf o f i l e l engt h
5
6 Publ i c st r I nf oName( i nt I nf oLengt h) As St r i ng ' I nf o Name
7 Publ i c st r I nf oCont ent ( i nt I nf oLengt h) As St r i ng ' I nf o Cont ent
8
9 ' Pr ogr amst ar t f unct i on
10 Sub mai n( )
11 Cal l r eadI nf o( App. pat h & " \ conf i g. i ni " , Fal se)
12 ' MsgBox get Cont ent ( " ser ver I P" )
13
14 Cal l openDBcn
15 Sel ect _Mode. Show
16 End Sub
17
18
19 Publ i c Sub r eadI nf o( st r I nf oPat h As St r i ng, bl nRel oad As Bool ean)
20
21 Di mst r Li neTmp As St r i ng
22 Di ml ngAssi gnPos As Long
23 Di mi dxCnt As Long
24
25 ' Check t he I nf o Fi l e var i s bl ank or not
26 I f Len( st r I nf oPat h) = 0 Then
27 ' MsgBox( )
28 Exi t Sub
29 End I f
30
31 ' t o Er ase t he ar r ay or not
32 I f bl nRel oad Then
33 Er ase st r I nf oName( )
34 Er ase st r I nf oCont ent ( )
35
36 st r I nf oName( 0) = " "
37 st r I nf oCont ent ( 0) = " "
38 End I f
39
40 ' Open i nput f i l e " st ar t CD. i nf "
41 Open st r I nf oPat h For I nput As #1
42
43 i dxCnt = - 1
44 Whi l e Not EOF( 1)
45
46 Li ne I nput #1, st r Li neTmp
47
48 Sel ect Case Lef t $( st r Li neTmp, 1)
49 Case st r I nf oExcapeChr
50 ' Not hi ng t o Do and go t o next l i ne
51 Case Chr ( 13)
52 ' Not hi ng t o Do and go t o next l i ne
53 Case Chr ( 10)
54 ' Not hi ng t o Do and go t o next l i ne
55 Case El se
56 i dxCnt = i dxCnt + 1
57
58 l ngAssi gnPos = I nSt r ( 1, st r Li neTmp, " =" )
59 ' MsgBox l ngAssi gnPos
60
61 st r I nf oName( i dxCnt ) = Lef t ( st r Li neTmp, l ngAssi gnPos - 1)
86
62 st r I nf oCont ent ( i dxCnt ) =Ri ght ( st r Li neTmp, Len( st r Li neTmp) - l ngAssi gnPos)
63
64 ' MsgBox st r I nf oName( i dxCnt ) & " - " & st r I nf oCont ent ( i dxCnt )
65 End Sel ect
66
67 Wend
68
69 Cl ose #1
70
71 ' MsgBox st r Li neTmp
72
73 End Sub
74
75 ' Get I nf or mat i on Cont ent st r i ng i n l oaded ar r ay wi t h I nf or mat i on Name
76 Publ i c Funct i on get Cont ent ( st r I nf or mat i onName As St r i ng)
77 Di mi As I nt eger
78 Di mst r FoundCont ent As St r i ng
79
80 st r FoundCont ent = " "
81 For i = LBound( st r I nf oName) To UBound( st r I nf oName)
82
83 ' Compar e t he I nf or mat i on Name
84 I f st r I nf oName( i ) = st r I nf or mat i onName Then
85 st r FoundCont ent = st r I nf oCont ent ( i )
86 End I f
87
88 Next i
89
90 get Cont ent = st r FoundCont ent
91 End Funct i on

The programming codes of form in Administration Tools
frmAdmin.frm
It is the tools main form.
1 Opt i on Expl i ci t
2 Di mRemot ePat h As St r i ng
3 Di mComput er Name As St r i ng
4 Di mFol der Name As St r i ng
5 Di mPhot oName As St r i ng
6
7 Pr i vat e Sub cmdHAdd_Cl i ck( )
8 f r mAdd. Show ( vbModal )
9 End Sub
10
11 Pr i vat e Sub cmdHDel et e_Cl i ck( )
12 Di mi nt HI D As I nt eger
13
14 i nt HI D = Mi d( l vwHHol der . Sel ect edI t em. key, 4, Len( l vwHHol der . Sel ect edI t em. key) - 3)
15
16 I f l vwHHol der . Sel ect edI t em. Sel ect ed Then
17 I f MsgBox( " Ar e you sur e del et e t hi s househol der ?" , vbExcl amat i on +vbYesNo, " Del et e
Recor d" ) = vbYes Then
18 conn. Execut e " DELETE FROM f yp_t bl HouseHol der WHERE i nt Hol der I D = " & i nt HI D &
" ; "
19 showRecor d
20 End I f
21 End I f
22 End Sub
23
24 Pr i vat e Sub cmdHEdi t _Cl i ck( )
25 I f Sel ect edHHI D = 0 Then
26 MsgBox " Pl ease sel ect househol der t o edi t . " , vbExcl amat i on, " Message"
27 El se
28 f r mEdi t . Show ( vbModal )
29 End I f
30 End Sub
31
32 Pr i vat e Sub cmdHHLSear ch_Cl i ck( )
33 showRecor d
34 End Sub
35
36 Pr i vat e Sub cmdHRef r esh_Cl i ck( )
87
37 ' l vwHHol der . Ref r esh
38 showRecor d
39 End Sub
40
41 Pr i vat e Sub cmdHSear ch_Cl i ck( )
42 l vwHHol der . Li st I t ems. Cl ear
43 showRecor d
44 End Sub
45
46 Pr i vat e Sub cmdVSear ch_Cl i ck( )
47 showRecor d
48 End Sub
49
50 Pr i vat e Sub For m_Load( )
51 Comput er Name = st r Ser ver I P ' set comput er name
52 Fol der Name = " user dat a\ vi si t or " ' set f ol der name ( opt i onal )
53 Remot ePat h =" \ \ " & Comput er Name & " \ " & Fol der Name & " \ " ' set t he r emot e pat h t o st or e
f i l e
54
55 ' cl ose al l f r ame
56 f r aHHol der . Vi si bl e = Fal se
57 f r aHHol der Log. Vi si bl e = Fal se
58 f r aVi si t or Log. Vi si bl e = Fal se
59
60 ' set al l DTPi cker dat e
61 dt pVSel ect Day. Val ue = For mat ( Now, " dd/ mm/ yyyy" )
62 dt pHHLFr om. Val ue = For mat ( Now, " dd/ mm/ yyyy" )
63 dt pHHLTo. Val ue = For mat ( Now, " dd/ mm/ yyyy" )
64 End Sub
65
66 Pr i vat e Sub l vwHHol der _I t emCl i ck( ByVal I t emAs MSComct l Li b. Li st I t em)
67 Sel ect edHHI D = Mi d( l vwHHol der . Sel ect edI t em. key, 4, Len( l vwHHol der . Sel ect edI t em. key)
- 3)
68 End Sub
69
70 Pr i vat e Sub l vwVi si t or _Bef or eLabel Edi t ( Cancel As I nt eger )
71 Cancel = 1
72 End Sub
73
74 Pr i vat e Sub l vwVi si t or _I t emCl i ck( ByVal I t emAs MSComct l Li b. Li st I t em)
75 Di mi nt VI D As I nt eger
76
77 i nt VI D = Mi d( l vwVi si t or . Sel ect edI t em. key, 4, Len( l vwVi si t or . Sel ect edI t em. key) - 3)
78
79 Di mr s As ADODB. Recor dset
80
81 Set r s = New ADODB. Recor dset
82
83 r s. Open "SELECT * FROM f yp_t bl Vi si t or WHERE i nt Vi si t or I D = " & i nt VI D & " ; " , conn,
adOpenSt at i c, adLockReadOnl y
84
85 i mgVPhot o. Pi ct ur e = LoadPi ct ur e( Remot ePat h & r s! chr FaceDat a & " . bmp" )
86 End Sub
87
88 Pr i vat e Sub mnuExi t _Cl i ck( )
89 End
90 End Sub
91
92 Pr i vat e Sub mnuHHDB_Cl i ck( )
93 f r aHHol der . Vi si bl e = Tr ue
94 f r aHHol der Log. Vi si bl e = Fal se
95 f r aVi si t or Log. Vi si bl e = Fal se
96 showRecor d
97 End Sub
98
99 Pr i vat e Sub showRecor d( )
100 Di mr s1 As ADODB. Recor dset
101 Di mr s2 As ADODB. Recor dset
102 Di mr s3 As ADODB. Recor dset
103
104 Di mst r Phot oName As St r i ng
105 Di mst r Bui l di ng As St r i ng
106 Di mst r HName As St r i ng
107 Di mst r HHLName As St r i ng
108
109 Di mdat Sel Dat e As Dat e
88
110 Di mdat Dat eFr omAs Dat e
111 Di mdat Dat eTo As Dat e
112
113 Di mi nt HHI D As I nt eger
114 Di mi nt HHLI D As I nt eger
115
116 Di mi dxVi si t or As Long
117 Di mi dxHHol der As Long
118 Di mi dxHHLog As Long
119
120 st r Bui l di ng = " %"
121 dat Sel Dat e = dt pVSel ect Day. Val ue
122 dat Dat eFr om= dt pHHLFr om. Val ue
123 dat Dat eTo = dt pHHLTo. Val ue
124
125 I f cboBui l di ng. Text <> " Al l " Then
126 st r Bui l di ng = cboBui l di ng. Text
127 ' msgBox st r Bui l di ng
128 End I f
129
130 st r HName = " %"
131 I f t xt HHName. Text <> " " Then
132 st r HName = t xt HHName. Text
133 End I f
134
135 i nt HHI D = 0
136 I f t xt HHI D. Text <> " " Then
137 i nt HHI D = Val ( t xt HHI D. Text )
138 st r HName = " "
139 End I f
140
141 st r HHLName = " "
142 I f t xt HHLName. Text <> " " Then
143 st r HHLName = t xt HHLName. Text
144 End I f
145
146 i nt HHLI D = 0
147 I f t xt HHLI D. Text <> " " Then
148 i nt HHLI D = Val ( t xt HHLI D. Text )
149 st r HHLName = " "
150 End I f
151
152 Set r s1 = New ADODB. Recor dset
153 r s1. Open " SELECT * FROM f yp_t bl Househol der h, f yp_t bl Bui l di ng b, f yp_t bl Fl oor Fl at f
" _
154 & " WHERE ( b. i nt Bui l di ngI D = h. i nt Bui l di ngI D AND f . i nt FFI D = h. i nt FFI D) AND " _
155 & " ( h. i nt Hol der I D = " & i nt HHI D & " OR " _
156 & " h. chr Hol der Name LI KE ' " & st r HName & " ' ) ORDER BY i nt Hol der I D ASC; " , conn,
adOpenSt at i c, adLockReadOnl y
157
158 l vwHHol der . Li st I t ems. Cl ear
159 i dxHHol der = 0
160 Whi l e Not r s1. EOF
161 i dxHHol der = i dxHHol der + 1
162 l vwHHol der . Li st I t ems. Add i dxHHol der , " hI D" & r s1( " i nt Hol der I D" ) ,
r s1( " i nt Hol der I D" )
163 l vwHHol der . Li st I t ems. I t em( i dxHHol der ) . Li st SubI t ems. Add 1, , r s1( " chr Hol der Name" )
164 l vwHHol der . Li st I t ems. I t em( i dxHHol der ) . Li st SubI t ems. Add 2, , r s1( " chr Gender " )
165 l vwHHol der . Li st I t ems. I t em( i dxHHol der ) . Li st SubI t ems. Add 3, , r s1( " dat Bi r t h" )
166 l vwHHol der . Li st I t ems. I t em( i dxHHol der ) . Li st SubI t ems. Add 4, , r s1( " chr HKI D" )
167 l vwHHol der . Li st I t ems. I t em( i dxHHol der ) . Li st SubI t ems. Add 5, , r s1( " dat RegDat e" )
168 l vwHHol der . Li st I t ems. I t em( i dxHHol der ) . Li st SubI t ems. Add 6, ,
r s1( " chr Bui l di ngName" )
169 l vwHHol der . Li st I t ems. I t em( i dxHHol der ) . Li st SubI t ems. Add 7, , r s1( " chr Fl oor " ) &
r s1( " chr Fl at " )
170
171 l vwHHol der . Ref r esh
172
173 r s1. MoveNext
174 Wend
175
176 Set r s2 = New ADODB. Recor dset
177 r s2. Open " SELECT v. i nt Vi si t or I D, v. dat Ent r y, b. chr Bui l di ngName, " _
178 & "CONCAT( f . chr Fl oor , f . chr Fl at ) AS ' Fl at ' , v. chr FaceDat a, v. chr Fi nger Dat a " _
179 & " FROM f yp_t bl Vi si t or v, f yp_t bl Bui l di ng b, f yp_t bl Fl oor Fl at f " _
180 & " WHERE b. i nt Bui l di ngI D = v. i nt Bui l di ngI D AND f . i nt FFI D = v. i nt FFI D AND " _
89
181 & " b. chr Bui l di ngName LI KE ' " & st r Bui l di ng & " ' AND " _
182 & " ( v. dat Ent r y >= ' " & For mat ( dat Sel Dat e, " yyyy- mm- dd" ) & " 00: 00: 00' AND " _
183 & " v. dat Ent r y <= ' " & For mat ( dat Sel Dat e, " yyyy- mm- dd" ) & " 23: 59: 59' ) ; " , conn,
adOpenSt at i c, adLockReadOnl y
184
185 l vwVi si t or . Li st I t ems. Cl ear
186 i dxVi si t or = 0
187 Whi l e Not r s2. EOF
188 i dxVi si t or = i dxVi si t or + 1
189 l vwVi si t or . Li st I t ems. Add i dxVi si t or , " vI D" & r s2( " i nt Vi si t or I D" ) ,
r s2( " i nt Vi si t or I D" )
190 l vwVi si t or . Li st I t ems. I t em( i dxVi si t or ) . Li st SubI t ems. Add 1, , r s2( " dat Ent r y" )
191 l vwVi si t or . Li st I t ems. I t em( i dxVi si t or ) . Li st SubI t ems. Add 2, ,
r s2( " chr Bui l di ngName" )
192 l vwVi si t or . Li st I t ems. I t em( i dxVi si t or ) . Li st SubI t ems. Add 3, , r s2( " Fl at " )
193
194 l vwVi si t or . Ref r esh
195
196 r s2. MoveNext
197 Wend
198
199 Set r s3 = New ADODB. Recor dset
200
201 Cl i pboar d. Set Text " SELECT * FROM f yp_t bl Hol der Log l , f yp_t bl HouseHol der h " _
202 & " WHERE l . i nt Hol der I D = h. i nt Hol der I D AND " _
203 & " ( l . i nt Hol der I D = " & i nt HHLI D & " OR h. chr Hol der Name LI KE ' " & st r HHLName &
" ' OR" _
204 & " ( l . dat I nTi me >= ' " & For mat ( dat Dat eFr om, " yyyy- mm- dd" ) & " 00: 00: 00' AND "
_
205 & " l . dat I nTi me <= ' " & For mat ( dat Dat eTo, " yyyy- mm- dd" ) & " 23: 59: 59' ) ) ; "
206
207 r s3. Open " SELECT * FROM f yp_t bl Hol der Log l , f yp_t bl HouseHol der h " _
208 & " WHERE l . i nt Hol der I D = h. i nt Hol der I D AND " _
209 & " ( l . i nt Hol der I D = " & i nt HHLI D & " OR h. chr Hol der Name LI KE ' " & st r HHLName &
" ' ) AND " _
210 & " ( l . dat I nTi me >= ' " & For mat ( dat Dat eFr om, " yyyy- mm- dd" ) & " 00: 00: 00' AND "
_
211 & " l . dat I nTi me <= ' " & For mat ( dat Dat eTo, " yyyy- mm- dd" ) & " 23: 59: 59' ) ; " , conn,
adOpenSt at i c, adLockReadOnl y
212
213 l vwHHLog. Li st I t ems. Cl ear
214 i dxHHLog = 0
215 Whi l e Not r s3. EOF
216 i dxHHLog = i dxHHLog + 1
217 l vwHHLog. Li st I t ems. Add i dxHHLog, " l I D" & r s3( " i nt LogI D" ) , r s3( " i nt Hol der I D" )
218 l vwHHLog. Li st I t ems. I t em( i dxHHLog) . Li st SubI t ems. Add 1, , r s3( " chr Hol der Name" )
219 l vwHHLog. Li st I t ems. I t em( i dxHHLog) . Li st SubI t ems. Add 2, , r s3( " dat I nTi me" )
220
221 l vwHHLog. Ref r esh
222
223 r s3. MoveNext
224 Wend
225 End Sub
226
227 Pr i vat e Sub mnuHHLog_Cl i ck( )
228 f r aHHol der Log. Vi si bl e = Tr ue
229 f r aHHol der . Vi si bl e = Fal se
230 f r aVi si t or Log. Vi si bl e = Fal se
231 End Sub
232
233 Pr i vat e Sub mnuVLog_Cl i ck( )
234
235 f r aVi si t or Log. Vi si bl e = Tr ue
236 f r aHHol der . Vi si bl e = Fal se
237 f r aHHol der Log. Vi si bl e = Fal se
238
239 Di mr s As ADODB. Recor dset
240
241 Set r s = New ADODB. Recor dset
242 r s. Open "SELECT * FROM f yp_t bl bui l di ng; " , conn, adOpenSt at i c, adLockReadOnl y
243
244 cboBui l di ng. Cl ear
245 cboBui l di ng. AddI t em" Al l "
246 cboBui l di ng. Text = " Al l "
247 Whi l e Not r s. EOF
248
90
249 cboBui l di ng. AddI t emr s( " chr Bui l di ngName" )
250
251 r s. MoveNext
252
253 Wend
254
255 End Sub

frmAdd.frm
It is a form of add new householder.
1 Opt i on Expl i ci t
2 Di mRemot ePat h As St r i ng
3 Di mComput er Name As St r i ng
4 Di mFol der Name As St r i ng
5 Di mAESFi l ename As St r i ng
6
7 Pr i vat e Sub cmdCl ose_Cl i ck( )
8 Unl oad Me
9 End Sub
10
11 Pr i vat e Sub cmdEnr ol l _Cl i ck( )
12 ' st ar t t he capt ur e t i mer
13 t mr St ar t Cap. I nt er val = 3000
14 t mr St ar t Cap. Enabl ed = Tr ue
15 End Sub
16
17 Pr i vat e Sub cmdSave_Cl i ck( )
18 I f AESFi l ename = " " Then
19 MsgBox " Pl ease enr ol l t he f ace. " , vbCr i t i cal , " Message"
20 El se
21 AddHHol der
22 End I f
23 End Sub
24
25 Pr i vat e Sub cmdSt ar t Cam_Cl i ck( )
26 I ni t i at eCam
27 cmdEnr ol l . Enabl ed = Tr ue
28 End Sub
29
30 Pr i vat e Sub cmdSt opCam_Cl i ck( )
31 Uni ni t i at eCam
32 cmdEnr ol l . Enabl ed = Fal se
33 End Sub
34
35 Pr i vat e Sub For m_Load( )
36 Comput er Name = st r Ser ver I P ' set comput er name
37 Fol der Name = " user dat a\ househol der " ' set f ol der name ( opt i onal )
38 Remot ePat h =" \ \ " & Comput er Name & " \ " & Fol der Name & " \ " ' set t he r emot e pat h t o st or e
f i l e
39
40 ' set t he maxl engt h of al l t ext box
41 t xt Name. MaxLengt h = 255
42 t xt Year . MaxLengt h = 4
43 t xt Mont h. MaxLengt h = 2
44 t xt Day. MaxLengt h = 2
45 t xt HKI D1. MaxLengt h = 2
46 t xt HKI D2. MaxLengt h = 6
47 t xt HKI D3. MaxLengt h = 1
48
49 ' r eset al l combo box
50 cboGender . Text = cboGender . Li st ( 0)
51 cboBui l di ng. Text = cboBui l di ng. Li st ( 0)
52 cboFl oor . Text = cboFl oor . Li st ( 0)
53 cboFl at . Text = cboFl at . Li st ( 0)
54
55 cmdEnr ol l . Enabl ed = Fal se
56 t mr St ar t Cap. Enabl ed = Fal se
57
58 ' MsgBox "Pl ease enr ol l t he f ace f i r st . " , vbI nf or mat i on, " Message"
59
60 End Sub
61
62 Pr i vat e Sub I ni t i at eCam( )
91
63 ' I ni t i at e t he webcam
64 Webcam. Set Si zeType 1
65 Webcam. Set EyeThr eshol d 180000
66 Webcam. Set Thr eshol d 80000
67 Webcam. I ni t Smar t Gat e
68 Webcam. Show
69 pi cCamMask. Vi si bl e = Fal se
70 End Sub
71
72 Pr i vat e Sub Uni ni t i at eCam( )
73 ' Uni ni t i at e t he webcam
74 Webcam. Unshow
75 Webcam. Uni ni t Smar t Gat e
76 pi cCamMask. Vi si bl e = Tr ue
77 End Sub
78
79 Pr i vat e Sub For m_Unl oad( Cancel As I nt eger )
80 Uni ni t i at eCam
81 End Sub
82
83 Pr i vat e Sub GenName( )
84 Di mAESKey As CRi j ndael
85 Di mpl ai nText ( ) As Byt e
86 Di mencText ( ) As Byt e
87 Di mencPasswor d( ) As Byt e
88 Di ml Count As Long
89 Di ml Lengt h As Long
90
91 Set AESKey = New CRi j ndael ' set AESKey f r omcl ass modul es
92
93 pl ai nText = For mat ( Now, " yymmddhhmmss" )
94 encPasswor d = " " ' def aul t no passwor d
95
96 encText = AESKey. Encr ypt Dat a( pl ai nText , encPasswor d)
97 AESFi l ename = " "
98 For l Count = 0 To UBound( encText )
99 AESFi l ename = AESFi l ename & Ri ght ( " 0" & Hex( encText ( l Count ) ) , 2)
100 Next
101
102 End Sub
103
104 Pr i vat e Sub t mr St ar t Cap_Ti mer ( )
105 GenName ' gener at e t he f i l ename t o AES f or mat
106 I f ( Webcam. SaveToBmpI mageT( Remot ePat h & AESFi l ename & " . bmp" , 320, 240) ) Then ' save
bi t map f r omcamer a
107 Webcam. AppendDat a Remot ePat h & AESFi l ename & " . bmp" , Remot ePat h & AESFi l ename &
" . usr " ' save t he t empl at e f i l e f r ombi t map
108 MsgBox " Face Enr ol l ment Successf ul ! " , vbI nf or mat i on, " Face Enr ol l ment "
109 El se
110 MsgBox " Face Enr ol l ment Fai l ed! \ nPl ease t r y agai n! " , vbCr i t i cal , " Face Enr ol l ment "
111 End I f
112
113 ' st op t he t i mer af t er 3 seconds
114 I f t mr St ar t Cap. I nt er val = 3000 Then
115 t mr St ar t Cap. Enabl ed = Fal se
116 End I f
117 End Sub
118
119 Pr i vat e Sub AddHHol der ( )
120 Di mr s1 As ADODB. Recor dset
121 Di mr s2 As ADODB. Recor dset
122 Di mdat Bi r t h As Dat e
123 Di mst r HKI D As St r i ng
124
125 Set r s1 = New ADODB. Recor dset
126 r s1. Open " SELECT i nt Bui l di ngI D FROM f yp_t bl Bui l di ng WHERE chr Bui l di ngName LI KE ' " &
cboBui l di ng. Text & " ' ; " , conn, adOpenSt at i c, adLockReadOnl y
127
128 Set r s2 = New ADODB. Recor dset
129 r s2. Open " SELECT i nt FFI D FROM f yp_t bl Fl oor Fl at WHERE chr Fl oor = ' " & cboFl oor . Text &
" ' AND chr Fl at = ' " & cboFl at . Text & " ' ; " , conn, adOpenSt at i c, adLockReadOnl y
130
131 dat Bi r t h = t xt Year . Text & " / " & t xt Mont h. Text & " / " & t xt Day. Text
132 st r HKI D = UCase( t xt HKI D1. Text ) & t xt HKI D2. Text & " ( " & t xt HKI D3. Text & " ) "
133
134 ' i nser t vi si t or r ecor d
92
135 conn. Execut e " I NSERT I NTO f yp_t bl HouseHol der VALUES ( ' ' , ' " & t xt Name. Text & " ' , ' "
& cboGender . Text & " ' , ' " & For mat ( dat Bi r t h, " YYYY- MM- DD" ) & " ' , ' " _
136 & st r HKI D & "' , ' " & For mat ( Now, " YYYY- MM- DD HH: MM: SS" ) & " ' , ' " & AESFi l ename
& " ' , ' " & r s1! i nt Bui l di ngI D & " ' , " & r s2! i nt FFI D & " ) ; " , , adExecut eNoRecor ds
137
138 r s1. Cl ose
139 Set r s1 = Not hi ng
140
141 r s2. Cl ose
142 Set r s2 = Not hi ng
143
144 MsgBox " Success t o save t he househol der i n dat abase" , vbI nf or mat i on, " Save New
Househol der "
145
146 ' r eset al l
147 AESFi l ename = " "
148 t xt Name. Text = " "
149 t xt Year . Text = " "
150 t xt Mont h. Text = " "
151 t xt Day. Text = " "
152 t xt HKI D1. Text = " "
153 t xt HKI D2. Text = " "
154 t xt HKI D3. Text = " "
155
156 cboGender . Text = cboGender . Li st ( 0)
157 cboBui l di ng. Text = cboBui l di ng. Li st ( 0)
158 cboFl oor . Text = cboFl oor . Li st ( 0)
159 cboFl at . Text = cboFl at . Li st ( 0)
160
161 Uni ni t i at eCam
162 cmdEnr ol l . Enabl ed = Fal se
163
164 End Sub

frmEdit.frm
It is a form of edit selected householder.
1 Opt i on Expl i ci t
2 Di mRemot ePat h As St r i ng
3 Di mComput er Name As St r i ng
4 Di mFol der Name As St r i ng
5 Di mAESFi l ename As St r i ng
6 Di mHHI D As I nt eger
7
8 Pr i vat e Sub cmdCl ose_Cl i ck( )
9 Unl oad Me
10 End Sub
11
12 Pr i vat e Sub cmdEnr ol l _Cl i ck( )
13 ' st ar t t he capt ur e t i mer
14 t mr St ar t Cap. I nt er val = 3000
15 t mr St ar t Cap. Enabl ed = Tr ue
16 End Sub
17
18 Pr i vat e Sub cmdSave_Cl i ck( )
19 Updat eHHol der
20 End Sub
21
22 Pr i vat e Sub cmdSt ar t Cam_Cl i ck( )
23 I ni t i at eCam
24 cmdEnr ol l . Enabl ed = Tr ue
25 End Sub
26
27 Pr i vat e Sub cmdSt opCam_Cl i ck( )
28 Uni ni t i at eCam
29 cmdEnr ol l . Enabl ed = Fal se
30 End Sub
31
32 Pr i vat e Sub For m_Load( )
33 Di mst r Bi r t h As St r i ng
34
35 Comput er Name = st r Ser ver I P ' set comput er name
36 Fol der Name = " user dat a\ househol der " ' set f ol der name ( opt i onal )

93
37 Remot ePat h =" \ \ " & Comput er Name & " \ " & Fol der Name & " \ " ' set t he r emot e pat h t o st or e
f i l e
38
39 ' f i nd t he househol der i d and put dat a i n t ext box and combobox
40 HHI D = Sel ect edHHI D
41 Di mr s As ADODB. Recor dset
42 Set r s = New ADODB. Recor dset
43 r s. Open "SELECT * FROM f yp_t bl HouseHol der h, f yp_t bl Fl oor Fl at f WHERE h. i nt Hol der I D
= " & HHI D & " AND f . i nt FFI D = h. i nt FFI D; " , conn, adOpenSt at i c, adLockReadOnl y
44
45 st r Bi r t h = For mat ( r s! dat Bi r t h, " yyyy- mm- dd" ) ' f or mat t he st r Bi r t h easy t o r ead
46 AESFi l ename = r s! chr User Dat a
47
48 t xt Name. Text = r s! chr Hol der Name
49 t xt Year . Text = Lef t ( st r Bi r t h, 4)
50 t xt Mont h. Text = Mi d( st r Bi r t h, 6, 2)
51 t xt Day. Text = Ri ght ( st r Bi r t h, 2)
52 t xt HKI D1. Text = Mi d( r s! chr HKI D, 1, 1)
53 t xt HKI D2. Text = Mi d( r s! chr HKI D, 2, 6)
54 t xt HKI D3. Text = Mi d( r s! chr HKI D, 9, 1)
55 I f ( r s! chr Gender = " M" ) Then
56 cboGender . Text = cboGender . Li st ( 0)
57 El seI f ( r s! chr Gender = " F" ) Then
58 cboGender . Text = cboGender . Li st ( 1)
59 End I f
60 cboBui l di ng. Text = cboBui l di ng. Li st ( Val ( r s! i nt Bui l di ngI D) - 1)
61 cboFl oor . Text = cboFl oor . Li st ( Val ( r s! chr Fl oor ) - 1)
62 cboFl at . Text = cboFl at . Li st ( Asc( r s! chr Fl at ) - 65)
63
64 ' di sabl e some t ext box t o pr event modi f y
65 t xt Name. Enabl ed = Fal se
66 t xt Year . Enabl ed = Fal se
67 t xt Mont h. Enabl ed = Fal se
68 t xt Day. Enabl ed = Fal se
69 t xt HKI D1. Enabl ed = Fal se
70 t xt HKI D2. Enabl ed = Fal se
71 t xt HKI D3. Enabl ed = Fal se
72 cboGender . Enabl ed = Fal se
73
74 ' set t he maxl engt h of al l t ext box
75 t xt Name. MaxLengt h = 255
76 t xt Year . MaxLengt h = 4
77 t xt Mont h. MaxLengt h = 2
78 t xt Day. MaxLengt h = 2
79 t xt HKI D1. MaxLengt h = 2
80 t xt HKI D2. MaxLengt h = 6
81 t xt HKI D3. MaxLengt h = 1
82
83 cmdEnr ol l . Enabl ed = Fal se
84 t mr St ar t Cap. Enabl ed = Fal se
85
86 pi cHol der I mage. Pi ct ur e =LoadPi ct ur e( Remot ePat h & r s! chr User Dat a & " . bmp" ) ' l oad t he
pr evi ous enr ol l ed pi c
87
88 ' MsgBox "Pl ease enr ol l t he f ace f i r st . " , vbI nf or mat i on, " Message"
89
90 End Sub
91
92 Pr i vat e Sub I ni t i at eCam( )
93 ' I ni t i at e t he webcam
94 Webcam. Set Si zeType 1
95 Webcam. Set EyeThr eshol d 180000
96 Webcam. Set Thr eshol d 80000
97 Webcam. I ni t Smar t Gat e
98 Webcam. Show
99 pi cHol der I mage. Vi si bl e = Fal se
100 pi cCamMask. Vi si bl e = Fal se
101 End Sub
102
103 Pr i vat e Sub Uni ni t i at eCam( )
104 ' Uni ni t i at e t he webcam
105 Webcam. Unshow
106 Webcam. Uni ni t Smar t Gat e
107 pi cCamMask. Vi si bl e = Tr ue
108 End Sub
109
94
110 Pr i vat e Sub For m_Unl oad( Cancel As I nt eger )
111 Uni ni t i at eCam
112 End Sub
113
114 Pr i vat e Sub GenName( )
115 Di mAESKey As CRi j ndael
116 Di mpl ai nText ( ) As Byt e
117 Di mencText ( ) As Byt e
118 Di mencPasswor d( ) As Byt e
119 Di ml Count As Long
120 Di ml Lengt h As Long
121
122 Set AESKey = New CRi j ndael ' set AESKey f r omcl ass modul es
123
124 pl ai nText = For mat ( Now, " yymmddhhmmss" )
125 encPasswor d = " " ' def aul t no passwor d
126
127 encText = AESKey. Encr ypt Dat a( pl ai nText , encPasswor d)
128 AESFi l ename = " "
129 For l Count = 0 To UBound( encText )
130 AESFi l ename = AESFi l ename & Ri ght ( " 0" & Hex( encText ( l Count ) ) , 2)
131 Next
132
133 End Sub
134
135 Pr i vat e Sub t mr St ar t Cap_Ti mer ( )
136 GenName ' gener at e t he f i l ename t o AES f or mat
137 I f ( Webcam. SaveToBmpI mageT( Remot ePat h & AESFi l ename & " . bmp" , 320, 240) ) Then ' save
bi t map f r omcamer a
138 Webcam. AppendDat a Remot ePat h & AESFi l ename & " . bmp" , Remot ePat h & AESFi l ename &
" . usr " ' save t he t empl at e f i l e f r ombi t map
139 MsgBox " Face Enr ol l ment Successf ul ! " , vbI nf or mat i on, " Face Enr ol l ment "
140 El se
141 MsgBox " Face Enr ol l ment Fai l ed! \ nPl ease t r y agai n! " , vbCr i t i cal , " Face Enr ol l ment "
142 End I f
143
144 ' st op t he t i mer af t er 3 seconds
145 I f t mr St ar t Cap. I nt er val = 3000 Then
146 t mr St ar t Cap. Enabl ed = Fal se
147 End I f
148 End Sub
149
150 Pr i vat e Sub Updat eHHol der ( )
151 Di mr s1 As ADODB. Recor dset
152 Di mr s2 As ADODB. Recor dset
153
154 Set r s1 = New ADODB. Recor dset
155 r s1. Open " SELECT i nt Bui l di ngI D FROM f yp_t bl Bui l di ng WHERE chr Bui l di ngName LI KE ' " &
cboBui l di ng. Text & " ' ; " , conn, adOpenSt at i c, adLockReadOnl y
156
157 Set r s2 = New ADODB. Recor dset
158 r s2. Open " SELECT i nt FFI D FROM f yp_t bl Fl oor Fl at WHERE chr Fl oor = ' " & cboFl oor . Text &
" ' AND chr Fl at = ' " & cboFl at . Text & " ' ; " , conn, adOpenSt at i c, adLockReadOnl y
159
160 conn. Execut e " UPDATE f yp_t bl HouseHol der SET dat RegDat e =' " & For mat ( Now, " YYYY- MM- DD" )
& " ' , i nt Bui l di ngI D = " & r s1! i nt Bui l di ngI D & _
161 " , i nt FFI D = " & r s2! i nt FFI D & " , chr User Dat a = ' " & AESFi l ename & " ' WHERE
i nt Hol der I D = " & HHI D & " ; "
162
163 r s1. Cl ose
164 Set r s1 = Not hi ng
165
166 r s2. Cl ose
167 Set r s2 = Not hi ng
168
169 MsgBox " Successf ul updat e househol der det ai l i n dat abase. " , vbI nf or mat i on, " Updat e
Househol der "
170
171 End Sub
172
173
174 Pr i vat e Sub AddHHol der ( )
175 Di mr s1 As ADODB. Recor dset
176 Di mr s2 As ADODB. Recor dset
177 Di mdat Bi r t h As Dat e
178 Di mst r HKI D As St r i ng
95
179
180 Set r s1 = New ADODB. Recor dset
181 r s1. Open " SELECT i nt Bui l di ngI D FROM f yp_t bl Bui l di ng WHERE chr Bui l di ngName LI KE ' " &
cboBui l di ng. Text & " ' ; " , conn, adOpenSt at i c, adLockReadOnl y
182
183 Set r s2 = New ADODB. Recor dset
184 r s2. Open " SELECT i nt FFI D FROM f yp_t bl Fl oor Fl at WHERE chr Fl oor = ' " & cboFl oor . Text &
" ' AND chr Fl at = ' " & cboFl at . Text & " ' ; " , conn, adOpenSt at i c, adLockReadOnl y
185
186 dat Bi r t h = t xt Year . Text & " / " & t xt Mont h. Text & " / " & t xt Day. Text
187 st r HKI D = UCase( t xt HKI D1. Text ) & t xt HKI D2. Text & " ( " & t xt HKI D3. Text & " ) "
188
189 ' i nser t vi si t or r ecor d
190 conn. Execut e " I NSERT I NTO f yp_t bl HouseHol der VALUES ( ' ' , ' " & t xt Name. Text & " ' , ' "
& cboGender . Text & " ' , ' " & For mat ( dat Bi r t h, " YYYY- MM- DD" ) & " ' , ' " _
191 & st r HKI D & "' , ' " & For mat ( Now, " YYYY- MM- DD HH: MM: SS" ) & " ' , ' " & AESFi l ename
& " ' , ' " & r s1! i nt Bui l di ngI D & " ' , " & r s2! i nt FFI D & " ) ; " , , adExecut eNoRecor ds
192
193 r s1. Cl ose
194 Set r s1 = Not hi ng
195
196 r s2. Cl ose
197 Set r s2 = Not hi ng
198
199 MsgBox " Success t o save t he househol der i n dat abase. " , vbI nf or mat i on, " Save New
Househol der "
200
201 ' r eset al l
202 AESFi l ename = " "
203 t xt Name. Text = " "
204 t xt Year . Text = " "
205 t xt Mont h. Text = " "
206 t xt Day. Text = " "
207 t xt HKI D1. Text = " "
208 t xt HKI D2. Text = " "
209 t xt HKI D3. Text = " "
210
211 cboGender . Text = cboGender . Li st ( 0)
212 cboBui l di ng. Text = cboBui l di ng. Li st ( 0)
213 cboFl oor . Text = cboFl oor . Li st ( 0)
214 cboFl at . Text = cboFl at . Li st ( 0)
215
216 Uni ni t i at eCam
217 cmdEnr ol l . Enabl ed = Fal se
218
219 End Sub

The programming codes of form in Building Security System
Select_Mode.frm
It is the mode selection form.
1 Pr i vat e Sub bt nCl ose_Cl i ck( )
2 End
3 End Sub
4
5 Pr i vat e Sub For m_Load( )
6 mode. Movi e = App. pat h & " \ i nt er f ace\ sel ect . swf "
7 mode. Pl ay
8
9 End Sub
10
11 Pr i vat e Sub mode_FSCommand( ByVal command As St r i ng, ByVal ar gs As St r i ng)
12 Sel ect Case command
13 Case "househol der "
14 H_Mode. Show
15 Case "vi si t or "
16 V_Mode. Show
17 End Sel ect
18 End Sub
96
H_Mode.frm
It is householder mode form.
1 Opt i on Expl i ci t
2 Di mRemot ePat h As St r i ng
3 Di mComput er Name As St r i ng
4 Di mFol der Name As St r i ng
5
6 Pr i vat e Sub For m_Load( )
7 Comput er Name = st r Ser ver I P ' set comput er name
8 Fol der Name = " user dat a\ househol der " ' set f ol der name ( opt i onal )
9 Remot ePat h =" \ \ " & Comput er Name & " \ " & Fol der Name & " \ " ' set t he r emot e pat h t o st or e
f i l e
10
11 ' set t he f i l ename of f l ash and pl ay
12 I nt er f ace. Movi e = App. pat h & " \ i nt er f ace\ househol der . swf "
13 I nt er f ace. Pl ay
14
15 Webcam. Vi si bl e = Fal se
16
17 End Sub
18
19 Pr i vat e Sub For m_Unl oad( Cancel As I nt eger )
20 ' Unshow and Uni ni t at e t he webcam
21 Uni ni t i at eCam
22 End Sub
23
24 Pr i vat e Sub St ar t Cam_Ti mer ( )
25 Webcam. Vi si bl e = Tr ue
26
27 ' st op t he t i mer af t er 2 seconds
28 I f St ar t Cam. I nt er val = 2000 Then
29 St ar t Cam. Enabl ed = Fal se
30
31 ' st ar t t he capt ur e t i mer
32 St ar t Cap. I nt er val = 3000
33 St ar t Cap. Enabl ed = Tr ue
34 End I f
35 End Sub
36
37 Pr i vat e Sub St ar t Cap_Ti mer ( )
38 Sear chUser
39
40 End Sub
41
42 Pr i vat e Sub I ni t i at eCam( )
43 ' I ni t i at e t he webcam
44 Webcam. Set Si zeType 1
45 Webcam. Set EyeThr eshol d 180000
46 Webcam. Set Thr eshol d 80000
47 Webcam. I ni t Smar t Gat e
48 Webcam. Show
49 Webcam. Vi si bl e = Tr ue
50
51 End Sub
52
53 Pr i vat e Sub Uni ni t i at eCam( )
54 ' Uni ni t i at e t he webcam
55 Webcam. Vi si bl e = Fal se
56 Webcam. Unshow
57 Webcam. Uni ni t Smar t Gat e
58 End Sub
59
60 Pr i vat e Sub Sear chUser ( )
61 Di mr s As ADODB. Recor dset
62 Di msuccess As Bool ean
63 Di maaa As St r i ng
64
65 success = Fal se
66
67 Set r s = New ADODB. Recor dset
68 r s. Open "SELECT i nt Hol der I D, chr Hol der Name, chr User Dat a FROM f yp_t bl HouseHol der ; " ,
conn, adOpenSt at i c, adLockReadOnl y
69
70 Do Unt i l r s. EOF Or success = Tr ue
97
71 I f Webcam. LoadUser Dat a( Remot ePat h & r s! chr User Dat a & " . usr " , 1) And Webcam. Ver i f y( )
Then
72 ' save l og of househol der i n t abl e " f yp_t bl Hol der Log"
73 conn. Execut e " I NSERT I NTO f yp_t bl Hol der Log VALUES ( ' ' , ' " & r s! i nt Hol der I D & " ' ,
' " & For mat ( Now, " YYYY- MM- DD HH: MM: SS" ) & " ' ) ; " , , adExecut eNoRecor ds
74
75 success = Tr ue
76
77 ' show successf ul message box
78 I nt er f ace. Set Var i abl e " VBCommand" , " i dent i f ySuccess"
79 I nt er f ace. Set Var i abl e " User name" , r s! chr Hol der Name
80
81 ' uni ni t i at e t he camwhen success
82 St ar t Cap. Enabl ed = Fal se
83 Uni ni t i at eCam
84 El se
85 r s. MoveNext
86 End I f
87 Loop
88
89 ' show f ai l ed message box when cannot ver i f y
90 I f ( success = Fal se) Then
91
92 I nt er f ace. Set Var i abl e " VBCommand" , " i dent i f yFai l ed"
93
94 ' st ar t t he capt ur e t i mer
95 St ar t Cap. I nt er val = 3000
96 St ar t Cap. Enabl ed = Tr ue
97 End I f
98
99 r s. Cl ose
100 Set r s = Not hi ng
101
102 End Sub
103
104 Pr i vat e Sub I nt er f ace_FSCommand( ByVal command As St r i ng, ByVal ar gs As St r i ng)
105 Sel ect Case command
106 Case "openCam"
107 I ni t i at eCam
108 ' st ar t t he capt ur e t i mer
109 St ar t Cap. I nt er val = 3000
110 St ar t Cap. Enabl ed = Tr ue
111 Case "cl oseCam"
112 Uni ni t i at eCam
113 Case "unl oad"
114 Unl oadFor m. I nt er val = 1000
115 Unl oadFor m. Enabl ed = Tr ue
116 End Sel ect
117 End Sub
118
119 Pr i vat e Sub Unl oadFor m_Ti mer ( )
120 I nt er f ace. St op
121 Unl oad Me
122 End Sub

V_Mode.frm
It is visitor mode form.
1 Opt i on Expl i ci t
2 Di mAESFi l ename As St r i ng
3 Di mFaceName As St r i ng
4 Di mFi nger Name As St r i ng
5 Di mRemot ePat h As St r i ng
6 Di mComput er Name As St r i ng
7 Di mFol der Name As St r i ng
8 Di mst r Fl oor As St r i ng
9 Di mst r Fl at As St r i ng
10
11 Pr i vat e Sub Enr ol l _Cl i ck( )
12 GenName ' gener at e t he f i l ename t o AES f or mat
13 Webcam. SaveToBmpI mageT Remot ePat h & AESFi l ename & " . bmp" , 320, 240 ' save bi t map f r om
camer a
14 Webcam. AppendDat a Remot ePat h & AESFi l ename & " . bmp" , Remot ePat h & AESFi l ename & " . usr "
' save t he t empl at e f i l e f r ombi t map
98
15
16 ' I nser t vi si t or r ecor d i n dat abase
17 AddVi si t or
18
19 End Sub
20
21 Pr i vat e Sub For m_Load( )
22 Comput er Name = st r Ser ver I P ' set comput er name
23 Fol der Name = " user dat a\ vi si t or " ' set f ol der name ( opt i onal )
24 Remot ePat h =" \ \ " & Comput er Name & " \ " & Fol der Name & " \ " ' set t he r emot e pat h t o st or e
f i l e
25
26 ' set t he f i l ename of f l ash and pl ay
27 I nt er f ace. Movi e = App. pat h & " \ i nt er f ace\ vi si t or . swf "
28 I nt er f ace. Pl ay
29
30 Webcam. Vi si bl e = Fal se
31
32 Fi nger I mage. Vi si bl e = Fal se
33 End Sub
34
35 Pr i vat e Sub For m_Unl oad( Cancel As I nt eger )
36 ' Unshow and Uni ni t at e t he webcam
37 Uni ni t i at eCam
38 ' uni ni t i at e t he f i nger pr i nt devi ce
39 Uni ni t Fi nger
40 End Sub
41
42 Pr i vat e Sub St ar t Face_Ti mer ( )
43 GenName ' gener at e t he f i l ename t o AES f or mat
44 FaceName = AESFi l ename ' put t he gener at ed f i l ename i n FaceName
45
46 I f ( Webcam. SaveToBmpI mageT( Remot ePat h & FaceName & " . bmp" , 320, 240) = Tr ue) Then
' save bi t map f r omcamer a
47 Webcam. AppendDat a Remot ePat h & FaceName & " . bmp" , Remot ePat h & FaceName & " . usr "
' save t he t empl at e f i l e f r ombi t map
48 Uni ni t i at eCam ' cl ose t he cam
49 I nt er f ace. Set Var i abl e " VBCommand" , " got oFi nger " ' pass t he val ue t o f l ash and r un
t he f unct i on
50 End I f
51 ' st op t he t i mer af t er 3 seconds
52 I f St ar t Face. I nt er val = 3000 Then
53 St ar t Face. Enabl ed = Fal se
54 End I f
55 End Sub
56
57 Pr i vat e Sub GenName( )
58 Di mAESKey As CRi j ndael
59 Di mpl ai nText ( ) As Byt e
60 Di mencText ( ) As Byt e
61 Di mencPasswor d( ) As Byt e
62 Di ml Count As Long
63 Di ml Lengt h As Long
64
65 Set AESKey = New CRi j ndael ' set AESKey f r omcl ass modul es
66
67 pl ai nText = For mat ( Now, " yymmddhhmmss" )
68 encPasswor d = " " ' def aul t no passwor d
69
70 encText = AESKey. Encr ypt Dat a( pl ai nText , encPasswor d)
71 AESFi l ename = " "
72 For l Count = 0 To UBound( encText )
73 AESFi l ename = AESFi l ename & Ri ght ( " 0" & Hex( encText ( l Count ) ) , 2)
74 Next
75
76 End Sub
77
78 Pr i vat e Sub AddVi si t or ( )
79 Di mr s As ADODB. Recor dset
80
81 conn. Cur sor Locat i on = adUseCl i ent
82
83 Set r s = New ADODB. Recor dset
84 r s. Open "SELECT i nt FFI D FROMf yp_t bl Fl oor Fl at WHERE chr Fl oor = ' " & st r Fl oor & " ' AND
chr Fl at = ' " & st r Fl at & " ' ; " , conn, adOpenSt at i c, adLockReadOnl y
85
99
86 ' i nser t vi si t or r ecor d
87 conn. Execut e " I NSERT I NTO f yp_t bl Vi si t or VALUES ( ' ' , ' " & FaceName & " ' , ' " & Fi nger Name
& " ' , ' " & For mat ( Now, " YYYY- MM- DD HH: MM: SS" ) & " ' , 1, " & r s! i nt FFI D & " ) ; " , ,
adExecut eNoRecor ds
88
89 r s. Cl ose
90 Set r s = Not hi ng
91
92 End Sub
93
94 Pr i vat e Sub I ni t i at eCam( )
95 ' I ni t i at e t he webcam
96 Webcam. Set Si zeType 1
97 Webcam. Set EyeThr eshol d 180000
98 Webcam. Set Thr eshol d 80000
99 Webcam. I ni t Smar t Gat e
100 Webcam. Show
101 Webcam. Vi si bl e = Tr ue
102 End Sub
103
104 Pr i vat e Sub Uni ni t i at eCam( )
105 ' Uni ni t i at e t he webcam
106 Webcam. Vi si bl e = Fal se
107 Webcam. Unshow
108 Webcam. Uni ni t Smar t Gat e
109 End Sub
110
111 Pr i vat e Sub I nt er f ace_FSCommand( ByVal command As St r i ng, ByVal ar gs As St r i ng)
112 Sel ect Case command
113 Case "f l oor f l at "
114 st r Fl oor = Lef t $( ar gs, Len( ar gs) - 1)
115 st r Fl at = Ri ght $( ar gs, 1)
116 Case "openCam"
117 I ni t i at eCam
118 Case "st ar t Face"
119 St ar t Face. I nt er val = 3000
120 St ar t Face. Enabl ed = Tr ue
121 Case "st ar t Fi nger "
122 I ni t Fi nger
123 Case "endFi nger "
124 Fi nger I mage. Vi si bl e = Fal se
125 Case "unl oad"
126 Unl oadFor m. I nt er val = 1000
127 Unl oadFor m. Enabl ed = Tr ue
128 End Sel ect
129 End Sub
130
131 Pr i vat e Sub I ni t Fi nger ( )
132 Di mTempl at eSi ze As Long
133 Di ml pTempl at eByt es( ) As Byt e
134 Di mt empl at e As FTR_DATA
135
136 Fi nger I mage. Vi si bl e = Tr ue
137
138 ' i ni t i al i ze Fut r oni c f i nger pr i nt SDK
139 FTRI ni t i al i ze
140
141 ' set dSDK set t i ngs:
142 ' f r ame sour ce
143 Di mval ue As Long
144 val ue = FSD_FUTRONI C_USB
145 FTRSet Par amFTR_PARAM_CB_FRAME_SOURCE, val ue
146
147 ' user ' s cal backs
148 FTRSet Par amFTR_PARAM_CB_CONTROL, Addr essOf cbCont r ol
149
150 ' FAR set t i ng
151 val ue = 110000 ' def aul t t hr eshol d set t i ng
152 FTRSet Par amFTR_PARAM_MAX_FAR_REQUESTED, val ue
153
154 ' Max Model s
155 val ue = 3 ' set t he number of t i mes t o scan
156 FTRSet Par amFTR_PARAM_MAX_MODELS, val ue
157
158 ' cr eat e t he i mage ar ea f or f i nger pr i nt bi t map
159 Di mhSWnd As Long
100
160 hSWnd = Cr eat eShowWnd( V_Mode. hwnd, 460, 100, 320, 400)
161
162 ' pr epar e memor y f or t empl at e st or e
163 FTRGet Par amFTR_PARAM_MAX_TEMPLATE_SI ZE, Templ at eSi ze
164
165 ReDi ml pTempl at eByt es( 0 To Templ at eSi ze - 1)
166
167 ' pr epar e ar gument s
168 t empl at e. pDat a = Var Pt r ( l pTempl at eByt es( 0) )
169
170 ' enr ol l oper at i on
171 FTREnr ol l 0&, FTR_PURPOSE_ENROLL, t empl at e
172
173 ' gener at e t he f i l ename
174 GenName
175 Fi nger Name = AESFi l ename
176
177 ' wr i t e t empl at e t o f i l e
178 I f ( AddFi nger ( t empl at e. pDat a, t empl at e. dwSi ze, Remot ePat h, Fi nger Name) ) Then
179 Uni ni t Fi nger ' uni ni t i at e t he f i nger pr i nt devi ce
180 End I f
181
182 ' f i nal l y, i nser t vi si t or r ecor d i n dat abase
183 AddVi si t or
184
185 ' cal l f l ash pl ay movi e when t he f i nger success.
186 I nt er f ace. Set Var i abl e " VBCommand" , " succFi nger "
187 End Sub
188
189 Pr i vat e Sub Uni ni t Fi nger ( )
190 ' uni ni t i al i ze Fut r oni c f i nger pr i nt SDK
191 FTRTer mi nat e
192 End Sub
193
194 Pr i vat e Sub Unl oadFor m_Ti mer ( )
195 I nt er f ace. St op
196 Unl oad Me
197 End Sub

Programming code of Clubhouse system
Clubhouse login system: Project1, Form2
1 Pr i vat e Sub Sear chUser ( )
2 Di mconn As ADODB. Connect i on
3 Di msuccess As Bool ean
4 Di mt mp As I nt eger
5 Di mbbq1 As ADODB. Recor dset
6 Di mbbq2 As ADODB. Recor dset
7
8 success = Fal se
9
10 Set conn = New ADODB. Connect i on
11 conn. Cur sor Locat i on = adUseCl i ent
12
13 ' connect MySQL dat abase ser ver
14
15 conn. Connect i onSt r i ng = " DRI VER={MySQL ODBC 3. 51 Dr i ver }; " _
16 & " SERVER=127. 0. 0. 1; " _
17 & " DATABASE=i ve_f yp; " _
18 & " UI D=i ve; " _
19 & " PWD=i ve; " _
20 & " OPTI ON=" & 1 + 2 + 8 + 32 + 2048 + 163841
21 conn. Open
22
23 Set bbq1 = New ADODB. Recor dset
24 bbq1. Open " SELECT i nt Hol der I D, chr Hol der Name, chr User Dat a FROMf yp_t bl HouseHol der ; " ,
conn
25 Set bbq2 = New ADODB. Recor dset
26 bbq2. Open " SELECT i nt Hol der I D, dat I nTi me FROM f yp_t bl cl ub wher e
f yp_t bl cl ub. i nt Hol der I D = ' " & bbq1! i nt Hol der I D & " ' ; " , conn
27
28 Do Unt i l bbq1. EOF Or success = Tr ue
29 I f Webcam. LoadUser Dat a( Remot ePat h & bbq1! chr User Dat a & " . usr " , 1) And
Webcam. Ver i f y( ) Then
101
30 success = Tr ue
31
32 Text 1. Text = bbq2! dat I nTi me
33
34 Ti met ake. Vi si bl e = Tr ue
35 Ti met ake. Text = " Your Logout t i me i s"
36
37 Text 2. Text = Ti me
38
39 Text 3. Text = " See you! " + bbq1! chr Hol der Name + " ! Logout successf ul ! "
40
41 conn. Execut e " UPDATE f yp_t bl cl ub SET dat Out Ti me =' " & For mat ( Now, " HH: MM: SS" ) & " ' WHERE
f yp_t bl cl ub. i nt Hol der I D = ' " & bbq1! i nt Hol der I D & " ' ; "
42
43 Command1. Enabl ed = Tr ue
44 El se
45 bbq1. MoveNext
46 End I f
47 Loop
48
49 I f ( success = Fal se) Then
50 Text 3. Text = " Sor r y, Logout Fai l ed! Pl ease t r y agai n! "
51 End I f
52 bbq1. Cl ose
53 Set bbq1 = Not hi ng
54 End Sub

You might also like