From 19ae987a82c00c5801dfe8bc87004e45ff27ba53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ege=20Yi=C4=9Fit=20Y=C4=B1ld=C4=B1r=C4=B1m?= Date: Thu, 29 Jan 2026 23:15:24 +0300 Subject: [PATCH] Implement encryption and decryption methods --- Cipher.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Cipher.java b/Cipher.java index 7527c5b..2da9e23 100644 --- a/Cipher.java +++ b/Cipher.java @@ -15,7 +15,7 @@ public String encrypt(String inputString) { // for all chars in the input string for (int i = 0; i < inputString.length(); i++) { - + outputString += replaceChar(inputString.charAt(i), true); } return outputString; @@ -26,7 +26,10 @@ public String decrypt(String inputString) { // output string will be collected in this variable, one char at a time String outputString = ""; - replaceChar('a',true); + for (int i = 0; i < inputString.length(); i++) + { + outputString += replaceChar(inputString.charAt(i), false); + } return outputString; } @@ -42,7 +45,7 @@ private char replaceChar(char inputChar, boolean isEncrypt) { for (int i = 0; i < ORIGINAL_ALPHABET.length(); i++) { if(ORIGINAL_ALPHABET.charAt(i) == inputChar) { - + return CIPHER_ALPHABET.charAt(i); } } } @@ -58,4 +61,4 @@ private char replaceChar(char inputChar, boolean isEncrypt) { // if we did not find it in the alphabet, then return the original char return inputChar; } -} \ No newline at end of file +}