Posts

Showing posts with the label INS

Implement Hill cipher encryption-decryption

Image
Practical - 5 Implement Hill cipher encryption-decryption. Download Practical Code: #include<stdio.h> #include<math.h> float encrypt[3][1], decrypt[3][1], a[3][3], b[3][3], mes[3][1], c[3][3]; void encryption();    //encrypts the message void decryption();    //decrypts the message void getKeyMessage();    //gets key and message from user void inverse();        //finds inverse of key matrix int main() { int choice; //clrscr(); while(1) { printf("Enter Your choice:\n1.Encrypt\t2.Decrypt\t3.Exit\n"); scanf("%d",&choice); switch(choice) { case 1: { encryption(); break; } case 2: { decryption(); break; } case 3: break; default: { printf("Enter a valid choice\n"); } } if(choice==3) return 0; } } void encryption() {     int i, j, k;     getKeyMessage();     for(i = 0; i <...

Implement Play fair cipher encryption-decryption

Image
Practical - 3 Implement Play fair cipher encryption-decryption. Download Practical Code: #include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h> char key[5][5]={'p','l','a','y','f','i','r','b','c','d','e','g','h','k','m','n','o','q','s','t','u','v','w','x','z'}; void take_input(char *text) { int i=0; char c,pre; 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(isalpha(c) || isdigit(c)) { putch(c); //printf("\nalpha\t"); if(isdigit(c)) { } else if(isupper(c)) { c=c+32; } if(i==0) { ...

Implement Mono alphabetic cipher encryption-decryption

Image
Practical - 2 Implement Mono alphabetic cipher encryption-decryption. Download Practical Code: //It Accepts alphabets only #include<stdio.h> #include<conio.h> #include<string.h> #include<ctype.h> char keyl[26] = {'k', 'd', 'j', 'i', 'l', 'w', 'y', 'o', 'r', 't', 'a', 'c', 'e', 'h', 'b', 'u', 'x', 'v', 'p', 'z', 'n', 'q', 'f', 's', 'm', 'g' }; char keyu[26] = {'K', 'D', 'J', 'I', 'L', 'W', 'Y', 'O', 'R', 'T', 'A', 'C', 'E', 'H', 'B', 'U', 'X', 'V', 'P', 'Z', 'N', 'Q', 'F', 'S', 'M', 'G' }; void take_input(char *text) { int i=0; char c...

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...