Question

make a cesar cipher statistical attack using c++

make a cesar cipher statistical attack using c++
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

#include <string>

#include <algorithm>

using namespace std;

char encode(char, int);

char decode(char,int);

string encoding(string,int);

int main()

{

string message;

string deco;

string enco;

cout<<"Input text: ";

getline(cin,message);

int size;

cout<<"Enter cipher key: ";

cin>>size;

for(int i=0;i<message.length();i++){

enco=enco+encode(message[i],size);

}

for(int i=0;i<enco.length();i++){

deco=deco+decode(enco[i],size); //appending result

}

cout<<"Encoded Message: "<<enco<<endl;

cout<<"Decoded Message: "<<deco<<endl;

return 0;

}

char encode(char c, int seed){

return (int)c+seed;

}

char decode(char c, int seed){

return (int)c-seed;

}

OUTPUT:

IF YOU HAVE ANY QUERY PLEASE COMMENT DOWN BELOW

PLEASE GIVE A THUMBS UP

Add a comment
Know the answer?
Add Answer to:
make a cesar cipher statistical attack using c++
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 5. ENCRYPT following message using VIGENERE CIPHER a. attack at dawn; Key = SECRET b. no...

    5. ENCRYPT following message using VIGENERE CIPHER a. attack at dawn; Key = SECRET b. no travel in april; Key = PANDEMIC

  • 28. Use a brute-force attack to decipher the following message enciphered by Alice using an addit...

    28. Use a brute-force attack to decipher the following message enciphered by Alice using an additive cipher. Suppose that Alice always uses a key that is close to her birthday which is on the 13th of the month: LYOD 28. Use a brute-force attack to decipher the following message enciphered by Alice using an additive cipher. Suppose that Alice always uses a key that is close to her birthday which is on the 13th of the month: LYOD

  • Cesar needs to make a decision whether to fertilize his garden or not. His profit depends...

    Cesar needs to make a decision whether to fertilize his garden or not. His profit depends on his decision with respect to fertilizer and whether or not it rains. Cesar's profit w in each of the four possible cases is listed below. Assume that the probability of rain is 50%.                     Do not fertilize                Fertilize Rain               w = $16                       w = $25 No rain          w = $9                        w = $0 If Cesar decides to choose the action that maximizes his...

  • Is RSA algorithm is same as Ceaser Cipher Algorithm? if not kindly make simple program of...

    Is RSA algorithm is same as Ceaser Cipher Algorithm? if not kindly make simple program of RSA in c and c++.

  • Create a C program: A caesar cipher is a simple cipher that shifts letters in a...

    Create a C program: A caesar cipher is a simple cipher that shifts letters in a string. For example, shifting “ab” over by 1 would result in “bc”, and shifting “xyz” over by 2 would result in “zab”. The caesar program should take, in the command line an integer k, the amount to shift some text by, and a string f i l e, the name of a file containing text to encode using the cipher. For example, suppose “secret.txt”...

  • Language: C Write an encoder and a decoder for a modified "book cipher." A book cipher...

    Language: C Write an encoder and a decoder for a modified "book cipher." A book cipher uses a document or book as the cipher key, and the cipher itself uses numbers that reference the words within the text. For example, one of the Beale ciphers used an edition of The Declaration of Independence as the cipher key. The cipher you will write will use a pair of numbers corresponding to each letter in the text. The first number denotes the...

  • Eve captures Bob’s Hill cipher machine, which uses a 2 by 2 matrix M mod 26. She tries a chosen plaintext attack. She fi...

    Eve captures Bob’s Hill cipher machine, which uses a 2 by 2 matrix M mod 26. She tries a chosen plaintext attack. She finds that the plaintext “ba” encrypts to “HC” and the plaintext “zz” encrypts to “GT”. What is the matrix M.

  • Write a java program that takes the following phrases and encrypts them using a substitution cipher....

    Write a java program that takes the following phrases and encrypts them using a substitution cipher. The program should ask for a key and a phrase and then proceed to encrypt that phrase using the given shared key. Make sure that you have the key for the cipher and the output of encrypted phrases. Encrypt the phrase: He who fights with monsters should look to it that he himself does not become a monster. And if you gaze long into...

  • 1. Encrypt the message howareyou using the affine cipher using the key (7,3). (a) What is...

    1. Encrypt the message howareyou using the affine cipher using the key (7,3). (a) What is the resulting ciphertext? (b) What is the decryption function you can use to decipher each ciphertext character? (c) Use your decryption function to decrypt the message to confirm you get the ciphertext back. 2. Use the ADFGX cipher using the grid below and the keyword "place" to encrypt the plaintext "brandenburggate". FREE GX (a) (b) What is the resulting ciphertext? How does the ADFGC...

  • Language: C Write an encoder and a decoder for a modified "book cipher." A book cipher uses a doc...

    Language: C Write an encoder and a decoder for a modified "book cipher." A book cipher uses a document or book as the cipher key, and the cipher itself uses numbers that reference the words within the text. For example, one of the Beale ciphers used an edition of The Declaration of Independence as the cipher key. The cipher you will write will use a pair of numbers corresponding to each letter in the text. The first number denotes the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT