From 97c4bd8a2ebedcff1a720cbab769f31f72e62485 Mon Sep 17 00:00:00 2001 From: vaidehi4321 <56602405+vaidehi4321@users.noreply.github.com> Date: Fri, 15 Nov 2019 17:46:08 -0500 Subject: [PATCH 1/2] file not done --- Crypto/src/ROT13.java | 82 +++++++++++++++--- Crypto/src/ROT13Test.java | 3 + SimpleCrypt.iml | 15 ++++ pom.xml | 8 ++ .../META-INF/SimpleCrypt.kotlin_module | Bin 0 -> 16 bytes 5 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 SimpleCrypt.iml create mode 100644 target/test-classes/META-INF/SimpleCrypt.kotlin_module diff --git a/Crypto/src/ROT13.java b/Crypto/src/ROT13.java index 1c58731..9080479 100644 --- a/Crypto/src/ROT13.java +++ b/Crypto/src/ROT13.java @@ -1,32 +1,90 @@ + import static java.lang.Character.isLowerCase; import static java.lang.Character.isUpperCase; import static java.lang.Character.toLowerCase; +import java.io.File; +import java.io.FileInputStream; + + +public class ROT13 { + + private int shift; -public class ROT13 { ROT13(Character cs, Character cf) { + + shift=cf-cs; } ROT13() { +shift=0; } + //lets read a file ,encode it and write in + - public String crypt(String text) throws UnsupportedOperationException { + - return ""; + private void writeFile(String input, String s) { + } - public String encrypt(String text) { - return text; - } - public String decrypt(String text) { - return text; + public String crypt(String text) throws UnsupportedOperationException { + return decrypt(encrypt(text)); } - public static String rotate(String s, Character c) { + public String encrypt(String text) { + return shiftString(text, (char) (97 + shift)); - return ""; - } -} + + } + + public String decrypt (String text){ + return shiftString(text, (char) (97 + 26 - shift)); + + } + public String shiftString(String text,Character c) { + int shift; + if (c >= 97 && c <= 122) { + shift = c - 97; + } else { + shift = c - 65; + } + + StringBuffer result = new StringBuffer(); + char[] charArr = text.toCharArray(); + for (int i = 0; i < charArr.length; i++) { + if (charArr[i] <= 90 && charArr[i] >= 65) { + charArr[i] = (char) ((charArr[i] + shift - 65) % 26 + 65); + + + } + if (charArr[i] <= 122 && charArr[i] >= 97) { + charArr[i] = (char) ((charArr[i] + shift - 97) % 26 + 97); + + + } + + } + + return String.valueOf(charArr); + } + + public static String rotate (String s, Character c){ + String str=""; + int l=s.indexOf(c); + for(int i=l; i + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4021c2d..e3815ca 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,14 @@ com.zipcodewilmington SimpleCrypt 1.0-SNAPSHOT + + + junit + junit + 4.12 + test + + diff --git a/target/test-classes/META-INF/SimpleCrypt.kotlin_module b/target/test-classes/META-INF/SimpleCrypt.kotlin_module new file mode 100644 index 0000000000000000000000000000000000000000..2983af70661ad375cc499ebc4da5a68ca46c532e GIT binary patch literal 16 RcmZQzU|?ooU|@t|egFVe02KfL literal 0 HcmV?d00001 From f4c7c3e45f359c43c0b4dac1cfdc5e8bb34becc1 Mon Sep 17 00:00:00 2001 From: vaidehi4321 <56602405+vaidehi4321@users.noreply.github.com> Date: Mon, 18 Nov 2019 08:30:12 -0500 Subject: [PATCH 2/2] crypt done --- Crypto/src/ROT13.java | 25 +++++++++++++++---------- SimpleCrypt.iml | 2 +- pom.xml | 12 ++++++++++++ target/sonnet18.enc | 0 4 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 target/sonnet18.enc diff --git a/Crypto/src/ROT13.java b/Crypto/src/ROT13.java index 9080479..900ec27 100644 --- a/Crypto/src/ROT13.java +++ b/Crypto/src/ROT13.java @@ -2,8 +2,9 @@ import static java.lang.Character.isLowerCase; import static java.lang.Character.isUpperCase; import static java.lang.Character.toLowerCase; -import java.io.File; -import java.io.FileInputStream; + +import java.io.*; + public class ROT13 { @@ -11,7 +12,7 @@ public class ROT13 { private int shift; - ROT13(Character cs, Character cf) { + ROT13(Character cs, Character cf) { shift=cf-cs; } @@ -19,15 +20,13 @@ public class ROT13 { ROT13() { shift=0; } - //lets read a file ,encode it and write in + //lets read a file ,encode it and write in + + + - - - private void writeFile(String input, String s) { - - } public String crypt(String text) throws UnsupportedOperationException { @@ -87,4 +86,10 @@ public static String rotate (String s, Character c){ } - } + + + + + + + } diff --git a/SimpleCrypt.iml b/SimpleCrypt.iml index ff637c1..9964384 100644 --- a/SimpleCrypt.iml +++ b/SimpleCrypt.iml @@ -1,6 +1,6 @@ - + diff --git a/pom.xml b/pom.xml index e3815ca..03e187b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,18 @@ com.zipcodewilmington SimpleCrypt 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 7 + 7 + + + + junit diff --git a/target/sonnet18.enc b/target/sonnet18.enc new file mode 100644 index 0000000..e69de29