- INTRODUCTION
- PREREQUISITE
- SAMPLE OUTPUT
- HOW IT WORKS !
- OTHER FEATURES
- SCOPE OF IMPROVEMENT
- CREDITS
- REFRENCES
ENIGMA was a Cipher Machine Used by Nazis at time of WW2
This project encrypts and decrypts the data entered by the user by using a symmetric key.
The key is based on ASCII values of certain sets of variables(DATE,TIME,INPUT).
The key changes every hour , so perpetrator have only an hour to crack the key , before it changes.
We have added various other features in our code like the voice, animation, sound,etc.
To run our program, the user must download the espeak synthesizer used in voice feature.
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
Input : Hello people
Output : lPuv+{r~⌂⌂v~
Input : lPuv+{r~⌂⌂v~
Output : Hello people
get the sum of current date and time's(HOUR's) ASCII value with help of this code
due to this code key changes every hour.
char buf[LEN];
int sum=0,i;
time_t t;
struct tm *timeStruct;
t= time(NULL);
timeStruct = localtime(&t);
strftime(buf, LEN, "%x-%I", timeStruct);
printf("\n");
printf("DATE & TIME\n");
printf("-> %s\n",buf);
printf("\n");
for(i=0;i<strlen(buf);i=i+3){
sum+=(int)buf[i]+(int)buf[i+1];}
FOR EG.
DATE - 25/01/22
TIME - 1800 hrs
sum value will be 402
D D \ M M \ Y Y
2 5 0 1 2 2
S1 = 50 + 53 + 48 + 49 + 50 + 50 = 300
TIME - 18:00 -> 06:00
0 6
S2 = 48 + 54 = 102
sum = S1 + S2 = 402
In this step u have to choose between 2 options
system("color 7C");
int num;
printf("CHOOSE AN OPTION \n");
printf("BY ENTERING A NUMBER\n");
printf("\n");
printf("[1] ENIGMA\n");
printf("[2] BOMBE\n");
printf("\n");
rintf("-> ");
scanf("%d",&num);
ENIGMA for ENCRYPTION
BOMBE for DECRYPTION
If u entered 1 you have selected encryption
So now u have input your data which has to be encrypted and the following code does that
// TAKING INPUT FROM USER---
gets(a);
for(i=0;i<100;i++){
ch1=getch();
if(ch1==13)
break;
a[i]=ch1;
printf("%c",ch1);}
a[i]='\0';
KEY is added
Making KEY is a 2 step process followed by output
First we need to determine the length of string is odd or even to determine the end point of loop
// STRING LENGTH EVEN OR ODD
if(strlen(a)%2==0){
b1=strlen(a);
} else{
b1=strlen(a)-1;
}
Here alternate elements of string are swapped
// LETTER INTERCHANGE
for(i=0;i<b1;i+=2){
temp1=a[i];
a[i]=a[i+1];
a[i+1]=temp1;
}
FOR EG.
heya -> ehay
KEY is half of length of input subtracted by 1st digit of sum which is obtained in STEP 1.
int key;
key=strlen(a)/2-sum%10;
In output ASCII values of string a[] are added with key and key is incremented with every character in string
printf("\n\nENCODED MESSAGE IS : ");
for(i=0;i<strlen(a);i++){
system("color A");
key=key+1;
printf("%c",a[i]+key);
}
printf("\n\nENCRYPTION SUCESSFUL!\n\n");
FOR EG.
INPUT : AAAA
A's ASCII value = 65
So
65 65 65 65
Is converted into
66+KEY 67+KEY 68+key 69+key
this step was taken to remove possiblity of repeatation.
If u have entered 2 you have selected decryption. Enter the Encrypted data using this code
char b[100];
scanf("%s",b);
KEY is subtracted
This is also a 2 step process followed by output
KEY is half of length of input subtracted by 1st digit of sum which is obtained in STEP 1.
After setting the KEY string b 's each character is decremented by it's ASCII value.
FOR EG.
INPUT : AAAA
A's ASCII value =65
So
65 65 65 65
is converted into
65-key 64-key 63-KEY 62-KEY
First we need to determine the length of string is odd or even to determine the end point of loop
// STRING LENGTH EVEN OR ODD
if(strlen(b)%2==0){
b1=strlen(b);
} else{
b1=strlen(b)-1;
}
Here alternate elements of string are swapped
// LETTER INTERCHANGE
for(i=0;i<b1;i+=2){
temp2=b[i];
b[i]=b[i+1];
b[i+1]=temp2;
}
FOR EG.
heya -> ehay
printf(" \nDECODED MESSAGE IS : ");
for(i=0;i<strlen(b);i++){
system("color E");
printf("%c",x2[i]);
}
printf("\n\nDECRYPTION SUCESSFUL!\n\n");
we use espeak synthesizer for voice function here is a sample code
#include<stdio.h>
#include<windows.h>
int main() {
system ("espeak -ven-us+f2 WE_CARE_FOR_YOUR_PRIVACY");
return 0;
}
You select different voice from 5 male and 5 female voices by making changes in espeak -ven-us+f2
f for female and m for male
1-5 for different pitches
You simply put a a message box by referring this sample code
#include<stdio.h>
#include<windows.h>
int main() {
MessageBox(0,"\n\n\nWE CARE FOR YOUR PRIVACY!\n\n","WELCOME",1);
Beep(800,500);
return 0;
}
Beep's frequency can be adjusted
This code opens any website you want like google.com , whatsapp.com , etc...
so you can send encrypted messages from website you want !
#include<stdio.h>
#include<windows.h>
#include<conio.h>
int main() {
// WEB PART------
printf("\nDo you want to open any services? (yes/no)\n");
printf("-> ");
char ans[10]; int f;
scanf("%s",ans);
if (ans[0]=='y'&&ans[1]=='e'&&ans[2]=='s'){
f=1;}
else{
f=0;
}
switch(f){
case 1:
printf("\n\nWHICH COMMUNICATION SERVICES DO YOU WANT TO OPEN?\n");
char i11[100];
scanf("%s",i11);
char i12[100]="\"Start www.";
strcat(i12,i11);
strcat(i12,".com\"");
system(i12);
while(!kbhit()){
;
}
break;
case 0:
printf("\nOKAY\n");
break;
}
return 0;
}
we use login system by simple switch case method but , we also masked the password using the following code
void mask(char spassword[]){
char ch; int i;
for(i=0;i<50;i++){
ch=getch();
if(ch==13)
break;
spassword[i]=ch;
ch='*';
printf("%c",ch);
}
spassword[i]='\0';
}
Animation was created by hardcoding frames and running it in a finite while loop
- The program can be further improved by using complex algorithms, as well as complex key.
System can be made to encrypt the data on the basis of Unicode values. - It also can be improved for encryption and decryption of images.
- It can also be improved for encryption and decryption of files.
- Key changing period can change as per convenience.
This project was done by
Prerna Sharma
Aditya Jambhale
Abuzer Ganjifrockwala
Ishan Bhat