answersLogoWhite

0

//Monalphabetic Cipher

/**Created by:Mihir Vadalia*/

#include

#include

FILE *source,*dest,*kf;

void encrypt();

void decrypt();

void main()

{

int choice;

do

{

clrscr();

printf("\n\n\t\tMonoalphabetic Cipher\n\nEnter your chice:\n");

printf("1.Encryption\n2.Decryption\n3.Exit.\n\nYour Choice:");

scanf("%d",&choice);

switch(choice)

{

case 1:

encrypt();

break;

case 2:

decrypt();

break;

default:

exit(0);

}

getch();

}while(choice);

}

void encrypt()

{

char k[26]={'/0'},fname[15],ch;

int i,n;

printf("\n\nEnter the name of file to be encrypted:\n");

flushall();

gets(fname);

flushall();

source = fopen(fname,"r");

dest = fopen("Dest.txt","w");

kf = fopen("key.txt","r");

i=0;

while((ch=getc(kf))!=EOF)

{

k[i]=ch;

i++;

}

while ((ch=getc(source))!=EOF)

{

n=(int)ch-97;

for (i=0;i!=n;i++);

putc(k[i],dest);

}

fclose(dest);

fclose(source);

fclose(kf);

printf("\n\nThe file has been encrypted...\n\nThe contents are:\n");

dest=fopen("Dest.txt","r");

while((ch=getc(dest))!=EOF)

printf("%c",ch);

}

void decrypt()

{

char k[26]={'/0'},fname[15],ch;

int i,n;

printf("\n\nEnter the name of file to be decrypted:\n");

flushall();

gets(fname);

flushall();

dest = fopen(fname,"r");

kf = fopen("key.txt","r");

i=0;

while((ch=getc(kf))!=EOF)

{

k[i]=ch;

i++;

}

printf("\nDecrypted contents are : ");

while ((ch=getc(dest))!=EOF)

{

for (i=0;ch!=k[i];i++);

putchar(97+i);

}

fclose(source);

fclose(kf);

}

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

What is difference between monoalphabetic and polyalphabetic cipher?

