Matrix Inverse
hi, I have read your posts in SDN concerning the matrix inversion.
would you please tell me how can I solve my problem concerning the 3 by 3 matrix. this is the code I use.
int base =256;
BigInteger p =new BigInteger("256");
BigInteger D =new BigInteger("3");
int s = Integer.parseInt(D.modInverse(p).toString());
int[][] key ={{1,2,3},{4,5,6},{7,8,8}};
int[][] ikey =newint[3][3];
for(int i= 0;i<3;i++)
for(int j= 0;j<3;j++){
ikey[i][j] = ((int)Math.pow(-1,i+j)*HillCipher.subMatrix(key, i, j)*s)%base;
ikey[i][j] = (ikey[i][j]<0)?ikey[i][j]+base:ikey[i][j];
}
the matrix which I recievce is not inverse of key matrix. also I have added subMatrix code below.
publicstaticint subMatrix(int[][]key,int i,int j){
int[][] rs =newint[key.length-1][key.length-1];
for(int k=0;k<key.length;k++)
for(int h=0;h<key[k].length;h++)
if(k!=i && h!=j){
int row = k;int col = h;
if(k>i)
row--;
if(h>j)
col--;
rs[row][col] = key[k][h];
}
return rs[0][0]*rs[1][1]-rs[0][1]*rs[1][0];
}

