Encoding Program This program will accept sender blocks of size 2 and will encrypt and convert to receiver blocks of size 3. The user needs to enter the integer digits into the integer list. After choosing values for p, q and i the program converts those integer digits to base 10, encrypts and then converts back to integer digits. Choosing p, q, and i: > restart; > p:=ithprime(35); p := 149 > q:=ithprime(29); q := 109 > n:=p*q; n := 16241 > i:=43; i := 43 > Entering integer digits: The list integers contains the integer digits from the message that is to be encrypted. The list integersencrypted is set to the original integers but they will be changed later. > integers:=[[2,14],[13,6],[18,0],[19,20],[11,0],[19,8],[14,1 3],[18,26],[24,14],[20,26],[6,14],[19,26],[0,13],[26,0],[27 ,29],[28,29]]: > num:=nops(integers); num := 16 > integersencrypted:=[[2,14],[13,6],[18,0],[19,20],[11,0],[19 ,8],[14,13],[18,26],[24,14],[20,26],[6,14],[19,26],[0,13],[ 26,0],[27,29],[28,29]]: > numenc:=nops(integersencrypted); numenc := 16 > Converting integer digits to base 10: This procedure and loop converts the integer digits in the list integers to base 10 assuming they were in base 30. It returns all the converted values. > base:= proc(L,k) local T, x, y: T:= op(L): x:=T[k,1]: y:=T[k,2]: x*30+y: end; base := proc(L, k) local T, x, y; T := op( L ) ; x := T[ k, 1 ] ; y := T[ k, 2 ] ; 30xy end proc > for k from 1 to num do conv[k]:=base(integers,k): od; conv 1 := 74 conv 2 := 396 conv 3 := 540 conv 4 := 590 conv 5 := 330 conv 6 := 578 conv 7 := 433 conv 8 := 566 conv 9 := 734 conv 10 := 626 conv 11 := 194 conv 12 := 596 conv 13 := 13 conv 14 := 780 conv 15 := 839 conv 16 := 869 > Encryption: The encryption function h will be used to encrypt all the values in the array conv. > h:=x->x^i mod n; h := xx i mod n > for k from 1 to num do encry[k]:=h(conv[k]): od; encry 1 := 10122 encry 2 := 7688 encry 3 := 10920 encry 4 := 9964 encry 5 := 13630 encry 6 := 4436 encry 7 := 6535 encry 8 := 14684 encry 9 := 15575 encry 10 := 9454 encry 11 := 2438 encry 12 := 4023 encry 13 := 6047 encry 14 := 2505 encry 15 := 13767 encry 16 := 11222 > Converting back to integer digits: This loop converts all the encrypted values back to integer digit blocks of size 3 and stores them in the list integersencrypted. > for k from 1 to num do x1:=trunc(encry[k]/30^2): x2:=trunc((encry[k]-(x1*30^2))/30): x3:=encry[k] mod 30: integersencrypted:=subsop(k=[x1,x2,x3],integersencrypted): od: > integersencrypted; [ [ 11, 7, 12 ], [ 8, 16, 8 ], [ 12, 4, 0 ], [ 11, 2, 4 ], [ 15, 4, 10 ], [ 4, 27, 26 ], [ 7, 7, 25 ], [ 16, 9, 14 ], [ 17, 9, 5 ], [ 10, 15, 4 ], [ 2, 21, 8 ], [ 4, 14, 3 ], [ 6, 21, 17 ], [ 2, 23, 15 ], [ 15, 8, 27 ], [ 12, 14, 2 ] ] >