Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can I encrypt a text using substitution cipher in R language? The plain text that I have to encrypt is p_text

How can I encrypt a text using substitution cipher in R language?

The plain text that I have to encrypt is p_text <- "Members of the Senate and of the House of Representatives of the United States, I feel greatly honored that you should have thus invited me to enter the United States Senate Chamber and address the representatives of both branches of Congress. The fact that my American forebears have for so many generations played their part in the life of the United States, and that here I am, an Englishman, welcomed in your midst, makes this experience one of the most moving and thrilling in my life, which is already long and has not been entirely uneventful. I wish indeed that my mother, whose memory I cherish, across the vale of years, could have been here to see. By the way, I cannot help reflecting that if my father had been American and my mother British instead of the other way around, I might have got here on my own. In that case this would not have been the first time you would have heard my voice. In that case I should not have needed any invitation. But if I had it is hardly likely that it would have been unanimous. So perhaps things are better as they are"

splitting0 <- strsplit(p_text, "")

chars0 <- unlist(strsplit(p_text, ""))

I already created a key variable, key <- "ZGYHXIWJVKULTMSARBQCPDOENF"

key <- "ZGYHXIWJVKULTMSARBQCPDOEN"

splitting <- strsplit(key, "")

chars <- unlist(strsplit(key, ""))

I was told to use a match function to encrypt. This is how I am trying to encrypt it

for (i in chars0)

{

ctexts <- c(match(i, chars0))

ctext <- chars[ctexts]

}

ctext

But all is get as my output is the letter G

Also after encrypting, how would you decrypt it?

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_2

Step: 3

blur-text-image_3

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

Students also viewed these Databases questions

Question

What are limit up- limit down rules?

Answered: 1 week ago

Question

c. What groups were least represented? Why do you think this is so?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago