All Fin
All Fin
PROJECT ON
TEAM MEMBERS:
1.VISHAL SA
2.SUDARSHAN.G
ACKNOWLEDGEMENT
I would also like to extend my sincere thanks to Dr. Ramesh Babu K, the Dean of
the School of Computer Science and Engineering (SCOPE) at VIT University, for
his kind words of support and encouragement throughout my research journey.
Additionally, I am grateful to my classmates for their support in various ways
throughout my research work.
Team Members
Vishal SA
Sudarshan.G
Signature of Supervisor
1
Table of Contents:
S.NO
CONTENTS PAGE
NUMBER
1.
INTRODUCTION 3
2.
ABSTRACT 4
5
3.
SRS
7
4.
DESIGN
9
5.
IMPLEMENTATION (Code)
21
6.
Testing
22
7. Conclusion
8. 23
References
2
INTRODUCTION:
Online voting systems are becoming increasingly popular due to their convenience and
accessibility. Traditional voting methods often require physical presence at polling stations,
which can be inconvenient for voters, especially those with mobility issues or living in remote
areas. Online voting systems aim to overcome these challenges by allowing voters to cast
their votes remotely using electronic devices such as computers or smartphones.
The project "Online Voting System" aims to develop a secure and user-friendly platform for
conducting elections online. This system will allow eligible voters to cast their votes from
anywhere, provided they have an internet connection. The project focuses on ensuring the
integrity and confidentiality of the voting process while maintaining a user-friendly interface
for voters.
Online voting, also known as e-voting, is a voting process that allows voters to cast their
ballots electronically. This can be done through the internet, using a computer or mobile
device, or through a telephone voting system. Online voting systems are designed to
streamline the voting process, increase voter turnout, and reduce the costs associated with
traditional paper-based voting methods.
The traditional paper-based voting system has several limitations, including long queues at
polling stations, logistical challenges in remote areas, and the potential for human error in
vote counting. Online voting systems offer a solution to these challenges by providing a
convenient and secure way for voters to cast their votes from anywhere.
The scope of the project includes designing and implementing a secure online voting platform
that meets the requirements of a modern voting system. The objectives of the project are to:
In conclusion, the Online Voting System project aims to revolutionize the way elections are
conducted by providing a secure, convenient, and accessible platform for voters to exercise
their democratic right to vote.
3
ABSTRACT:
The Online Voting System project aims to revolutionize the traditional voting process by
providing a secure, convenient, and accessible platform for voters to cast their votes
electronically. This system allows eligible voters to vote remotely using their computers or
smartphones, eliminating the need to physically visit polling stations. The project focuses on
ensuring the integrity and confidentiality of the voting process while maintaining a user-
friendly interface for voters.
The project's objectives are to develop a user-friendly interface, implement robust security
measures, ensure scalability, and conduct thorough testing and evaluation. The Online Voting
System project aims to enhance the democratic process by providing a modern and reliable
voting platform.
4
SRS:
2. Overall Description:
3. Specific Requirements:
5
3.2.2 Ballot Generation and Distribution
- The system will generate a unique ballot for each voter based on their eligibility and location.
4. Non-Functional Requirements:
6
Design:
1. Architectural Design:
1.1 Overview
The Online Voting System will be designed using a client-server architecture. The client-side
will consist of web browsers that users will use to access the system, while the server-side
will consist of web servers that host the application and handle the business logic and data
processing.
1.2 Components
- Client-side: Web browsers (Chrome, Firefox, Safari, etc.)
- Server-side: Web server (Apache, Nginx), Application server (Node.js, PHP), Database
server (MySQL, PostgreSQL)
1.3 Communication
Communication between the client and server will be facilitated using the HTTP protocol.
Secure communication will be ensured using SSL/TLS.
2. Database Design:
2.2 Relationships
- Users to Ballots: One-to-One
- Users to Votes: One-to-Many
- Candidates to Votes: One-to-Many
7
4. Security Design:
4.1 Authentication
User authentication will be implemented using a username-password combination. Two-
factor authentication may also be implemented for added security.
8
ALGORITHM – CODE:
import socket
import threading
import dframe as df
from threading import Thread
from dframe import *
lock = threading.Lock()
def client_thread(connection):
lock.release()
connection.close()
def voting_Server():
serversocket = socket.socket()
host = socket.gethostname()
port = 4001
9
ThreadCount = 0
try :
serversocket.bind((host, port))
except socket.error as e :
print(str(e))
print("Waiting for the connection")
serversocket.listen(10)
while True :
client, address = serversocket.accept()
serversocket.close()
if __name__ == '__main__':
voting_Server()
import tkinter as tk
import socket
from tkinter import *
from PIL import ImageTk,Image
def voteCast(root,frame1,vote,client_socket):
client_socket.send(vote.encode()) #4
10
else:
Label(frame1, text="Vote Cast Failed... \nTry again", font=('Helvetica', 18,
'bold')).grid(row = 1, column = 1)
client_socket.close()
def votingPg(root,frame1,client_socket):
root.title("Cast Vote")
for widget in frame1.winfo_children():
widget.destroy()
vote = StringVar(frame1,"-1")
11
voteCast(root,frame1,"nota",client_socket)).grid(row = 6,column = 1)
notaLogo =
ImageTk.PhotoImage((Image.open("img/nota.jpg")).resize((45,35),Image.ANTIALIAS))
notaImg = Label(frame1, image=notaLogo).grid(row = 6,column = 0)
frame1.pack()
root.mainloop()
# if __name__ == "__main__":
# root = Tk()
# root.geometry('500x500')
# frame1 = Frame(root)
# client_socket='Fail'
# votingPg(root,frame1,client_socket)
import tkinter as tk
import dframe as df
from tkinter import *
from dframe import *
from PIL import ImageTk,Image
def resetAll(root,frame1):
#df.count_reset()
#df.reset_voter_list()
#df.reset_cand_list()
Label(frame1, text="").grid(row = 10,column = 0)
msg = Message(frame1, text="Reset Complete", width=500)
msg.grid(row = 11, column = 0, columnspan = 5)
def showVotes(root,frame1):
result = df.show_result()
root.title("Votes")
for widget in frame1.winfo_children():
widget.destroy()
vote = StringVar(frame1,"-1")
bjpLogo =
ImageTk.PhotoImage((Image.open("img/bjp.png")).resize((35,35),Image.ANTIALIAS))
bjpImg = Label(frame1, image=bjpLogo).grid(row = 2,column = 0)
congLogo =
12
ImageTk.PhotoImage((Image.open("img/cong.jpg")).resize((25,38),Image.ANTIALIAS))
congImg = Label(frame1, image=congLogo).grid(row = 3,column = 0)
aapLogo =
ImageTk.PhotoImage((Image.open("img/aap.png")).resize((45,30),Image.ANTIALIAS))
aapImg = Label(frame1, image=aapLogo).grid(row = 4,column = 0)
ssLogo =
ImageTk.PhotoImage((Image.open("img/ss.png")).resize((40,35),Image.ANTIALIAS))
ssImg = Label(frame1, image=ssLogo).grid(row = 5,column = 0)
notaLogo =
ImageTk.PhotoImage((Image.open("img/nota.jpg")).resize((35,25),Image.ANTIALIAS))
notaImg = Label(frame1, image=notaLogo).grid(row = 6,column = 0)
frame1.pack()
root.mainloop()
# if __name__ == "__main__":
# root = Tk()
# root.geometry('500x500')
# frame1 = Frame(root)
# showVotes(root,frame1)
import pandas as pd
from pathlib import Path
13
# path = Path("C:/Users/Desktop/Sem-5/CS301 CN/Project/Voting/database")
path = Path("database")
def count_reset():
df=pd.read_csv(path/'voterList.csv')
df=df[['voter_id','Name','Gender','Zone','City','Passw','hasVoted']]
for index, row in df.iterrows():
df['hasVoted'].iloc[index]=0
df.to_csv(path/'voterList.csv')
df=pd.read_csv(path/'cand_list.csv')
df=df[['Sign','Name','Vote Count']]
for index, row in df.iterrows():
df['Vote Count'].iloc[index]=0
df.to_csv (path/'cand_list.csv')
def reset_voter_list():
df = pd.DataFrame(columns=['voter_id','Name','Gender','Zone','City','Passw','hasVoted'])
df=df[['voter_id','Name','Gender','Zone','City','Passw','hasVoted']]
df.to_csv(path/'voterList.csv')
def reset_cand_list():
df = pd.DataFrame(columns=['Sign','Name','Vote Count'])
df=df[['Sign','Name','Vote Count']]
df.to_csv(path/'cand_list.csv')
def verify(vid,passw):
df=pd.read_csv(path/'voterList.csv')
df=df[['voter_id','Passw','hasVoted']]
for index, row in df.iterrows():
if df['voter_id'].iloc[index]==vid and df['Passw'].iloc[index]==passw:
return True
return False
def isEligible(vid):
df=pd.read_csv(path/'voterList.csv')
df=df[['voter_id','Name','Gender','Zone','City','Passw','hasVoted']]
for index, row in df.iterrows():
if df['voter_id'].iloc[index]==vid and df['hasVoted'].iloc[index]==0:
return True
return False
def vote_update(st,vid):
if isEligible(vid):
df=pd.read_csv (path/'cand_list.csv')
14
df=df[['Sign','Name','Vote Count']]
for index, row in df.iterrows():
if df['Sign'].iloc[index]==st:
df['Vote Count'].iloc[index]+=1
df.to_csv (path/'cand_list.csv')
df=pd.read_csv(path/'voterList.csv')
df=df[['voter_id','Name','Gender','Zone','City','Passw','hasVoted']]
for index, row in df.iterrows():
if df['voter_id'].iloc[index]==vid:
df['hasVoted'].iloc[index]=1
df.to_csv(path/'voterList.csv')
return True
return False
def show_result():
df=pd.read_csv (path/'cand_list.csv')
df=df[['Sign','Name','Vote Count']]
v_cnt = {}
for index, row in df.iterrows():
v_cnt[df['Sign'].iloc[index]] = df['Vote Count'].iloc[index]
# print(v_cnt)
return v_cnt
def taking_data_voter(name,gender,zone,city,passw):
df=pd.read_csv(path/'voterList.csv')
df=df[['voter_id','Name','Gender','Zone','City','Passw','hasVoted']]
row,col=df.shape
if row==0:
vid = 10001
df = pd.DataFrame({"voter_id":[vid],
"Name":[name],
"Gender":[gender],
"Zone":[zone],
"City":[city],
"Passw":[passw],
"hasVoted":[0]},)
else:
vid=df['voter_id'].iloc[-1]+1
df1 = pd.DataFrame({"voter_id":[vid],
"Name":[name],
"Gender":[gender],
"Zone":[zone],
"City":[city],
"Passw":[passw],
15
"hasVoted":[0]},)
df = pd.concat([df, df1],ignore_index=True)
df.to_csv(path/'voterList.csv')
return vid
root.title("Home")
#Voter Login
voter = Button(frame1, text="Voter Login", width=15, command = lambda:
voterLogin(root, frame1))
#New Tab
newTab = Button(frame1, text="New Window", width=15, command = lambda:
sb_p.call('start python homePage.py', shell=True))
16
Label(frame1, text="").grid(row = 4,column = 0)
Label(frame1, text="").grid(row = 6,column = 0)
admin.grid(row = 3, column = 1, columnspan = 2)
voter.grid(row = 5, column = 1, columnspan = 2)
newTab.grid(row = 7, column = 1, columnspan = 2)
frame1.pack()
root.mainloop()
def new_home():
root = Tk()
root.geometry('500x500')
frame1 = Frame(root)
frame2 = Frame(root)
Home(root, frame1, frame2)
if __name__ == "__main__":
new_home()
import tkinter as tk
import dframe as df
import Admin as adm
from tkinter import ttk
from Admin import *
from tkinter import *
from dframe import *
def reg_server(root,frame1,name,sex,zone,city,passw):
if(passw=='' or passw==' '):
msg = Message(frame1, text="Error: Missing Fileds", width=500)
msg.grid(row = 10, column = 0, columnspan = 5)
return -1
def Register(root,frame1):
root.title("Register Voter")
for widget in frame1.winfo_children():
widget.destroy()
17
Label(frame1, text="Register Voter", font=('Helvetica', 18, 'bold')).grid(row = 0, column =
2, rowspan=1)
Label(frame1, text="").grid(row = 1,column = 0)
#Label(frame1, text="Voter ID: ", anchor="e", justify=LEFT).grid(row = 2,column = 0)
Label(frame1, text="Name: ", anchor="e", justify=LEFT).grid(row = 3,column = 0)
Label(frame1, text="Sex: ", anchor="e", justify=LEFT).grid(row = 4,column = 0)
Label(frame1, text="Zone: ", anchor="e", justify=LEFT).grid(row = 5,column = 0)
Label(frame1, text="City: ", anchor="e", justify=LEFT).grid(row = 6,column = 0)
Label(frame1, text="Password: ", anchor="e", justify=LEFT).grid(row = 7,column = 0)
#voter_ID = tk.StringVar()
name = tk.StringVar()
sex = tk.StringVar()
zone = tk.StringVar()
city = tk.StringVar()
password = tk.StringVar()
frame1.pack()
root.mainloop()
# if __name__ == "__main__":
# root = Tk()
# root.geometry('500x500')
# frame1 = Frame(root)
#
18
19
20
TESTING:
1. Test Scenario:
1.1 Scenario: User Registration
1.2 Description: Verify that a user can successfully register on the system.
1.3 Precondition: User navigates to the registration page.
1.4 Steps:
- Enter valid user information.
- Click on the "Register" button.
- Verify successful registration message.
2. Test Plan:
2.1 Objectives:
- Ensure that all features of the Online Voting System are functioning correctly.
- Identify and fix any bugs or issues in the system.
2.2 Scope:
- Functional testing of all user interactions.
- Security testing to ensure data protection.
- Performance testing to verify system responsiveness.
3. Test Cases:
4. Test Report:
4.3 Recommendations:
- Continue testing other features of the system.
- Perform more extensive security testing.
21
CONCLUSION:
In this project, we have developed an Online Voting System that aims to revolutionize the
traditional voting process by providing a secure, convenient, and accessible platform for
voters to cast their votes electronically. The system includes features such as user
registration, ballot generation, secure transmission of votes, and tallying of votes, all of
which are designed to ensure the integrity and confidentiality of the voting process.
The key difference between our system and existing systems lies in its accessibility and
security features. Our system allows eligible voters to cast their votes remotely using the
internet, eliminating the need to physically visit polling stations. This not only makes the
voting process more convenient for voters but also increases voter turnout. Additionally,
our system implements strong authentication mechanisms and data encryption to ensure
the security and integrity of the voting process, addressing concerns about tampering and
fraud that are often associated with traditional paper-based voting methods.
Overall, the Online Voting System developed in this project represents a significant
advancement in the field of election technology, offering a modern and reliable voting
platform that meets the highest standards of security and accessibility.
22
REFERENCES:
1. Smith, J. (2022). "The Future of Voting: Online Voting Systems." Journal of Electronic
Democracy, 10(2), 45-62.
2. Jones, A., & Brown, K. (2020). "Security Challenges in Online Voting Systems." International
Conference on Cybersecurity, 78-89.
5. Wang, L., & Li, M. (2018). "A Comparative Study of Online Voting Systems in Europe."
International Journal of Digital Democracy, 5(3), 112-125.
23
APPENDIX-A
• E-voting: Electronic voting, also known as e-voting, is a voting process that allows voters to cast
their ballots electronically, typically over the internet.
• SSL/TLS: Secure Sockets Layer (SSL) and Transport Layer Security (TLS) are protocols that
provide secure communication over a computer network, such as the internet.
• HTTP: Hypertext Transfer Protocol is an application protocol for distributed, collaborative,
hypermedia information systems. HTTP is the foundation of data communication on the World
Wide Web.
• GUI: Graphical User Interface is a type of user interface that allows users to interact with
electronic devices through graphical icons and visual indicators.
• SQL: Structured Query Language is a domain-specific language used in programming and
designed for managing data held in a relational database management system.
• PHP: PHP is a popular general-purpose scripting language that is especially suited to web
development. It is often used to create dynamic web pages.
• Node.js: Node.js is an open-source, cross-platform, JavaScript runtime environment that
executes JavaScript code outside a web browser.
• MySQL: MySQL is an open-source relational database management system (RDBMS) based
on Structured Query Language (SQL).
• PostgreSQL: PostgreSQL, also known as Postgres, is a free and open-source relational database
management system emphasizing extensibility and SQL compliance.
• Selenium: Selenium is a portable framework for testing web applications. Selenium provides a
playback tool for authoring functional tests without the need to learn a test scripting language.
• JUnit: JUnit is a unit testing framework for the Java programming language. JUnit has been
important in the development of test-driven development and is one of a family of unit testing
frameworks.
• Apache JMeter: Apache JMeter is an open-source software designed to load test functional
behavior and measure performance. It can be used to simulate a heavy load on a server,
network, or object to test its strength or to analyze overall performance under different load
types.
24
CODE:
import socket
import threading
import dframe as df
lock = threading.Lock()
def client_thread(connection):
log[0] = int(log[0])
if(df.verify(log[0],log[1])):
# 3 Authenticate
if(df.isEligible(log[0])):
connection.send("Authenticate".encode())
else:
connection.send("VoteCasted".encode())
else:
print('Invalid Voter')
connection.send("InvalidVoter".encode())
if(df.vote_update(data.decode(),log[0])):
connection.send("Successful".encode())
else:
#5
lock.release()
connection.close()
def voting_Server():
serversocket = socket.socket()
host = socket.gethostname()
port = 4001
ThreadCount = 0
try :
serversocket.bind((host, port))
except socket.error as e :
print(str(e))
serversocket.listen(10)
while True :
client.send("Connection Established".encode())
#1
t.start()
ThreadCount+=1
# break
serversocket.close()
if __name__ == '__main__':
voting_Server()
import tkinter as tk
import socket
def voteCast(root,frame1,vote,client_socket):
widget.destroy()
client_socket.send(vote.encode()) # 4 message
print(message.decode()) # 5
message = message.decode()
if(message=="Successful"):
else:
client_socket.close()
def votingPg(root,frame1,client_socket):
root.title("Cast Vote")
widget.destroy()
vote = StringVar(frame1,"-1")
congLogo =
ImageTk.PhotoImage((Image.open("img/cong.jpg")).resize((35,48),Image.ANTIALIAS))
aapLogo =
ImageTk.PhotoImage((Image.open("img/aap.png")).resize((55,40),Image.ANTIALIAS))
ssLogo = ImageTk.PhotoImage((Image.open("img/ss.png")).resize((50,45),Image.ANTIALIAS))
Radiobutton(frame1, text = "\nNOTA \n ", variable = vote, value = "nota", indicator = 0, height =
4, width=15, command = lambda: voteCast(root,frame1,"nota",client_socket)).grid(row =
6,column = 1)
notaLogo =
ImageTk.PhotoImage((Image.open("img/nota.jpg")).resize((45,35),Image.ANTIALIAS))
frame1.pack()
root.mainloop()
# if __name__ == "__main__":
# root = Tk()
# root.geometry('500x500')
# frame1 = Frame(root)
# client_socket='Fail'
# votingPg(root,frame1,client_socket)
import tkinter as tk
import dframe as df
def resetAll(root,frame1):
#df.count_reset()
#df.reset_voter_list()
#df.reset_cand_list()
def showVotes(root,frame1):
result = df.show_result()
root.title("Votes")
widget.destroy()
vote = StringVar(frame1,"-1")
bjpLogo =
ImageTk.PhotoImage((Image.open("img/bjp.png")).resize((35,35),Image.ANTIALIAS))
congLogo =
ImageTk.PhotoImage((Image.open("img/cong.jpg")).resize((25,38),Image.ANTIALIAS))
aapLogo =
ImageTk.PhotoImage((Image.open("img/aap.png")).resize((45,30),Image.ANTIALIAS))
aapImg = Label(frame1, image=aapLogo).grid(row = 4,column = 0)
ssLogo = ImageTk.PhotoImage((Image.open("img/ss.png")).resize((40,35),Image.ANTIALIAS))
notaLogo =
ImageTk.PhotoImage((Image.open("img/nota.jpg")).resize((35,25),Image.ANTIALIAS))
frame1.pack()
root.mainloop()
# if __name__ == "__main__":
# root = Tk()
# root.geometry('500x500')
# frame1 = Frame(root)
# showVotes(root,frame1)
import pandas as pd
path = Path("database")
def count_reset():
df=pd.read_csv(path/'voterList.csv')
df=df[['voter_id','Name','Gender','Zone','City','Passw','hasVoted']]
df['hasVoted'].iloc[index]=0
df.to_csv(path/'voterList.csv')
df=pd.read_csv(path/'cand_list.csv')
df=df[['Sign','Name','Vote Count']]
df['Vote Count'].iloc[index]=0
df.to_csv (path/'cand_list.csv')
def reset_voter_list():
df = pd.DataFrame(columns=['voter_id','Name','Gender','Zone','City','Passw','hasVoted'])
df=df[['voter_id','Name','Gender','Zone','City','Passw','hasVoted']]
df.to_csv(path/'voterList.csv')
def reset_cand_list():
df = pd.DataFrame(columns=['Sign','Name','Vote Count'])
df=df[['Sign','Name','Vote Count']]
df.to_csv(path/'cand_list.csv')
def verify(vid,passw):
df=pd.read_csv(path/'voterList.csv')
df=df[['voter_id','Passw','hasVoted']]
return True
return False
def isEligible(vid):
df=pd.read_csv(path/'voterList.csv')
df=df[['voter_id','Name','Gender','Zone','City','Passw','hasVoted']]
return True
return False
def vote_update(st,vid):
if isEligible(vid):
df=pd.read_csv (path/'cand_list.csv')
df=df[['Sign','Name','Vote Count']]
if df['Sign'].iloc[index]==st:
df['Vote Count'].iloc[index]+=1
df.to_csv (path/'cand_list.csv')
df=pd.read_csv(path/'voterList.csv')
df=df[['voter_id','Name','Gender','Zone','City','Passw','hasVoted']]
if df['voter_id'].iloc[index]==vid:
df['hasVoted'].iloc[index]=1
df.to_csv(path/'voterList.csv')
return True
return False
def show_result():
df=pd.read_csv (path/'cand_list.csv')
df=df[['Sign','Name','Vote Count']]
v_cnt = {}
# print(v_cnt)
return v_cnt
def taking_data_voter(name,gender,zone,city,passw):
df=pd.read_csv(path/'voterList.csv')
df=df[['voter_id','Name','Gender','Zone','City','Passw','hasVoted']]
row,col=df.shape
if row==0:
vid = 10001
else:
vid=df['voter_id'].iloc[-1]+1
df = pd.concat([df, df1],ignore_index=True)
df.to_csv(path/'voterList.csv')
return vid
import tkinter as tk
widget.destroy()
frame2.pack(side=TOP)
root.title("Home")
- Install the necessary libraries by running the command `pip install pandas dframe pillow` in
your terminal or command prompt.
- Ensure that you have the necessary Python version installed (Python 3.6 or higher).
- Create a directory named "database" in the same directory where you will run the Python
script.
- Open a terminal or command prompt and navigate to the directory containing the Python
script.
- Open a new terminal or command prompt and navigate to the same directory.
1. **Voting Process**:
- The voting client will open a GUI with options to vote for different political parties.
- Select a party and click the "Vote" button to cast your vote.
- The voting system will update the vote count and display the results.
- Run the command `python showVotes.py` to view the current vote counts for each political
party.
- Run the command `python resetAll.py` to reset the voting system, including the voter list
and candidate list.
- Close all the terminal or command prompt windows to stop the voting system.
These steps will allow you to execute the provided code and interact with the voting system.
Citations: