#OK to post homework #Joseph Koutsoutis, 03-31-2024, Assignment 18 read `C18.txt`: #1 MakeCubic := proc(L,n): if nops(L) <> 20 then return(FAIL): fi: return(BinToIn([op(1..5,L)])+ BinToIn([op(6..10,L)])*n+ BinToIn([op(11..15,L)])*n^2+ BinToIn([op(16..20,L)])*n^3): end: #2 EncodeDES := proc(M,K,r) local i,M_enc: if nops(M) mod 2 <> 0 then return(FAIL): fi: if nops(K) <> 20*r then return(FAIL): fi: M_enc := M: for i from 1 to r do: M_enc := Feistel(M_enc, n -> MakeCubic(K[(20*(i-1)+1)..(20*(i))], n)): od: return(M_enc): end: #3 DecodeDES := proc(M,K,r) local i,M_dec: if nops(M) mod 2 <> 0 then return(FAIL): fi: if nops(K) <> 20*r then return(FAIL): fi: M_dec := M: for i from r to 1 by -1 do: M_dec := revFeistel(M_dec, n -> MakeCubic(K[(20*(i-1)+1)..(20*(i))], n)): od: return(M_dec): end: