(Substitution Cipher) A substitution cipher is a more complicated way to encrypt lext than a Caesar cipher. The basic version of a substitution cipher converts cach given character in a message by permuting the letters of the alphabet based on a fixed permutation. The permutation itself can be simply viewed as a permutation of the numbers 1 through 26. Any permutation of these numbers can casily be represented by vector of length 26 consisting of the integers from 1 to 26, cach appearing exactly once. For instance, the vector [2, 3, 4, 5, ..., 26, 1] represents the permutation that converts 1 to 2, 2 to 3, ..., 25 to 26, and 26 to 1. For this problem, you should write two separate functions: the first handles the con- version of just a single character while the second works on a string of length 3. subs_char Function: Input Variables: • a single character to be converted using the substitution cypher • a permutation (as described above) to be used in the encryption Output variables: •a single character of encrypted text subs_cipher Function: Input Variables: • a length 3 string of lower case letlers representing a short plain text message • a permutation (as described above) to be used in the encryption Output variables: • a length 3 string representing the results of the encryption llint: For the subs_char function, you'll need to convert the character to a number between 1 and 26 and use this as an index in the permutation vector. A possible sample case is: » cchar = subs_char('a’, [2:26, 1]) cchar - b » ctext = subs_cipher(’abc', [ 5, 7, 1, 2:4, 6, 8:26 ]) ctext = ega >> ctext = %3D subs_cipher(’abc’, randperm(26)) ctext = gts
(Substitution Cipher) A substitution cipher is a more complicated way to encrypt lext than a Caesar cipher. The basic version of a substitution cipher converts cach given character in a message by permuting the letters of the alphabet based on a fixed permutation. The permutation itself can be simply viewed as a permutation of the numbers 1 through 26. Any permutation of these numbers can casily be represented by vector of length 26 consisting of the integers from 1 to 26, cach appearing exactly once. For instance, the vector [2, 3, 4, 5, ..., 26, 1] represents the permutation that converts 1 to 2, 2 to 3, ..., 25 to 26, and 26 to 1. For this problem, you should write two separate functions: the first handles the con- version of just a single character while the second works on a string of length 3. subs_char Function: Input Variables: • a single character to be converted using the substitution cypher • a permutation (as described above) to be used in the encryption Output variables: •a single character of encrypted text subs_cipher Function: Input Variables: • a length 3 string of lower case letlers representing a short plain text message • a permutation (as described above) to be used in the encryption Output variables: • a length 3 string representing the results of the encryption llint: For the subs_char function, you'll need to convert the character to a number between 1 and 26 and use this as an index in the permutation vector. A possible sample case is: » cchar = subs_char('a’, [2:26, 1]) cchar - b » ctext = subs_cipher(’abc', [ 5, 7, 1, 2:4, 6, 8:26 ]) ctext = ega >> ctext = %3D subs_cipher(’abc’, randperm(26)) ctext = gts
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
make a code , if you can uses mathlab
keep basic code no if or return
![(Substitution Cipher) A substitution cipher is a more complicated way to encrypt
text than a Caesar cipher. The basic version of a substitution cipher converts cach
given character in a message by permuting the letters of the alphabet based on a fixed
permutation. The permutation itself can be simply viewed as a permutation of the
numbers 1 through 26. Any permutation of these numbers can casily be represented
by vector of length 26 consisting of the integers from 1 to 26, cach appearing exactly
once. For instance, the vector
[2, 3, 4, 5, ..., 26, 1]
represents the permutation that converts 1 to 2, 2 to 3, ..., 25 to 26, and 26 to 1.
For this problem, you should write two separate functions: the first handles the con-
version of just a single character while the second works on a string of length 3.
subs_char Function:
Input Variables:
• a single character to be converted using the substitution cypher
a permutation (as described above) to be used in the encryption
Output variables:
• a single character of encrypted text
subs_cipher Function:
Input Variables:
• a length 3 string of lower case letlers representing a short plain text
message
• a permutation (as described above) to be used in the encryption
Output variables:
• a length 3 string representing the results of the encryption
IHint: For the subs_char function, you'll need to convert the character to a number
between 1 and 26 and use this as an index in the permutation vector.
A possible sample case is:
>> cchar =
subs_char('a', [2:26, 1])
cchar = b
» ctext = subs_cipher(’abc', [ 5, 7, 1, 2:4, 6, 8:26 ])
ctext = ega
>> ctext =
subs_cipher('abc’, randperm(26))
ctext =
gts](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff610f60e-c097-44c0-9c2f-23e045cb2fc2%2F3e468b7b-d64e-4978-b536-863cf757b746%2Fbesiln_processed.png&w=3840&q=75)
Transcribed Image Text:(Substitution Cipher) A substitution cipher is a more complicated way to encrypt
text than a Caesar cipher. The basic version of a substitution cipher converts cach
given character in a message by permuting the letters of the alphabet based on a fixed
permutation. The permutation itself can be simply viewed as a permutation of the
numbers 1 through 26. Any permutation of these numbers can casily be represented
by vector of length 26 consisting of the integers from 1 to 26, cach appearing exactly
once. For instance, the vector
[2, 3, 4, 5, ..., 26, 1]
represents the permutation that converts 1 to 2, 2 to 3, ..., 25 to 26, and 26 to 1.
For this problem, you should write two separate functions: the first handles the con-
version of just a single character while the second works on a string of length 3.
subs_char Function:
Input Variables:
• a single character to be converted using the substitution cypher
a permutation (as described above) to be used in the encryption
Output variables:
• a single character of encrypted text
subs_cipher Function:
Input Variables:
• a length 3 string of lower case letlers representing a short plain text
message
• a permutation (as described above) to be used in the encryption
Output variables:
• a length 3 string representing the results of the encryption
IHint: For the subs_char function, you'll need to convert the character to a number
between 1 and 26 and use this as an index in the permutation vector.
A possible sample case is:
>> cchar =
subs_char('a', [2:26, 1])
cchar = b
» ctext = subs_cipher(’abc', [ 5, 7, 1, 2:4, 6, 8:26 ])
ctext = ega
>> ctext =
subs_cipher('abc’, randperm(26))
ctext =
gts
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY