The following is my current functions
________Sbox Function______
> Sbox2 <- 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 <-
> binary(c(4, 0, 6, 5, 7, 1, 3 ,2)) S12 <- binary(c(5, 3, 0, 7, 6, 2, 1,
> 4))
_______expand Function (provided)_____
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)
}
___round 1 Function____
round1 <- function(b,k){
#Divide the block into two equal halves called L0 and R0.
b <- (unlist(strsplit(b, "")))
k <- (unlist(strsplit(k, "")))
L0 <- b[1:6]
R0 <- b[7:12]
#Create two sub keys K1 containing the first 8 digits of K and K2 that contains the last 8 digits of K.
K1 <- k[1:8]
K2 <- k[2:9]
#Expand R0 from 6 t o 8 bits and call it ER0
ER0 <- expand(R0)
#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
fullblock <- bitwXor(ER0,K1)
block1 <- fullblock[1:4]
block2 <- fullblock[4:8]
# Call Sbox1() with block1 as its parameter.
# Call Sbox2() with block2 as its parameter.
b1 <- Sbox1(block1)
b2 <- Sbox2(block2)
# Concatenate the results of e) and f) and store the result in a variable called FR0.
FR0 <- c(b1,b2)
#Take the XOR of FR0 and L0 and store the results in R1.
R1 <- bitwXor(FR0,L0)
#Store R0 to L1
L1 <- R0
#Return L1 concatenated to R1
return(c(L1, R1))
} round1('000001010111','001101100')
Question: When running my round1() function, the bitwXor function keep repeating this error: Error in bitwXor(ER0, K1) : unimplemented type 'character' in 'bitwXor'
I have tried to work with different data type but nothing seems to work? Is it just a data type issue
P.S if it helps I am inputting into the function like: round1("000001010111","001101100")