From dce5965c0bbb4964b97adde3ce406f29da2583a5 Mon Sep 17 00:00:00 2001 From: Ahmet Guneyli Date: Wed, 25 Sep 2024 16:22:36 +0300 Subject: [PATCH] correct the cipher class --- Cipher.class | Bin 0 -> 1390 bytes Cipher.java | 14 ++++++++++---- CipherTest.class | Bin 0 -> 1234 bytes 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 Cipher.class create mode 100644 CipherTest.class diff --git a/Cipher.class b/Cipher.class new file mode 100644 index 0000000000000000000000000000000000000000..5bb1dc84d070be39ec0babde736837c6034ac76f GIT binary patch literal 1390 zcma)6TTc@~6#k|cww5Yb6y;Ki3fLC3DtM!Yq-;PMTP2iWq7ORV4(-xqciG*7_1Pbx zZ^jp2c+eM2eDDYOH}qE+yqw*ZP(q`o>CBmPzH|A`oSm<~K7Rp_#l0|m@Jk3p5JVS4 z?*`xIX^rcZ^rO;-P#lJ?d#bKFa}54OaxH`q1H$y{mJo^HBu*W1Dms>`SI9{ddc~=F zPB|Ce8^LKr$)HrZm8GzOL@p_ZaRz54^har`W-Ig#lt_YdH48er_Bq>L! z;K2xnFwAgnlh=f7=n8ipt4@_9+u^!nGh9yO4=FUO$;ip$x)4Sf26;&-i}gxX-Kc4s zx?yfvwo~8UdC_n|ErtEO%5)VW?~&+$;#EYLx8|(hNSv zdb)5uj2oDiFyr?ACd1fae^q_ksEKs5&CTmr@L?wPA`5@TYC~=Fn!^JJSjwb4@F%j>s@Xa=I=oS>v`XYzcQ5#*cC8RH}qo zhLOKRX^5M=aDisqM>Ffg0Ld4@aLGHx=sebTjw3)e`ub=cCq#^P`o<7UeFFPP0$o0> zuGtMnBaQ^EF7!FM256s%N(KL1Y;q4L-eGVmH5uDOPhbyypD7m#ul(%&@9$F|JbyP< zKcxeGyMFZ2+J_O^$4HwbZ3Mob2ucXEAEakU{a-f!zp@Qewm4)*nNACaTgSCfjpB3^58Ad&@Kh^dF@Qm zn*^jO#WnQMfDd3Aqa-JB2Q!$(95PrS`2jtWZd>{w?b8D}@B=~LKA0yEqe(B|6t2)7 VqROw)|0-_LDNNFB+@&xBe*h=}KM?=` literal 0 HcmV?d00001 diff --git a/Cipher.java b/Cipher.java index 7527c5b..9ac91f4 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 v = 0; v < inputString.length(); v++) + { + // append the encrypted version of the char to the output string + outputString += replaceChar(inputString.charAt(v), 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); } } } diff --git a/CipherTest.class b/CipherTest.class new file mode 100644 index 0000000000000000000000000000000000000000..2e123530daa63ed763f2adafa0e8e11d7273fa9f GIT binary patch literal 1234 zcmaJ>>rN9v6#j-5wv^REk*k7(7UWW>_e+Z?R8bQyCT%drUrTq=op!sk?oQFZhd+D` z{Q(IkK7bEpJlk>&#NA}}%s1zJ=Q}fJ_RrtL-vCxoOri@h1921G=waxuS$kH_wY+L> zd$%SknxSV|dQz`2#AfGq3?v9CO5YJd5(Z)k^f63mM}|CfRMWNjuHeF}1T9|+n|tcZ zROENX#8spijH4xnnc0ogTqPYyuUeS92t~mICerO-TeNw5aScNThE0rM^ql5WE7YPv zQdN_b4|V9I%DpFgO-Y2+D5RcWvQto7bgmaoZgrfQ%Z+Au>4J- z9c70J+$VH9kX7kfE-#C(I?q`G4;cntpY*^9{FvZZog<{yID%6>c$&mB z+ts-i=UVlMqG-8pNorAGFyDEe2#T&1h9WfZf?@hXO_xbEu*xv`e^7rJn`%B|I%_iu}=-WMi0QQ3nh6Ng<<;b-cSuBzrxqd^8aG?AP#>WHnZlsf&3)y{` zTMLW(=+DQ0VlaD%F<>7z$X-0etz&yEeu&%0lYL~;Gx=_ESs3f4NOC{TyoA1X{siUj zqjvx%M(Kx;K?--#kLQFG=~BPJ5K0&(O-pU1Ia&qbF+3r?_uAuw_V|cmfFz+Sc!@QP F{R7B^HHQEI literal 0 HcmV?d00001