Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ programming. code needs to output sample The Affine cipher is a cryptographic method for encrypting text such that it becomes unreadable to a party

image text in transcribed

image text in transcribed

C++ programming. code needs to output sample

The Affine cipher is a cryptographic method for encrypting text such that it becomes unreadable to a party without access to the cryptographic key. The encryption and decryption operations are simple shifts of the alphabet letters in a cyclic fashion. Mathematically, for a key k-(a, 3), the encryption and decryption are defined as: Encryption: c-(a r B) mod 26, 1Sa 26 and 1SB 26 Decryption: x = a-1, (c-d) mod 26. Here, 1 is a multiplicative inverse of a in the group of integers modulo 26. To find the multiplicative inverse of one needs to find z such that a -1 mod 26 A simple way of finding the inverse of a is to consider all numbers from 1 to 25 and see which one satisfies equation To illustrate the use of the Affine cipher, consider the encryption of "defend the east wall of the castle" with key k = (, ) = (5,7). The first letter "d is mapped to number 3 (alphabet letters are numbered from 0 to 25). Inserting 3 to the encryption functions yields c 5 * 3 + 7 mod 26-22 mod 26-22 which corresponds to letter "w". Applying the same process for ever letter, the plaintext sentence is translated to "wbgbuw yqb bhty nhkk zg yqb rhtykb" . Now to decode, we first need to find the inverse of 5 modulo 26. Scanning every number from 1 to 25, we observe that 5-21 mod 26 so the inverse of 5 is 21. Using 21 for decrypting the first letter "" (or 22) becomes 21 (22-7) mod 263, which reverses back to letter "d NOTE: The modulo operation for negative numbers is different from the % arithmetic operator in C. Write a C program that decrypts a file named "encrypted.txt" and places the decryption output to a file called "de- crypted.txtA file encrypted with k (5,7) is provided with the assignment. You can use it to test your decryption function. You will know when you have succeeded because the text becomes readable. In your program

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

=+ 5. Do Europeans work more or fewer hours than Americans?

Answered: 1 week ago