Posts

Showing posts from July, 2017

Poly alphabetic cipher implementation in C

Image
Practical - 4 Implement Poly alphabetic cipher encryption-decryption. Download Practical Code: //this code accepts only characters without spaces #include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h> void take_input(char *text) { int i=0; char c; while(1) { c=getch(); if(c==13) { text[i]='\0'; break; } else if(c==8) { putch('\b'); putch(' '); putch('\b'); i--; } else if(c!=32) { if((c>=65 && c<=90) || (c>=97 && c<=122)) { printf("%c",c); text[i]=c; i++; } } } } void encrypt() { int i=0,j=0,pt_len,key_len,temp; char c,pt[200],ct[200],key[200]; printf("Enter text to encrypt:\n"); take_input(&pt); printf("\nEnter key to encrypt:\n"); take_input(&key); pt_len=strlen(pt); key_len=strlen(key); for(i=0;i<pt_len;i++) { if(

Ceaser Cipher Method Implementation in C

Image
Practical - 1 Write a C program to implement Ceaser Cipher method for encryption and decryption. Download Practical Code: //It Accepts alphabets only #include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h> void take_input(char *text) { int i=0; char c; while(1) { c=getch(); if(c==13) { text[i]='\0'; break; } else if(c==8) { putch('\b'); putch(' '); putch('\b'); i--; } else if(c!=32) { if((c>=65 && c<=90) || (c>=97 && c<=122)) { printf("%c",c); text[i]=c; i++; } } } } int key; void encrypt() { int i=0,len; char ct[200],pt[200],temp;//ct=cipher text,pt=plain text printf("Enter message to encrypt:\n"); take_input(&pt); printf("\nEnter key for encryption:\t"); scanf("%d",&key); len=strlen(pt); while(i<len) { te