From 2bc9e6b4357af01a97160c48c9a47b5eaf6db266 Mon Sep 17 00:00:00 2001 From: Berken Keni Date: Fri, 26 Sep 2025 16:26:48 +0300 Subject: [PATCH] Add files via upload --- Cipher.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Cipher.java b/Cipher.java index 7527c5b..ef9669a 100644 --- a/Cipher.java +++ b/Cipher.java @@ -15,7 +15,12 @@ public String encrypt(String inputString) { // for all chars in the input string for (int i = 0; i < inputString.length(); i++) { - + char c = inputString.charAt(i); + // takes the current char + c = replaceChar(c,true); + // replaces it using the replaceChar method + outputString += c; + // adds the char to the output string } return outputString; @@ -26,7 +31,16 @@ 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++) + { + char c = inputString.charAt(i); + // takes the current char + c = replaceChar(c,false); + // replaces it using the replaceChar method + outputString += c; + // adds the char to the output string + } + return outputString; } @@ -42,7 +56,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); } } }