From f88ee4039c04bf8722ade70b611ae99b4cf033f8 Mon Sep 17 00:00:00 2001 From: Emir Date: Fri, 26 Sep 2025 20:20:26 +0300 Subject: [PATCH 1/2] Replaced random words with meaningful expressions --- Cipher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cipher.java b/Cipher.java index 7527c5b..80603f1 100644 --- a/Cipher.java +++ b/Cipher.java @@ -1,4 +1,4 @@ -// This class is used for encrypting or decrypting strings using character mapping + // This class is used for encrypting or decrypting strings using character mapping public class Cipher { // Strings for keeping the alphabets, one for the original letters and the other for the encrypted ones From d22f9173718cc1776eeef4155d8413ca6d83bdf7 Mon Sep 17 00:00:00 2001 From: Emir Date: Fri, 26 Sep 2025 20:27:28 +0300 Subject: [PATCH 2/2] Replaced random words with meaningful expressions --- Cipher.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Cipher.java b/Cipher.java index 7527c5b..022bdf7 100644 --- a/Cipher.java +++ b/Cipher.java @@ -15,7 +15,8 @@ public String encrypt(String inputString) { // for all chars in the input string for (int i = 0; i < inputString.length(); i++) { - + // append the encrypted version of the char to the output string + outputString += replaceChar(inputString.charAt(i), true); } return outputString; @@ -26,8 +27,13 @@ public String decrypt(String inputString) { // output string will be collected in this variable, one char at a time String outputString = ""; - replaceChar('a',true); - + // for all chars in the input string + for (int i = 0; i < inputString.length(); i++) + { + // append the encrypted version of the char to the output string + outputString += replaceChar(inputString.charAt(i), false); + } + return outputString; } @@ -42,7 +48,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); } } }