Skip to content

Commit 82bea9f

Browse files
committed
Removed unnecessary parentheses
1 parent 5e86307 commit 82bea9f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public String encrypt(String plaintext, String keyword) {
2525
char plainChar = plaintext.charAt(i);
2626
char keyChar = extendedKey.charAt(i);
2727

28-
int encryptedChar = ((plainChar - 'A') + (keyChar - 'A')) % 26 + 'A';
28+
int encryptedChar = (plainChar - 'A' + keyChar - 'A') % 26 + 'A';
2929
ciphertext.append((char) encryptedChar);
3030
}
3131

@@ -44,7 +44,7 @@ public String decrypt(String ciphertext, String keyword) {
4444
char cipherChar = ciphertext.charAt(i);
4545
char keyChar = extendedKey.charAt(i);
4646

47-
int decryptedChar = ((cipherChar - 'A') - (keyChar - 'A') + 26) % 26 + 'A';
47+
int decryptedChar = (cipherChar - 'A' - keyChar - 'A' + 26) % 26 + 'A';
4848
plaintext.append((char) decryptedChar);
4949

5050
extendedKey.append((char) decryptedChar); // Extend key with each decrypted char

0 commit comments

Comments
 (0)