@@ -74,13 +74,15 @@ public void setKey(String key) {
74
74
75
75
private String [] getSubkeys (String originalKey ) {
76
76
StringBuilder permutedKey = new StringBuilder (); // Initial permutation of keys via pc1
77
- int i , j ;
77
+ int i ;
78
+ int j ;
78
79
for (i = 0 ; i < 56 ; i ++) {
79
80
permutedKey .append (originalKey .charAt (PC1 [i ] - 1 ));
80
81
}
81
82
String [] subKeys = new String [16 ];
82
83
String initialPermutedKey = permutedKey .toString ();
83
- String C0 = initialPermutedKey .substring (0 , 28 ), D0 = initialPermutedKey .substring (28 );
84
+ String C0 = initialPermutedKey .substring (0 , 28 );
85
+ String D0 = initialPermutedKey .substring (28 );
84
86
85
87
// We will now operate on the left and right halves of the permutedKey
86
88
for (i = 0 ; i < 16 ; i ++) {
@@ -105,7 +107,8 @@ private String[] getSubkeys(String originalKey) {
105
107
}
106
108
107
109
private String XOR (String a , String b ) {
108
- int i , l = a .length ();
110
+ int i ;
111
+ int l = a .length ();
109
112
StringBuilder xor = new StringBuilder ();
110
113
for (i = 0 ; i < l ; i ++) {
111
114
int firstBit = a .charAt (i ) - 48 ; // 48 is '0' in ascii
@@ -116,7 +119,8 @@ private String XOR(String a, String b) {
116
119
}
117
120
118
121
private String createPaddedString (String s , int desiredLength , char pad ) {
119
- int i , l = s .length ();
122
+ int i ;
123
+ int l = s .length ();
120
124
StringBuilder paddedString = new StringBuilder ();
121
125
int diff = desiredLength - l ;
122
126
for (i = 0 ; i < diff ; i ++) {
@@ -165,7 +169,8 @@ private String encryptBlock(String message, String[] keys) {
165
169
for (i = 0 ; i < 64 ; i ++) {
166
170
permutedMessage .append (message .charAt (IP [i ] - 1 ));
167
171
}
168
- String L0 = permutedMessage .substring (0 , 32 ), R0 = permutedMessage .substring (32 );
172
+ String L0 = permutedMessage .substring (0 , 32 );
173
+ String R0 = permutedMessage .substring (32 );
169
174
170
175
// Iterate 16 times
171
176
for (i = 0 ; i < 16 ; i ++) {
@@ -198,7 +203,9 @@ private String decryptBlock(String message, String[] keys) {
198
203
*/
199
204
public String encrypt (String message ) {
200
205
StringBuilder encryptedMessage = new StringBuilder ();
201
- int l = message .length (), i , j ;
206
+ int l = message .length ();
207
+ int i ;
208
+ int j ;
202
209
if (l % 8 != 0 ) {
203
210
int desiredLength = (l / 8 + 1 ) * 8 ;
204
211
l = desiredLength ;
@@ -223,7 +230,9 @@ public String encrypt(String message) {
223
230
*/
224
231
public String decrypt (String message ) {
225
232
StringBuilder decryptedMessage = new StringBuilder ();
226
- int l = message .length (), i , j ;
233
+ int l = message .length ();
234
+ int i ;
235
+ int j ;
227
236
if (l % 64 != 0 ) {
228
237
throw new IllegalArgumentException ("Encrypted message should be a multiple of 64 characters in length" );
229
238
}
0 commit comments