C Program:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<conio.h> | |
#include<string.h> | |
#define pf printf | |
#define sf scanf | |
char dc[26]="XDGSZANYOBTMJCEVFHKWPLQURI"; | |
char ec[26]="abcdefghijklmnopqrstuvwxyz"; | |
void e(char*); | |
void d(char*); | |
void main(){ | |
char *p; | |
clrscr(); | |
pf("\n\nEnter plain text:"); | |
sf("%s",p); | |
pf("\nAfter Encryption:\n-----------------\n"); | |
e(p); | |
pf("\n%s",p); | |
pf("\nAfter Decryption:\n-----------------\n"); | |
d(p); | |
pf("\n%s",p); | |
getch(); | |
} | |
void e(char *p){ | |
int l=0; | |
while(*(p+l) != '\0'){ | |
*(p+l)=dc[*(p+l)-97]; | |
l++; | |
} | |
} | |
void d(char *p){ | |
int l=0; | |
while(*(p+l) != '\0'){ | |
int i; | |
for(i=0;i<26;i++){ | |
if(dc[i]==*(p+l)) | |
break; | |
} | |
*(p+l)=ec[i]; | |
l++; | |
} | |
} |
nice code.
ReplyDeleteyes
ReplyDelete