Encryption is commonly used to disguise messages on the internet. A Caesar cipher performs a shift of all of the characters in a string (based on their ASCII values, see Table 2.1), e.g. h e l l o → m j q q t The example shows a shift with a distance of 5 characters, i.e. h(ASCII:104) → m(ASCII:109) Write a C/C++ program that asks the user to input a line of plaintext and the distance value and outputs an encrypted text using a Caesar cipher, with the ASCII values range from 0 through 127. Use underscores (ASCII: 95) to represent space characters. Underscore characters should not be encrypted, and any character that is encrypted may not become an underscore. In this case, the character should be changed to the next character in the ASCII table. The program should work for any printable characters. NB: No strings (datatype) or library functions may be used.
Encryption is commonly used to disguise messages
on the internet. A Caesar cipher performs a shift of
all of the characters in a string (based on their ASCII
values, see Table 2.1), e.g.
h e l l o → m j q q t
The example shows a shift with a distance of 5
characters, i.e. h(ASCII:104) → m(ASCII:109)
Write a C/C++ program that asks the user to input a
line of plaintext and the distance value and outputs
an encrypted text using a Caesar cipher, with the
ASCII values range from 0 through 127. Use
underscores (ASCII: 95) to represent space
characters.
Underscore characters should not be encrypted,
and any character that is encrypted may not
become an underscore. In this case, the character
should be changed to the next character in the
ASCII table.
The program should work for any printable
characters.
NB: No strings (datatype) or library functions may
be used.
See Figure 2.1 for example output.
![16
17
ASCII-Tabel / ASCII Table
80
81
32
48
64
96
97
NUL
DLE
SP
112
P
SOH
DC1
33
49
65
A
113
STX
18
DC2
34
50
2
66
82
98
b.
114
ETX
19
DC3
35
51
67
83
99
115
EOT
20
DC4
36
52
68
D.
84
100
116
ENQ
21
NAK
37
53
5
69
85
101
117
ACK
22
SYN
38
54
6
70
86
V
102
118
BEL
23
ETB
39
55
71
G
87
103
119
BS
24
CAN
40
56
2ר
88
104
120
HT
25
EM
41
57
73
89
105
121
10
26
SUB
42
58
74
90
106
122
11
VT
27
ESC
43
59
5ר
91
107
123
12
FF
28
FS
44
60
< 76
L.
92
108
|1
124
13
CR
29
GS
45
61
77
93
109
125
14
SO
30
RS
46
62
78
94
110
126
15
SI
31
US
47
63
?| 79| o
95
111
127
DEL
Tabel 2.1/ Table 2.1
V A](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fed4f6c49-9921-4063-af6a-927cc53a9afc%2Fc2ac60b9-0815-458c-8627-9473ce7b7350%2Fjyswk5c_processed.png&w=3840&q=75)
![Enter the sentence to encrypt: Hello!_Your_pin_number_is:_76866
Enter the shift value: 3
The encrypted sentence is: Khoor$_\rxu_slq_qxpehu_lv=_:9;99
Figuur 2.1/ Figure 2.1](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fed4f6c49-9921-4063-af6a-927cc53a9afc%2Fc2ac60b9-0815-458c-8627-9473ce7b7350%2Fvb81vt6_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)