Question: I need help with generating RSA encryption code for a C programming ( C 9 0 standard ) for a voting system. It has to
I need help with generating RSA encryption code for a C programming C standard for a voting system. It has to encrypt the Voters personal details in the RSA format. Below is the C code for the main.c file.
#include
#include
#include
#include
#define MAXNUMBERSIZE
#define MAXFNAMESIZE
#define MAXLNAMESIZE
#define MAXMOBNOSIZE
#define MAXIDSIZE
#define MAXSTNUMBERSIZE
#define MAXSTNAMESIZE
#define MAXSUBURBSIZE
#define MAXPCODESIZE
#define MAXVOTERS
int MAXPEOPLE ;
int numVoters ;
struct dateOfBirth
unsigned int day;
unsigned int month;
unsigned int year;
;
typedef struct DateOfBirth DoBt;
struct address
char streetNumberMAXSTNUMBERSIZE;
char streetNameMAXSTNAMESIZE;
char suburbMAXSUBURBSIZE;
char postCodeMAXPCODESIZE;
;
typedef struct address addrt;
struct PersonalDetails
char firstNameMAXFNAMESIZE;
char lastNameMAXLNAMESIZE;
addrt address;
char mobileNumberMAXMOBNOSIZE;
DoBt dateOfBirth;
char shareholderIDMAXIDSIZE;
votersMAXVOTERS;
COLLECTING VOTES
void numberOfVoters; Liam
void getPersonalDetails; Liam
void encrypt; hansali
void compress; marcus
RECEIVING VOTES
void receiveData; Liam
void decompress; marcus
void decrypt; hansali
void printResults;
MERGE VOTES
void mergeVotes;
Linked List Implementation
typedef struct node
char firstNameMAXFNAMESIZE;
char lastNameMAXLNAMESIZE;
int numVotes;
struct node next;
nodet;
Candidaterelated functions
nodet createNodechar firstName, char lastName, int numVotes; Harry
void addCandidatenodet head, char firstName, char lastName, int numVotes; Harry
void printCandidatesnodet head; Harry
void votenodet head; Harry
nodet findCandidatenodet head, char firstName, char lastName; Harry
nodet createNodechar firstName, char lastName, int numVotes
nodet newNode nodetmallocsizeofnodet;
if newNode NULL
fprintfstderr "Memory allocation failed
;
exitEXITFAILURE;
strcpynewNodefirstName, firstName;
strcpynewNodelastName, lastName;
newNodenumVotes numVotes;
newNodenext NULL;
return newNode;
void updateVotenodet head, int index, char firstName, char lastName
Traverse to find candidate
If doesn't exist make new candidate
nodet current head;
if new candidate, index is
ifindex
addCandidatecurrent firstName, lastName;
printfAdded new Candidate!
;
return;
Iterate current to given index and increase vote
int counter;
forcounter ; counter index; counter
current currentnext;
found current, increase vote by
currentnumVotes ;
printfAdded vote for s s
currentfirstName, currentlastName;
Function to add a candidate to the linked list
void addCandidatenodet head, char firstName, char lastName, int numVotes
nodet existingCandidate findCandidatehead firstName, lastName;
if existingCandidate NULL
existingCandidatenumVotes;
printfAdded a vote to existing candidate s s
firstName, lastName;
else
if head NULL
head createNodefirstName lastName, numVotes;
else
nodet current head;
while currentnext NULL
current currentnext;
currentnext createNodefirstName lastName, numVotes;
printfAdded new candidate s s with vote
firstName, lastName;
Function to find a candidate in the linked list
nodet findCandidatenodet head, char firstName, char lastName
nodet current head;
while current NULL
if strcmpcurrentfirstName, firstName && strcmpcurrentlastName, lastName
return current; Candidate found
current currentnext;
return NULL; Candidate not found
Function to vote for a candidate
void votenodet head
int choice;
printf
Vote for a candidate Enter to add a new candidate: ;
scanfd &choice;
if choice
char firstNameMAXNAMESIZE;
char lastNameMAXNAMESIZE;
printfEnter the first name of the new candidate: ;
scanfs firstName;
printfEnter the last name of the new candidate:
Please write the correct encryption and decryption codes.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
