Question
Please write your code in R and submit your script and results for each of the following. Use the functions expand() and S1_function() to do
Please write your code in R and submit your script and results for each of the following. Use the functions expand() and S1_function() to do the following:
USE THE FOLLOWING Function:
expand <- function(v) { ev <- vector(mode = "character") swap(v[3], v[4]) ev[1:4] <- v[1:4] ev[5:8] <- v[3:6] return(ev) } v
S11_function <- function(b) { b <- unlist(strsplit(b, "")) tempVal <- unbinary(paste(b[2:4], collapse = '')) tempRet <- ifelse((b[1] == "0"), S11[tempVal + 1], S12[tempVal + 1]) return(tempRet) } S11_function("1110")
QUESTION :
Create a second function for substitution box S2_function() that replicates the S1_function() your wrote for homework 4 except that it uses the following substitution boxes: S11 contains the binary of the numbers (4, 0, 6, 5, 7, 1, 3 2) and S12 contains those for (5, 3, 0, 7, 6, 2, 1, 4). (20 points)
Create a round function called round1() that takes a binary character vector of length 12 and key K of length 9 and does the following: (20 points total)
Divide the block into two equal halves called L0 and R0.
Create two sub keys K1 containing the first 8 digits of K and K2 that contains the last 8 digits of K.
Expand R0 from 6 t o 8 bits and call it ER0.
Take the XOR of the result of ER0 with K1. Store the first 4 bits in a variable called block1 and the last 4 bits in a variable called block2.
Call S1_function with block1 as its parameter.
Call S2_function with block2 as its parameter.
Concatenate the results of e) and f) and store the result in a variable called FR0.
Take the XOR of FR0 and L0 and store the results in R1.
Store R0 to L1.
Return L1 concatenated to R1.
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