Posts

mono alphabetic Cipher substitution technique

Image
AIM: To implement a program for encrypting a plain text and decrypting a cipher text using mono alphabetic Cipher substitution technique. CODE: #include<iostream> #include<conio.h> #include<stdio.h> #include<string.h> void encryption(); void decryption(); char pt[50],ct[50],ch; char alpha[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; char sub[26]={'q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m'}; int i,j; using names...

Caesar Cipher

Image
AIM: To implement a program for encrypting a plain text and decrypting a cipher text using Caesar Cipher (shift cipher) substitution technique. CODE: #include<stdio.h> //ASCII RANGE CAN BE MODIFIED HERE int ascii_min=32; int ascii_max=126; void encryption(char p[], int key, int length){ int range,i; for(i=0;i<length;i++){ p[i]=p[i]-ascii_min; } for(i=0;i<length;i++){ p[i]=(p[i]+key)%range; } for(i=0;i<length;i++){ p[i]=p[i]+ascii_min; } printf("\nYour Cipher Text is: %s\n",p); } void decryption(char c[], int key, int length){ int i; for(i=0;i<length;i++){ c[i]=c[i]-ascii_min; } for(i=0;i<length;i++){ c[i]=(c[i]-key)%range; } for(i=0;i<length;i++){ c[i]=c[i]+ascii_min; } printf("\nYour Plain Text is: %s\n",c); } void main(){ int key; char data[30]; printf("ENCRYPTION FUNCTION\n---------------------------"); printf("\nEnter the Plain text: "); ge...