Skip to content

Commit d229d5b

Browse files
committed
Fixed syntax error and clang formatting
1 parent 6a53215 commit d229d5b

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/main/java/com/thealgorithms/ciphers/HillCipher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ private int determinant(int[][] matrix, int n) {
9090
int subJ = 0;
9191
for (int j = 0; j < n; j++) {
9292
if (j != x) {
93-
subMatrix[sub_i][sub_j++] = matrix[i][j];
93+
subMatrix[subI][subJ++] = matrix[i][j];
9494
}
9595
}
96-
sub_i++;
96+
subI++;
9797
}
9898
det += sign * matrix[0][x] * determinant(subMatrix, n - 1);
9999
sign = -sign;

src/test/java/com/thealgorithms/ciphers/HillCipherTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ class HillCipherTest {
1212
void hillCipherEncryptTest() {
1313
// given
1414
String message = "ACT"; // Plaintext message
15-
int[][] keyMatrix = {
16-
{6, 24, 1},
17-
{13, 16, 10},
18-
{20, 17, 15}
19-
}; // Encryption key matrix
15+
int[][] keyMatrix = {{6, 24, 1}, {13, 16, 10}, {20, 17, 15}}; // Encryption key matrix
2016

2117
// when
2218
String cipherText = hillCipher.encrypt(message, keyMatrix);
@@ -29,11 +25,7 @@ void hillCipherEncryptTest() {
2925
void hillCipherDecryptTest() {
3026
// given
3127
String cipherText = "POH"; // Ciphertext message
32-
int[][] inverseKeyMatrix = {
33-
{8, 5, 10},
34-
{21, 8, 21},
35-
{21, 12, 8}
36-
}; // Decryption (inverse key) matrix
28+
int[][] inverseKeyMatrix = {{8, 5, 10}, {21, 8, 21}, {21, 12, 8}}; // Decryption (inverse key) matrix
3729

3830
// when
3931
String plainText = hillCipher.decrypt(cipherText, inverseKeyMatrix);

0 commit comments

Comments
 (0)