Question: help with procedure with affine cypher

I have to create a procedure that decodes an encoded message using a 2x2 matrix and a row vector.  (Alphanumeric is a 95 character string)

So far I have A:=Matrix(2, 2, [[17,22], [4, 53]]); B:=Vector[row]([19,82]); as my two matricies, and have writtten this as my proc:


AffineMatEncode := proc(text::string,
      A::{matrix, Matrix, list},
      B::{vector, Vector, list})
   local vtext,vcrypt,i,n,p, Inv, minv, minv2, w, D;
   global AlphaNumeric;
   vtext := StringToVects(text, n);
   vcrypt:= [seq(map(modp, evalm( A &* vtext[i] + B), p), i=1..nops(vtext))];
   Inv:=MatrixInverse(A); Determinant(Inv);
   D:=1/Determinant mod 95;
   minv2:=map(modp, minv, 95);
   w:=map(modp, evalm(minv2 &* (-B)), 95);
end proc:  

I believe the end might be wrong, because it's not taking the proper input, can someone help me fix this?

Please Wait...