File tree 1 file changed +2
-2
lines changed
src/main/java/com/thealgorithms/ciphers
1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ public String encrypt(String plaintext, String keyword) {
25
25
char plainChar = plaintext .charAt (i );
26
26
char keyChar = extendedKey .charAt (i );
27
27
28
- int encryptedChar = (( plainChar - 'A' ) + ( keyChar - 'A' ) ) % 26 + 'A' ;
28
+ int encryptedChar = (plainChar - 'A' + keyChar - 'A' ) % 26 + 'A' ;
29
29
ciphertext .append ((char ) encryptedChar );
30
30
}
31
31
@@ -44,7 +44,7 @@ public String decrypt(String ciphertext, String keyword) {
44
44
char cipherChar = ciphertext .charAt (i );
45
45
char keyChar = extendedKey .charAt (i );
46
46
47
- int decryptedChar = (( cipherChar - 'A' ) - ( keyChar - 'A' ) + 26 ) % 26 + 'A' ;
47
+ int decryptedChar = (cipherChar - 'A' - keyChar - 'A' + 26 ) % 26 + 'A' ;
48
48
plaintext .append ((char ) decryptedChar );
49
49
50
50
extendedKey .append ((char ) decryptedChar ); // Extend key with each decrypted char
You can’t perform that action at this time.
0 commit comments