I have two empty arrays and some variables:
static int p = 41;
static int q = 67;
static int d = 83;
static int n = p * q;
static int[] encryptedBlocks = new int[charArray.length];
static int[] decryptedArray = new int[charArray.length];
the first of which is filled with the following (I've checked, and it is):
1573
1978
385
1092
1022
857
856
1387
225
606
2293
1339
1630
The second array I'm attempting to fill with the results of an equation in a for loop:
for (int i = 0; i < encryptedBlocks.length; i++) {
int M = (int)Math.pow(encryptedBlocks[i], d) % n;
decryptedArray[i] = M;
}
Problem is I get the same result for M
for each iteration.. I'm totally clueless as to what is going on:
2662
2662
2662
2662
2662
2662
2662
2662
2662
2662
2662
2662
2662
Just in case I've double checked encryptedBlocks[i]
is indeed the next value each iteration, and it is. Am I missing something in relation to using int
and Math.pow()
?
First two iteration values for encryptedBlocks[i]
, d
and n
:
1573 83 2747
1978 83 2747