Online Voting with Visual Cryptography
Online Voting with Visual Cryptography
ABSTRACT
Trustworthy election is an efficient mechanism to democracy. It is a process in which
people choose their representative to form a government. The key requirement for
effective election process are correctness, robustness, and security. There are variety of
voting schemes which are based on the traditional method.
But because of the inconvenient traditional voting system there is tremendous decrease
in number of voters. Hence online voting system is introduced to overcome the
drawback of traditional voting system.
The online voting system where a person can cast his vote from anywhere in the world
by logging onto a website is being adopted by an increasing number of governments
and companies.
Online voting system has the facility to complete voting process faster than the paper
ballot voting procedure. This system itself should be intelligent to earn the trust and
confidence of the user by providing enhanced security and reliability. The security is
an important factor in any voting system.
However, the problem with this is that any user can log in to the website and cast votes
multiple times using various identities which leads to unfair election result.
This is a frequently encountered issue with the online voting system which is
deteriorating the authenticity of the decisions taken via the online mode.
So security is provided through the authentication. Authentication is a secured way to
check the voter’s identity. The principal objective of authentication is to prevent any
adversary from copying other user. Secret sharing schemes are the powerful mechanism
used for the authentication.
Secret sharing schemes are ideal for storing information that is highly sensitive and
highly important. Secret sharing is also termed as secret splitting. Secret sharing is a
method for allocating a secret among a group of participants. Each of whom is allocated
a share of the secret.
In this paper I have implemented a two factor authentication system through which a
voter can vote by passing through biometrics and VC share mechanism which facilitates
authentication as well identification of a genuine voter.
1
CHAPTER-1
INTRODUCTION
1.1 Introduction to Online Voting system
The Online Voting system is designed to count the number of votes and thereby
calculate the percentage of votes. Also the number of vote a candidate obtains is also
obtained. Along with the number the percentage of votes for each candidate is
calculated. The system is so designed that it can also check for duplication. It then
decides the winner in every section. The project is designed with a modular approach
and the number of modules is decided as per the requirements of the organization. The
three modules are administrator module, the user module and Database. The
administrator has total authority of the organization and maintains all the aspects. The
user has the provision to view the list of all candidates and results as well as vote for
the desired candidates.
One of the best-known techniques has been credited to Moni Naor and Adi Shamir,
who developed it in [Link] demonstrated a visual secret sharing scheme, where an
image was broken up into n shares so that only someone with all n shares could decrypt
the image, while any n − 1 shares revealed no information about the original image.
Each share was printed on a separate transparency, and decryption was performed by
overlaying the shares. When all n shares were overlaid, the original image would
appear. There are several generalizations of the basic scheme including k-out-of-n
visual cryptography.
2
Some antecedents of visual cryptography are in patents from the [Link]
antecedents are in the work on perception and secure communication.
3
1.5 Drawbacks of Existing System
Voter’s identity is not validated in existing system efficiently.
Impossible to identify whether a voter is authentic or not
The Existing system is vulnerable to SYBIL attack.
Verification of votes can’t be done in case of any security breach.
Anonymity of voter is not available.
4
CHAPTER 2
LITERATURE SURVEY
2.1 Cryptography
The Internet is the fastest growing communication medium and essential part of the
infrastructure, nowadays. To cope with the growth of internet it has become a
constant struggle to keep the secrecy of information and when profits are involved,
protect the copyright of data. To provide secrecy and copyright of data, many of the
steganographic techniques have been developed. But each of the technique has their
respective pros and cons. Where one technique lacks in payload capacity, the other
lacks in robustness. So, the main emphasis of cryptography is to overcome these
shortcomings.
In Cryptography the techniques which are used to protect information are obtained
from mathematical concepts and a set of rule based calculations known as algorithms
to convert messages in ways that make it hard to decode it. These algorithms are used
for cryptographic key generation, digital signing, verification to protect data privacy,
web browsing on internet and to protect confidential transactions such as credit card
and debit card transactions.
5
Features of Cryptography are as follows:
1. Confidentiality:
Information can only be accessed by the person for whom it is intended and no
other person except him can access it.
2. Integrity:
Information cannot be modified in storage or transition between sender and
intended receiver without any addition to information being detected.
3. Non-repudiation:
The creator/sender of information cannot deny his or her intention to send
information at later stage.
4. Authentication:
The identities of sender and receiver are confirmed. As well as
destination/origin of information is confirmed.
6
2.3 Visual Cryptography
Visual cryptography is a cryptographic technique which allows visual information
(pictures, text, etc.) to be encrypted in such a way that decryption can be done just by
sight reading. Visual cryptography, degree associated rising cryptography technology,
uses the characteristics of human vision to rewrite encrypted photos. Visual
cryptography provides secured digital transmission that is used just for merely the
once.
Numerous guidance like military maps and business identifications are transmitted
over the internet. Whereas pattern secret photos, security problems ought to be
compelled to be taken into thought as a result of hackers may utilize weak link over
the communication network to steal info that they need. To touch upon the protection
problems with secret photos, varied image secret sharing schemes are developed.
Anyone will use it for coding with none science information and any computations.
2.3.1 Visual Cryptography Process
The basis of the technique is the superposition (overlaying) of two semi-transparent
layers. Imagine two sheets of transparency covered with a seemingly random
collection of black pixels.
7
Mysteriously, however, if the two grids are overlaid correctly, at just the right
position, a message magically appears! The patterns are designed to reveal a message.
2.3.2 Authentication
Authentication is a secured way to check the voter’s identity. The principal objective
of authentication is to prevent any adversary from copying other user. Secret sharing
schemes are the powerful mechanism used for the authentication. Secret sharing
schemes are ideal for storing information that is highly sensitive and highly important.
Secret sharing is also termed as secret splitting. Secret sharing is a method for allocating
a secret among a group of participants. Each of whom is allocated a share of the secret.
For reconstruction it uses t shares out of n no of shares. The system uses the idea to fit
a unique polynomial of degree (t-1) to any set of t points that lie on the polynomial. For
straight line it takes two points, three points to define a quadratic, and to define cubic
curve it takes four points, and so on. It means to form the polynomial of degree t-1 it
takes t points. The method is to generate a polynomial of degree t-1 with the secret as
the first coefficient and the remaining coefficients picked at random. It finds n points
on the curve and give one to each of the participants. When at least t out of the n
participants expose their points, there is sufficient information to fit a (t-1)th degree
polynomial to them, and the first coefficient being the secret.
2.4 Steganography
Steganography is the practice of concealing a file, message, image, or video within
another file, message, image, or video. The word steganography combines
the Greek words steganos , meaning "covered or concealed", and graphe (γραφή)
meaning "writing".
The advantage of steganography over cryptography alone is that the intended secret
message does not attract attention to itself as an object of scrutiny. Plainly visible
encrypted messages, no matter how unbreakable they are, arouse interest and may in
themselves be incriminating in countries in which encryption is illegal.
8
Whereas cryptography is the practice of protecting the contents of a message alone,
steganography is concerned both with concealing the fact that a secret message is being
sent and its contents.
9
CHAPTER 3
ALGORITHM DESCRIPTION
3.1 Two out of Two VC Share Algorithm
2 out‐of 2 visual cryptography scheme a normal scheme of (2,2) VCS generate 2 shares
picture on the basis of an original image from share’s at user ‘s end must superimpose
both shares to generate original image. To secure the ratio of obtained secrete image
form shares in (2, 2) scheme every pixel in secrete image (original image) can be
replaced in share image by a 2 x 2block of sub pixels. According to table 1, for white
original pixel one of six combinations is created. Same process is applicable for black
pixel. After superimposing the shares the original image will be obtained.
Authentication Phase
Authentication is an important mechanism to provide security to the system. Secret
sharing is an efficient technique used for secured authentication. For authentication it
requires both the shares. At the time of authentication voter will produce his share and
authority will produce his share both the shares are necessary to reconstruct the original
secret. Using authentication only valid voters will be capable to cast the vote.
10
• The decoded image is identified, although some contrast loss is observed.
• Due to pixel expansion the width of the decoded image is twice as that of the
original image.
3.1.2 Advantages
• Simple to implement
• Decryption algorithm not required (Use a human Visual System). So a person
unknown to cryptography can decrypt the message.
• We can send cipher text through FAX or E-MAIL.
• Lower computational cost since the secret message is recognized only by human
eyes and not cryptographically computed.
3.1.2 Disadvantages
• The contrast of the reconstructed image is not maintained.
• Perfect alignment of the transparencies is troublesome.
• Due to pixel expansion the width of the decoded image is twice as that of
the original image. Leads to loss of information due to change in aspect
ratio.
• Additional processing is required for colored images.
11
CHAPTER 4
SYSTEM ANALYSIS
4.1 System Requirements
4.1.1 Software Requirements
a) JS (Front End)
JavaScript often abbreviated as JS, is a high-level, interpreted scripting language that
conforms to the ECMAScript specification. JavaScript has curly-bracket
syntax, dynamic typing, prototype-based object-orientation, and first-class functions.
Alongside HTML and CSS, JavaScript is one of the core technologies of the World
Wide Web. JavaScript enables interactive web pages and is an essential part of web
applications. The vast majority of websites use it, and major web browsers have a
dedicated JavaScript engine to execute it.
12
create plug-ins on top of the JavaScript library. This enables developers to
create abstractions for low-level interaction and animation, advanced effects and high-
level, themeable widgets. The modular approach to the jQuery library allows the
creation of powerful dynamic web pages and Web applications.
e) PhpMyAdmin
phpMyAdmin is a free software tool written in PHP, intended to handle the
administration of MySQL over the Web. phpMyAdmin supports a wide range of
operations on MySQL and MariaDB. Frequently used operations (managing databases,
tables, columns, relations, indexes, users, permissions, etc) can be performed via the
user interface, while you still have the ability to directly execute any SQL statement.
phpMyAdmin comes with a wide range of documentation and users are welcome to
update our wiki pages to share ideas and howtos for various operations. The
phpMyAdmin team will try to help you if you face any problem; you can use a variety
13
of support channels to get help. phpMyAdmin is also very deeply documented in a book
written by one of the developers – Mastering phpMyAdmin for Effective MySQL
Management, which is available in English and Spanish. To ease usage to a wide range
of people, phpMyAdmin is being translated into 72 languages and supports both LTR
and RTL languages. phpMyAdmin is a mature project with a stable and flexible code
base; you can find out more about the project and its history and the awards it earned.
When the project turned 15, we published a celebration page.
14
CHAPTER 5
SYSTEM DESIGN
5.1 UML Diagrams
Unified Modelling Language is a tool that helps a designer to present his ideas
about the project to his client and his developer. Modelling plays a crucial role in
designing a software. A poorly designed model can lead to a poorly developed software.
A UML system has using five different views that help in describing systems from
different perspectives. Each view has a set of diagrams that and components that
represent the real time objects.
15
5.1.1 Use Case Diagram
The basic representation for the interaction of the user with the system is
represented using the use case diagram. It involves the relationship between the user
and various use cases with the actors being involved. There are different kinds of
relationships that are involved between the use cases and the actors. They include:
a. Association relationship
b. Generalization
c. Dependency
d. Realizations
e. Transitions
The following represents the use case diagram of the proposed system:
16
5.1.2 Class Diagram
They are static representation of an application. Only the class diagrams have the
capability to be directly mapped with the OOP Languages because in OOPs everything
is model in the form of classes and objects. Because of this reason these diagrams are
used widely at the time of construction. This is one of the most popularly used UML
diagram in the designer community. A class diagram plays an essential role in forward
and reverse engineering.
a. It acts as a base for the component and deployment diagrams.
b. It mainly describes and defines the basic responsibilities of a system’s application.
c. It implements the analysis and design view for a static application.
In a class diagram, each object is modelled as a class. Each class consists of section or
compartments.
1. Class name
2. Attributes of a class or operations
3. Methods or functions
4. Documentation (optional section)
17
2. Classifier members are “static” members of a class in many programming
languages. The scope is the class itself.
i. Static attributes are common to all other objects that invoke the class.
ii. Static methods are not instantiated.
3. Instance members are nothing but the members that are local to an object.
i. The main purpose of instance members is to allow the objects to store
their states.
ii. Declarations outside the methods are usually known as instance members.
18
5.1.3 Sequence Diagram
The Sequence Diagram depicts the time sequence among various objects in an
application. It depicts the sequence of messages with which objects communicate with
each other so that they carry out the required functionality.
It consists of the lifelines which are usually parallel vertical lines. It consists of
horizontal arrows which indicates the direction of the messages that are exchanged in a
proper order which makes the user easy to understand.
The lifeline for a given object represents a role. The synchronous calls are
represented with the help of a solid arrow head whereas the asynchronous messages are
represented with the help of open arrow heads.
All objects are represented according to their time ordering. Timing of messages
plays a major role in sequence diagrams. An object is killed immediately after its use
in sequence diagrams.
II). Contents
Objects are normally named or unknown instances of class, however may likewise
speak to occurrences of different things, for example components, collaboration and
nodes. Graphically, object is represented as a rectangle by underlying its name.
III). Links
A link is a semantic association among objects i.e., an object of an affiliation is
called as a connection. It is represented as a line.
IV). Messages
A message is a determination of a correspondence between objects that passes on
the data with the desire that the action will follow.
19
Fig 5.3: Voter’s Sequence Diagram
A small filled circle followed by an arrow represents the initial action state or the start
point for any activity diagram. For activity diagram using swimlanes, make sure the
start point is placed in the top left corner of the first column.
An action state represents the non-interruptible action of objects. You can draw an
action state in SmartDraw using a rectangle with rounded corners.
Action Flow
Action flows, also called edges and paths, illustrate the transitions from one action state
to another. They are usually drawn with an arrowed line.
Object Flow
Object flow refers to the creation and modification of objects by activities. An object
flow arrow from an action to an object means that the action creates or influences the
object. An object flow arrow from an object to an action indicates that the action state
uses the object.
21
Decisions and Branching
Guards
In UML, guards are a statement written next to a decision diamond that must be true
before moving next to the next activity. These are not essential, but are useful when a
specific answer, such as "Yes, three labels are printed," is needed before moving
forward.
An arrow pointing to a filled circle nested inside another circle represents the final
action state.
22
The basic purpose of an activity diagram is same as that of other UML diagrams.
The dynamic behaviour of the system is viewed by the activity diagram. They are used
to construct a system using the backward and forward engineering mechanisms.
The purpose of an activity diagram is as follows:
1) For drawing the flow (i.e. activity) in a system.
2) For showing the flow of sequence from one activity to another activity.
1) For showing the concurrent and parallel flow of actions in the system. The elements
which are used in an activity diagram are as follows:
i) Association relationship
ii) Activities
iii) Conditions and Constraints.
23
Fig 5.6: Admin’s Activity Diagram
24
CHAPTER 6
IMPLEMENTATION
25
6.1.3 Creating the Election title to undergo election process
6.1.6 Adding Required Candidates for election by adding their details as well as
position of the candidate and description about their candidature
Note: Candidates information is disclosed to admin itself
26
6.1.7 List of all the candidates
27
6.1.9 List of all the Eligible Voters
28
6.1.11 List of all the voters who have voted in the Election
6.2.1 Login
29
6.2.2 Fingerprint Verification for Voting (First Step Authentication)
6.2.4 Voter allowed to cast and submit vote after successful verification
30
6.2.5 Saved Ballot after voting the candidate the voter elected
package [Link]
/**
* @author ${[Link]}
*/
object FingerPrintMain extends App {
while([Link]())
{
31
val (i1 ,i2 , i3 ) = [Link](user)
println( "Check Fingerprint : " + new
FingerPrintMatch(90).matchFingerPrintFromDatabase(user , fingerprint)(conn))
println( "CHeck Shares : "+[Link]( i1 , i2)( i3))
package [Link]
class EmailForAuthShare {
// Send message
[Link](message)
[Link]("message sent successfully....")
package [Link]
import [Link]
32
class FingerPrintMatch( threshold : Double ) {
while([Link]())
{
}
}
package [Link]
import [Link]
import [Link].{ByteArrayInputStream, ByteArrayOutputStream, File}
import [Link].{Files, Paths}
import [Link]
import [Link]
import [Link]
import [Link]._
33
println(s"load $fileName")
if(fileName == "readme")
println(s"ignored")
else{
})
} match {
case Success(_) => println(s"Success")
case Failure(e) => println(s"Failed : "+ [Link])
}
[Link](1, [Link])
[Link](2, [Link])
[Link](3 , userDetails.finger_id)
[Link](4 , userDetails.scan_id)
[Link](5 , [Link])
[Link](6 , [Link])
[Link]
} match {
case Success(_) => println("Update Success")
case Failure(e) => {
println("Update Failed "+ [Link])
throw e
}
}
34
{
val sql = s"SELECT id, email , finger_id , scan_id , fingerprint , image
FROM users where id = '$user' "
var count = 0
var img : BufferedImage = null
var imgKey : BufferedImage = null
var imgEnc : BufferedImage = null
while([Link]() && count == 0)
{
count = count + 1
}
35
x += 1; x - 1
}
}
{
y += 1; y - 1
}
}
// Total number of red pixels = width * height
// Total number of blue pixels = width * height
// Total number of green pixels = width * height
// So total number of pixels = width * height * 3
val total_pixels = width1 * height1 * 3
// Normalizing the value of different pixels
// for accuracy(average pixels per color
// component)
val avg_different_pixels = difference / total_pixels
// There are 255 values of pixels in total
val percentage: Int = (avg_different_pixels / 255) * 100
percentage == 0
}
} }
6.3.5 Java jar file for encryption of voter image and generation of key
36
6.3.6 Decryption of image by overlapping the shares
6.4.1 [Link]:
37
<button type='button' class='close' data-dismiss='alert' aria-
hidden='true'>×</button>
<h4><i class='icon fa fa-warning'></i> Error!</h4>
".$_SESSION['error']."
</div>
";
unset($_SESSION['error']);
}
if(isset($_SESSION['success'])){
echo "
<div class='alert alert-success alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-
hidden='true'>×</button>
<h4><i class='icon fa fa-check'></i> Success!</h4>
".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>
<div class="row">
<div class="col-xs-10 col-xs-offset-1" id="content">
</div>
</div>
</section>
</div>
38
$.ajax({
type: 'POST',
url: 'ballot_up.php',
data:{id:id},
dataType: 'json',
success: function(response){
if(![Link]){
fetch();
}
}
});
});
});
function fetch(){
$.ajax({
type: 'POST',
url: 'ballot_fetch.php',
dataType: 'json',
success: function(response){
$('#content').html(response).iCheck({checkboxClass:'icheckbox_flat-
green',radioClass: 'iradio_flat-green'});
}
});
}
</script>
</body>
</html>
39
6.4.2 [Link]:
40
<div class="box">
<div class="box-header with-border">
<a href="#addnew" data-toggle="modal" class="btn btn-primary btn-sm btn-
flat"><i class="fa fa-plus"></i> New</a>
</div>
<div class="box-body">
<table id="example1" class="table table-bordered">
<thead>
<th class="hidden"></th>
<th>Position</th>
<th>Photo</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Platform</th>
<th>Tools</th>
</thead>
<tbody>
<?php
$sql = "SELECT *, [Link] AS canid FROM candidates LEFT JOIN
positions ON [Link]=candidates.position_id ORDER BY [Link]
ASC";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
$image = (!empty($row['photo'])) ? '../images/'.$row['photo'] :
'../images/[Link]';
echo "
<tr>
<td class='hidden'></td>
<td>".$row['description']."</td>
<td>
<img src='".$image."' width='30px' height='30px'>
<a href='#edit_photo' data-toggle='modal' class='pull-right photo'
data-id='".$row['canid']."'><span class='fa fa-edit'></span></a>
</td>
<td>".$row['firstname']."</td>
<td>".$row['lastname']."</td>
<td><a href='#platform' data-toggle='modal' class='btn btn-info btn-
sm btn-flat platform' data-id='".$row['canid']."'><i class='fa fa-search'></i>
View</a></td>
<td>
<button class='btn btn-success btn-sm edit btn-flat' data-
id='".$row['canid']."'><i class='fa fa-edit'></i> Edit</button>
<button class='btn btn-danger btn-sm delete btn-flat' data-
id='".$row['canid']."'><i class='fa fa-trash'></i> Delete</button>
</td>
</tr>
";
}
?>
</tbody>
41
</table>
</div>
</div>
</div>
</div>
</section>
</div>
});
function getRow(id){
$.ajax({
type: 'POST',
url: 'candidates_row.php',
data: {id:id},
dataType: 'json',
success: function(response){
$('.id').val([Link]);
42
$('#edit_firstname').val([Link]);
$('#edit_lastname').val([Link]);
$('#posselect').val(response.position_id).html([Link]);
$('#edit_platform').val([Link]);
$('.fullname').html([Link]+' '+[Link]);
$('#desc').html([Link]);
}
});
}
</script>
</body>
</html>
6.4.3 [Link]
43
}
if(isset($_SESSION['success'])){
echo "
<div class='alert alert-success alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-
hidden='true'>×</button>
<h4><i class='icon fa fa-check'></i> Success!</h4>
".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-aqua">
<div class="inner">
<?php
$sql = "SELECT * FROM positions";
$query = $conn->query($sql);
echo "<h3>".$query->num_rows."</h3>";
?>
<p>No. of Positions</p>
</div>
<div class="icon">
<i class="fa fa-tasks"></i>
</div>
<a href="[Link]" class="small-box-footer">More info <i class="fa fa-
arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-green">
<div class="inner">
<?php
$sql = "SELECT * FROM candidates";
$query = $conn->query($sql);
echo "<h3>".$query->num_rows."</h3>";
?>
<p>No. of Candidates</p>
</div>
<div class="icon">
44
<i class="fa fa-black-tie"></i>
</div>
<a href="[Link]" class="small-box-footer">More info <i class="fa fa-
arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-yellow">
<div class="inner">
<?php
$sql = "SELECT * FROM voters";
$query = $conn->query($sql);
echo "<h3>".$query->num_rows."</h3>";
?>
<p>Total Voters</p>
</div>
<div class="icon">
<i class="fa fa-users"></i>
</div>
<a href="[Link]" class="small-box-footer">More info <i class="fa fa-
arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-red">
<div class="inner">
<?php
$sql = "SELECT * FROM votes GROUP BY voters_id";
$query = $conn->query($sql);
echo "<h3>".$query->num_rows."</h3>";
?>
<p>Voters Voted</p>
</div>
<div class="icon">
<i class="fa fa-edit"></i>
</div>
<a href="[Link]" class="small-box-footer">More info <i class="fa fa-
arrow-circle-right"></i></a>
</div>
</div>
<!-- ./col -->
</div>
45
<div class="row">
<div class="col-xs-12">
<h3>Votes Tally
<span class="pull-right">
<a href="[Link]" class="btn btn-success btn-sm btn-flat"><span
class="glyphicon glyphicon-print"></span> Print</a>
</span>
</h3>
</div>
</div>
<?php
$sql = "SELECT * FROM positions ORDER BY priority ASC";
$query = $conn->query($sql);
$inc = 2;
while($row = $query->fetch_assoc()){
$inc = ($inc == 2) ? 1 : $inc+1;
if($inc == 1) echo "<div class='row'>";
echo "
<div class='col-sm-6'>
<div class='box box-solid'>
<div class='box-header with-border'>
<h4 class='box-title'><b>".$row['description']."</b></h4>
</div>
<div class='box-body'>
<div class='chart'>
<canvas id='".slugify($row['description'])."'
style='height:200px'></canvas>
</div>
</div>
</div>
</div>
";
if($inc == 2) echo "</div>";
}
if($inc == 1) echo "<div class='col-sm-6'></div></div>";
?>
</section>
<!-- right col -->
</div>
<?php include 'includes/[Link]'; ?>
</div>
<!-- ./wrapper -->
46
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
$sql = "SELECT * FROM candidates WHERE position_id = '".$row['id']."'";
$cquery = $conn->query($sql);
$carray = array();
$varray = array();
while($crow = $cquery->fetch_assoc()){
array_push($carray, $crow['lastname']);
$sql = "SELECT * FROM votes WHERE candidate_id = '".$crow['id']."'";
$vquery = $conn->query($sql);
array_push($varray, $vquery->num_rows);
}
$carray = json_encode($carray);
$varray = json_encode($varray);
?>
<script>
$(function(){
var rowid = '<?php echo $row['id']; ?>';
var description = '<?php echo slugify($row['description']); ?>';
var barChartCanvas = $('#'+description).get(0).getContext('2d')
var barChart = new Chart(barChartCanvas)
var barChartData = {
labels : <?php echo $carray; ?>,
datasets: [
{
label : 'Votes',
fillColor : 'rgba(60,141,188,0.9)',
strokeColor : 'rgba(60,141,188,0.8)',
pointColor : '#3b8bba',
pointStrokeColor : 'rgba(60,141,188,1)',
pointHighlightFill : '#fff',
pointHighlightStroke: 'rgba(60,141,188,1)',
data : <?php echo $varray; ?>
}
]
}
var barChartOptions ={
//Boolean - Whether the scale should start at zero, or an order of magnitude down
from the lowest value
scaleBeginAtZero : true,
//Boolean - Whether grid lines are shown across the chart
scaleShowGridLines : true,
//String - Colour of the grid lines
scaleGridLineColor : 'rgba(0,0,0,.05)',
//Number - Width of the grid lines
scaleGridLineWidth : 1,
//Boolean - Whether to show horizontal lines (except X axis)
scaleShowHorizontalLines: true,
//Boolean - Whether to show vertical lines (except Y axis)
scaleShowVerticalLines : true,
47
//Boolean - If there is a stroke on each bar
barShowStroke : true,
//Number - Pixel width of the bar stroke
barStrokeWidth : 2,
//Number - Spacing between each of the X value sets
barValueSpacing : 5,
//Number - Spacing between data sets within X values
barDatasetSpacing : 1,
//String - A legend template
legendTemplate : '<ul class="<%=[Link]()%>-legend"><% for
(var i=0; i<[Link]; i++){%><li><span style="background-
color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i
].label%><%}%></li><%}%></ul>',
//Boolean - whether to make the chart responsive
responsive : true,
maintainAspectRatio : true
}
[Link] = false
var myChart = [Link](barChartData, barChartOptions)
//[Link]('legend_'+rowid).innerHTML=
[Link]();
});
</script>
<?php
}
?>
</body>
</html>
6.4.4 [Link]:
<?php
session_start();
include 'includes/[Link]';
if(isset($_POST['login'])){
$username = $_POST['username'];
$password = $_POST['password'];
48
}
else{
$_SESSION['error'] = 'Incorrect password';
}
}
}
else{
$_SESSION['error'] = 'Input admin credentials first';
}
header('location: [Link]');
?>
6.4.5 [Link]
<?php
session_start();
session_destroy();
header('location: [Link]');
?>
6.4.6 [Link]
49
echo "
<div class='alert alert-danger alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-
hidden='true'>×</button>
<h4><i class='icon fa fa-warning'></i> Error!</h4>
".$_SESSION['error']."
</div>
";
unset($_SESSION['error']);
}
if(isset($_SESSION['success'])){
echo "
<div class='alert alert-success alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-
hidden='true'>×</button>
<h4><i class='icon fa fa-check'></i> Success!</h4>
".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<a href="#addnew" data-toggle="modal" class="btn btn-primary btn-sm btn-
flat"><i class="fa fa-plus"></i> New</a>
</div>
<div class="box-body">
<table id="example1" class="table table-bordered">
<thead>
<th>Lastname</th>
<th>Firstname</th>
<th>Photo</th>
<th>Voters ID</th>
<th>Tools</th>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM voters";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
$image = (!empty($row['photo'])) ? '../images/'.$row['photo'] :
'../images/[Link]';
echo "
<tr>
<td>".$row['lastname']."</td>
<td>".$row['firstname']."</td>
<td>
50
<img src='".$image."' width='30px' height='30px'>
<a href='#edit_photo' data-toggle='modal' class='pull-right photo'
data-id='".$row['id']."'><span class='fa fa-edit'></span></a>
</td>
<td>".$row['voters_id']."</td>
<td>
<button class='btn btn-success btn-sm edit btn-flat' data-
id='".$row['id']."'><i class='fa fa-edit'></i> Edit</button>
<button class='btn btn-danger btn-sm delete btn-flat' data-
id='".$row['id']."'><i class='fa fa-trash'></i> Delete</button>
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
51
});
function getRow(id){
$.ajax({
type: 'POST',
url: 'voters_row.php',
data: {id:id},
dataType: 'json',
success: function(response){
$('.id').val([Link]);
$('#edit_firstname').val([Link]);
$('#edit_lastname').val([Link]);
$('#edit_password').val([Link]);
$('.fullname').html([Link]+' '+[Link]);
}
});
}
</script>
</body>
</html>
6.4.7 [Link]
52
<button type='button' class='close' data-dismiss='alert' aria-
hidden='true'>×</button>
<h4><i class='icon fa fa-warning'></i> Error!</h4>
".$_SESSION['error']."
</div>
";
unset($_SESSION['error']);
}
if(isset($_SESSION['success'])){
echo "
<div class='alert alert-success alert-dismissible'>
<button type='button' class='close' data-dismiss='alert' aria-
hidden='true'>×</button>
<h4><i class='icon fa fa-check'></i> Success!</h4>
".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<a href="#reset" data-toggle="modal" class="btn btn-danger btn-sm btn-
flat"><i class="fa fa-refresh"></i> Reset</a>
</div>
<div class="box-body">
<table id="example1" class="table table-bordered">
<thead>
<th class="hidden"></th>
<th>Position</th>
<th>Candidate</th>
<th>Voter</th>
</thead>
<tbody>
<?php
$sql = "SELECT *, [Link] AS canfirst, [Link]
AS canlast, [Link] AS votfirst, [Link] AS votlast FROM votes LEFT
JOIN positions ON [Link]=votes.position_id LEFT JOIN candidates ON
[Link]=votes.candidate_id LEFT JOIN voters ON [Link]=votes.voters_id
ORDER BY [Link] ASC";
$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
echo "
<tr>
<td class='hidden'></td>
<td>".$row['description']."</td>
<td>".$row['canfirst'].' '.$row['canlast']."</td>
<td>".$row['votfirst'].' '.$row['votlast']."</td>
53
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
54
CHAPTER 7
TESTING
7.1 TESTING PLAN
Testing process starts with a test plan. This plan identifies all the testing related
activities that must be performed and specifies the schedules, allocates the resources,
and specified guidelines for testing. During the testing of the unit the specified test cases
are executed and the actual result compared with expected output. The final output of
the testing phase is the test report and the error report.
55
CHAPTER 8
CONCLUSION
8.1 CONCLUSION
Internet-based voting offers many benefits including low cost and increased voter
participation. Voting systems must consider security and human factors carefully, and
in particular make sure that they provide voters with reliable and intuitive indications
of the validity of the voting process. The system we propose uses visual cryptography
to provide mutual authentication for voters and election servers.
56
CHAPTER 9
BIBILOGRAPHY
References
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
57