From 9a09bced681628da90c68e575b6c868ab199b680 Mon Sep 17 00:00:00 2001 From: Eren Date: Thu, 6 Feb 2025 23:27:55 +0300 Subject: [PATCH] Fixed all errors. --- .DS_Store | Bin 0 -> 6148 bytes Cipher.java | 126 +++++++++++++++++++++++++++------------------------- 2 files changed, 66 insertions(+), 60 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 original to encrypted - // if isEncrypt == false -> encrypted to original - // works only when the input char is included in our alphabet variables - // should not replace symbols or upper case letters, return input char in those cases - private char replaceChar(char inputChar, boolean isEncrypt) { - - if(isEncrypt) { - for (int i = 0; i < ORIGINAL_ALPHABET.length(); i++) - { - if(ORIGINAL_ALPHABET.charAt(i) == inputChar) { - - } - } - } - else { - for (int i = 0; i < CIPHER_ALPHABET.length(); i++) - { - if(CIPHER_ALPHABET.charAt(i) == inputChar) { - return ORIGINAL_ALPHABET.charAt(i); - } - } - } - - // if we did not find it in the alphabet, then return the original char - return inputChar; - } -} \ No newline at end of file + + // replaces the given input char based on the given isEncrypt variable + // if isEncrypt == true -> original to encrypted + // if isEncrypt == false -> encrypted to original + // works only when the input char is included in our alphabet variables + // should not replace symbols or upper case letters, return input char in those cases + private char replaceChar(char inputChar, boolean isEncrypt) { + + if(isEncrypt) { + for (int i = 0; i < ORIGINAL_ALPHABET.length(); i++) + { + if(ORIGINAL_ALPHABET.charAt(i) == inputChar) { + return CIPHER_ALPHABET.charAt(i); + } + } + } + else { + for (int i = 0; i < CIPHER_ALPHABET.length(); i++) + { + if(CIPHER_ALPHABET.charAt(i) == inputChar) { + return ORIGINAL_ALPHABET.charAt(i); + } + } + } + + // if we did not find it in the alphabet, then return the original char + return inputChar; + } +} \ No newline at end of file