@@ -67,10 +67,10 @@ public void setKey(String key) {
67
67
private static final int [][][] S = {S1 , S2 , S3 , S4 , S5 , S6 , S7 , S8 };
68
68
69
69
// Permutation table, used in the Feistel function post s-box usage
70
- static int [] permutation = {16 , 7 , 20 , 21 , 29 , 12 , 28 , 17 , 1 , 15 , 23 , 26 , 5 , 18 , 31 , 10 , 2 , 8 , 24 , 14 , 32 , 27 , 3 , 9 , 19 , 13 , 30 , 6 , 22 , 11 , 4 , 25 };
70
+ static final int [] PERMUTATION = {16 , 7 , 20 , 21 , 29 , 12 , 28 , 17 , 1 , 15 , 23 , 26 , 5 , 18 , 31 , 10 , 2 , 8 , 24 , 14 , 32 , 27 , 3 , 9 , 19 , 13 , 30 , 6 , 22 , 11 , 4 , 25 };
71
71
72
72
// Table used for final inversion of the message box after 16 rounds of Feistel Function
73
- static int [] ipInverse = {40 , 8 , 48 , 16 , 56 , 24 , 64 , 32 , 39 , 7 , 47 , 15 , 55 , 23 , 63 , 31 , 38 , 6 , 46 , 14 , 54 , 22 , 62 , 30 , 37 , 5 , 45 , 13 , 53 , 21 , 61 , 29 , 36 , 4 , 44 , 12 , 52 , 20 , 60 , 28 , 35 , 3 , 43 , 11 , 51 , 19 , 59 , 27 , 34 , 2 , 42 , 10 , 50 , 18 , 58 , 26 , 33 , 1 , 41 , 9 , 49 , 17 , 57 , 25 };
73
+ static final int [] IP_INVERSE = {40 , 8 , 48 , 16 , 56 , 24 , 64 , 32 , 39 , 7 , 47 , 15 , 55 , 23 , 63 , 31 , 38 , 6 , 46 , 14 , 54 , 22 , 62 , 30 , 37 , 5 , 45 , 13 , 53 , 21 , 61 , 29 , 36 , 4 , 44 , 12 , 52 , 20 , 60 , 28 , 35 , 3 , 43 , 11 , 51 , 19 , 59 , 27 , 34 , 2 , 42 , 10 , 50 , 18 , 58 , 26 , 33 , 1 , 41 , 9 , 49 , 17 , 57 , 25 };
74
74
75
75
private String [] getSubkeys (String originalKey ) {
76
76
StringBuilder permutedKey = new StringBuilder (); // Initial permutation of keys via pc1
@@ -153,7 +153,7 @@ private String feistel(String messageBlock, String key) {
153
153
154
154
StringBuilder permutedString = new StringBuilder ();
155
155
for (i = 0 ; i < 32 ; i ++) {
156
- permutedString .append (substitutedString .charAt (permutation [i ] - 1 ));
156
+ permutedString .append (substitutedString .charAt (PERMUTATION [i ] - 1 ));
157
157
}
158
158
159
159
return permutedString .toString ();
@@ -178,7 +178,7 @@ private String encryptBlock(String message, String[] keys) {
178
178
String combinedBlock = R0 + L0 ; // Reverse the 16th block
179
179
permutedMessage .setLength (0 );
180
180
for (i = 0 ; i < 64 ; i ++) {
181
- permutedMessage .append (combinedBlock .charAt (ipInverse [i ] - 1 ));
181
+ permutedMessage .append (combinedBlock .charAt (IP_INVERSE [i ] - 1 ));
182
182
}
183
183
return permutedMessage .toString ();
184
184
}
0 commit comments