Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Program only, Not C++ or C# The Caesar Cipher may have been good for the time it was invented, but it is to easy

C Program only, Not C++ or C#

The Caesar Cipher may have been good for the time it was invented, but it is to easy to break, especially with computers. Simply shift the encoded message using all the keys 'A' to 'Z' and one of the results will reveal the decrypted message.

The Vigenre cipher is a method of encrypting were the shift being used can vary from one letter to the next. So lets examine encryption of the word "HELLO" using the encryption key "BOOK". "HELLO" "BOOKB" Start by making the key as long as or longer than the message being encrypted. Repeat the key over again if needed. Since HELLO is 5 characters and BOOk is 4 characters, we start to repeat BOOK over again giving us BOOKB. Then take the first letter to encrypt. H=7, B=1, and we have 26 letters giving (7 + 1 ) % 26 = 8. So the letter H encrypts to 'I'. Let's do the next letter. E=4, O=14 giving us (4 + 14) % 26 = 18 % 26 = 18, or the letter 'S'. If we continue this procedure we will get "ISZVP" when "HELLO" is encrypted with "BOOK".

1) Ask the user if we are encrypting or decrypting.

2) Ask the user to enter a sentence to be transformed.

3) Ask the user to enter a sentence that will be used as the encryption or decryption key.

4) The sentences (array of characters) should end with a NULL terminator '\0'.

5) The range of values will be all printable characters on the ASCII chart starting with a SPACE - Value 32, up to and including a ~ - Value 126. Therefore, the number of symbols is 95 (0 to 94), i.e. Mod 95.

6) If the key is shorter than the message, make sure the key repeats until it matches the length of the text to be transformed.

7) Print out the transformed (encrypted or decrypted) message.

Tip. Given any printable character from the ASCII chart (32 to 126), then '?' - 32 gives a value from 0 to 94. Given any number from 0 to 94, adding 32 to that number gives the corresponding printable character.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel 2024 In 7 Days

Authors: Alan Dinkins

1st Edition

B0CJ3X98XK, 979-8861224000

More Books

Students also viewed these Databases questions

Question

Summarize the naturenurture debate in psychology.

Answered: 1 week ago

Question

What is a verb?

Answered: 1 week ago