Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Rotation cypher. Characters are represented internally in C++ by the standard integer ASCII code. Example: s=Hello!; v= 7210110810811133// ASCII code of string s

In C++

Rotation cypher.

Characters are represented internally in C++ by the standard integer ASCII code.

Example:

s="Hello!";

v= 7210110810811133// ASCII code of string s

The 72 corresponds to "H," 101 to "e," etc. Here we will use the 94 codes for printable ASCII characters from 32 (space) up to 125 ("]") to make a rotation cipher. Think of the numbers from 32 to 125 on a circle:

[...32, 33, 34,... , 124, 125, 32, 33,...]

The cipher consists of replacing each character with ASCII code N with the character corresponding to the code 47 steps to the right around the circle. Code a function so=rot47(si)that returns the input string encrypted in this way. Using the function again should decrypt the string.

s=rot47(' Abort mission ')// encode Abort mission and return a string s

s= p3@CEO>:DD:@?] // encoded cyphertext

s= rot47(s)

s = Abort mission.// decoded cyphertext

Hint:

Convert the string into array of ASCII codes, add 47, if the result> 125 then subtract 94. First, generate the encoded text using rot47 function, then use the same function to decode the text back.

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

=+3. Explain the bag-of-words model, tf-idf and the n-gram model.

Answered: 1 week ago