In a monoalphabetic cipher, our substitution characters are a random permutation of the 26 letters of the alphabet: plaintext letters: a b c d e f ..... substitution letters: t h i j a b ..... • The key now is the sequence of substitution letters. In other words, the key in this case is the actual random permutation of the alphabet used. For a particular alphabet, only one substitution can be used example: if the substitution letter for 'a' is 't' and for 'd' it is 'p' then if the keyword happens to be "tpp"..... then we can encrypt the message as "add"(note that the substitution letter for 'd' is only 'p'.. In a monoalphabetic cipher, the same substitution rule is used for every substitution. In a polyalphabetic cipher, the substitution rule changes continuously from letter to letter according to the elements of the encryption key. Example for polyalphabetic: key: abracadabraabracadabraabracadabraab plaintext: canyoumeetmeatmidnightihavethegoods ciphertext: CBEYQUPEFKMEBK..................... • The Vigenere cipher is an example of a polyalphabetic cipher.


Difference of polyalphabetic substitution cipher and polyalphabetic cipher?

In a monoalphabetic cipher, our substitution characters are arandom permutation of the 26 letters of the alphabet:plaintext letters: a b c d e f .....substitution letters: t h i j a b .....• The key now is the sequence of substitution letters. In otherwords, the key in this case is the actual random permutation ofthe alphabet used.For a particular alphabet, only one substitution can be usedexample: if the substitution letter for 'a' is 't' and for 'd' it is 'p'then if the keyword happens to be "tpp"..... then we can encrypt the message as "add"(note that the substitution letter for 'd' is only 'p'..In a monoalphabetic cipher, the same substitution rule is used forevery substitution. In a polyalphabetic cipher, the substitutionrule changes continuously from letter to letter according to theelements of the encryption key.Example for polyalphabetic:key: abracadabraabracadabraabracadabraabplaintext: canyoumeetmeatmidnightihavethegoodsciphertext: CBEYQUPEFKMEBK.....................• The Vigenere cipher is an example of a polyalphabetic cipher.


Algorithm for hill cipher?

Hill Cipher is a cryptographic algorithm to encrypt and decrypt an alphabetic text. In this cipher, each letter is represented by a number (eg. A = 0, B = 1, C = 2). To encrypt a message, each block of n letters (considered as an n -component vector) is multiplied by an invertible n × n matrix, against modulus 26.


Difference of polyalphabetic substitution cipher and monoalphabetic cipher?

mono meant one so substitution the replaced values as one character each value of alphabetic substitute A-Z . Plain text: a b c d e….. Substitution: d e f g h….. Polyalphabetic it's nothing but.. ploy meant more than one so its contain the more than one letters to substitution then also here using the key. Mono and ploy are using the same techniques of the substitution. Substitutions are having mono and ploy and then etc… In a monoalphabetic cipher, our substitution characters are a random permutation of the 26 letters of the alphabet: plaintext letters: a b c d e f ..... substitution letters: t h i j a b ..... • The key now is the sequence of substitution letters. In other words, the key in this case is the actual random permutation of the alphabet used. For a particular alphabet, only one substitution can be used example: if the substitution letter for 'a' is 't' and for 'd' it is 'p' then if the keyword happens to be "tpp"..... then we can encrypt the message as "add"(note that the substitution letter for 'd' is only 'p'.. In a monoalphabetic cipher, the same substitution rule is used for every substitution. In a polyalphabetic cipher, the substitution rule changes continuously from letter to letter according to the elements of the encryption key. Example for polyalphabetic: key: abracadabraabracadabraabracadabraab plaintext: canyoumeetmeatmidnightihavethegoods ciphertext: CBEYQUPEFKMEBK..................... • The Vigenere cipher is an example of a polyalphabetic cipher.


What is the program to write route cipher?

c#


What is the command to decrypt the myfiledoc?

cipher /d C:\filename.ext.


How do you write a program a bout rotor cipher using C?

Just fart!


How do you complete level 54 on 100 Floors?

a=01 so code is c=03 o=15 d=04 e=05 The A=01 is the cipher and the level is asking you enter C-O-D-E where C=03, O=15, D=04, and E=05. See related links for screenshots.


How you complete level 54 on 100 Floors?

a=01 so code is c=03 o=15 d=04 e=05 The A=01 is the cipher and the level is asking you enter C-O-D-E where C=03, O=15, D=04, and E=05. See related links for screenshots.


What is key of hill cipher if we have plain text and cipher text?

Assume Plaintext = P, Ciphertext = C, and the Key = K. C = P * K Therefore, multiply both sides by the inverse of P and you will get: C * P^(-1) = K Or, (ciphertext) * (inverse plaintext) = key If the size of the key is known as well, then use that same size when creating P and C matrices.


What is Caesar cipher?

secret language add 3 more e.g..................... a=d b=e c=f and so on.......


Is substitution a type of cipher?

Yes A=B B=C etc so CAT in cypher is DBU as one example

Trending Questions
Quality and reliability are related concepts but are fundamentally different in a number of ways Discuss them? Can use stone dust as a filler material for bituminous concrete? How do you calculate how to split a 7.5Kw load over 3 phases? Why do people need to develop alternative sources of renewable energy and become less dependent on fossil fuels? What is the organizational structure of management in a power plant? How is a Residual Current Device or RCD different to a Ground Fault Circuit Interrupter or GFCI? What is the minimum value of power factor of a circuit can have under what circumstances can this occur? How data is represented in dbms? Why converting a base class pointer to a derived class pointer is consider dangerous by the compiler? What is the minimum value of Ir test in 11kv cables? If you are considering Ch 7 but do not want to include a newly purchased vehicle are you able to still file? In which layer will liquid petroleum be found in the oil trap shown in figure 4-1? What is better civil or electronics for engineering? What are the codes called that surround the HTML text? Accidentally drop cardboard down the toilet how do you get it out? Purpose of minimum flow line for centrifugal pump? How is hooke's law releted to torque wrench action? What are the procedure of construction of a well foundation? Is there a way to calculate the physical length of the groove on a compact disc based on the time length of the track? Which error is the violation of grammar rules of a programming language?