Question
I understand how this is supposed to work, but I can't figure out how swapping values would expand a character vector, like in section 3
I understand how this is supposed to work, but I can't figure out how swapping values would expand a character vector, like in section 3 and 5 or how replicating v[3] and v[4] would result in an 8 bit character vector such as in section 4.
1) Store the following binary number as a character string s: 110011.
2) Convert this into a character vector v.
3) Expand the character vector v to 8 bits as follows: swap v[3] and v[4] .
4) Replicate v[3] and v[4] . The result (call it ev) should be a character vector of size 8.
5) Write a function called expand() that takes a binary vector of size 6 as input and returns a binary vector of size 8 as output.
6) Create two character vectors S11 and S12 such that S11 contains the binary representations of the numbers (5,2,1,6,3,4,7,0), and S12 contains those of the numbers (1,4,6,2,0,7,5,3).
7) Let b=1101. Extract the last three characters. Convert the last three characters into decimal and store it in a variable called tempVal. Write an if-then-else statement such that if b[1] == 0 retrieve the value of S11[tempval]. If b[1]==1 retrieve the value of S12[tempval] and store it in a variable tempRet. (Hint: You might need to shift the indices by 1)
8) Write a function called S11_function that takes a block of 4-character binary (such as 1110) and, using the two s-boxes from question 6, returns a 3-character binary number using the logic that if the first character is 0 then use S11, otherwise use S12.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started