The ROT-13 algorithm encrypts a string one character at a time by adding 13 to the value of the internal representation of the character. We want our encryption scheme to cover the entire printable ASCII range. After examining the ASCII character set and their internal representations, we see that characters 0 through 32 and character 127 are control characters. Technically, characters 32 (space) and 127 (DEL) are printable, but we don’t want to include them in our encryption routine. Therefore, we want our encrypted string to only contain characters in the range of 33 through 126. As an example:   Plaintext:              Norwich Ciphertext:                        [|!&vpu   The internal representation of ‘N’ is 78. 78 plus 13 is 91, which is the character ‘[‘. The internal representation of ‘o’ is 111. 111 plus 13 is 124, which is the character ‘|’. The internal representation of ‘r’ is 114. 114 plus 13 is 127. Since 126 is our maximum value for our desired printable range, we must use modular arithmetic. Therefore, we get (114+13)%127=0. The character for 0 on the ASCII chart is NULL, which is still not within our desired range. So we have to shift any values less than 33. Therefore, ‘r’ encrypts to ‘!’ which is value 33. Character ‘s’ would be encrypted as ‘"’, which is value 34. The image below helps explain the encryption process. Write a C++ program that prompts the user to enter a password. The program then calls an encryption function that returns a string as the encrypted password. Print the encrypted password to the screen. Note that the printing of the encrypted password should occur inside of main() and not inside of your encryption function. Show your source code and a screenshot of your program output.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
  1. The ROT-13 algorithm encrypts a string one character at a time by adding 13 to the value of the internal representation of the character. We want our encryption scheme to cover the entire printable ASCII range. After examining the ASCII character set and their internal representations, we see that characters 0 through 32 and character 127 are control characters. Technically, characters 32 (space) and 127 (DEL) are printable, but we don’t want to include them in our encryption routine. Therefore, we want our encrypted string to only contain characters in the range of 33 through 126. As an example:

 

Plaintext:              Norwich

Ciphertext:                        [|!&vpu

 

The internal representation of ‘N’ is 78. 78 plus 13 is 91, which is the character ‘[‘. The internal representation of ‘o’ is 111. 111 plus 13 is 124, which is the character ‘|’. The internal representation of ‘r’ is 114. 114 plus 13 is 127. Since 126 is our maximum value for our desired printable range, we must use modular arithmetic. Therefore, we get (114+13)%127=0. The character for 0 on the ASCII chart is NULL, which is still not within our desired range. So we have to shift any values less than 33. Therefore, ‘r’ encrypts to ‘!’ which is value 33. Character ‘s’ would be encrypted as ‘"’, which is value 34. The image below helps explain the encryption process.

Write a C++ program that prompts the user to enter a password. The program then calls an encryption function that returns a string as the encrypted password. Print the encrypted password to the screen. Note that the printing of the encrypted password should occur inside of main() and not inside of your encryption function. Show your source code and a screenshot of your program output.

 

Plaintext:
Internal
Representation
Encrypt
(Add 13 mod 127)
Printable?
(Y or N)
Scale Non-
Printables by 33
Ciphertext:
N
с
h
↓↓↓↓
↓ ↓↓
78 111 114 119 105 99 104
↓↓↓↓↓
↓ ↓ ↓ ↓
r W i
91 124 0 5 118 112 117
↓↓↓↓↓↓
1 1
Y Y N N Y Y Y
↓ ↓ ↓
|II|||
↓ ↓
↓
91 124
33 38 118 112 117
↓ ↓
↓↓ ↓ ↓ ↓ ↓
[ | ! & V
pu
Transcribed Image Text:Plaintext: Internal Representation Encrypt (Add 13 mod 127) Printable? (Y or N) Scale Non- Printables by 33 Ciphertext: N с h ↓↓↓↓ ↓ ↓↓ 78 111 114 119 105 99 104 ↓↓↓↓↓ ↓ ↓ ↓ ↓ r W i 91 124 0 5 118 112 117 ↓↓↓↓↓↓ 1 1 Y Y N N Y Y Y ↓ ↓ ↓ |II||| ↓ ↓ ↓ 91 124 33 38 118 112 117 ↓ ↓ ↓↓ ↓ ↓ ↓ ↓ [ | ! & V pu
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Public key encryption
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education