diff --git a/Crypto/src/ROT13.java b/Crypto/src/ROT13.java index 1c58731..900ec27 100644 --- a/Crypto/src/ROT13.java +++ b/Crypto/src/ROT13.java @@ -1,32 +1,95 @@ + import static java.lang.Character.isLowerCase; import static java.lang.Character.isUpperCase; import static java.lang.Character.toLowerCase; -public class ROT13 { +import java.io.*; + + + +public class ROT13 { + + private int shift; - ROT13(Character cs, Character cf) { + + 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 ""; + + + + + public String crypt(String text) throws UnsupportedOperationException { + return decrypt(encrypt(text)); } public String encrypt(String text) { - return text; - } + return shiftString(text, (char) (97 + shift)); + + + + } + + 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..03e187b 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,26 @@ com.zipcodewilmington SimpleCrypt 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 7 + 7 + + + + + + + junit + junit + 4.12 + test + + diff --git a/target/sonnet18.enc b/target/sonnet18.enc new file mode 100644 index 0000000..e69de29 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 0000000..2983af7 Binary files /dev/null and b/target/test-classes/META-INF/SimpleCrypt.kotlin_module differ