diff --git a/Crypto/src/Main/rocks/zipcode/ROT13.java b/Crypto/src/Main/rocks/zipcode/ROT13.java new file mode 100644 index 0000000..04af4cc --- /dev/null +++ b/Crypto/src/Main/rocks/zipcode/ROT13.java @@ -0,0 +1,53 @@ +package rocks.zipcode; + +import static java.lang.Character.isLowerCase; +import static java.lang.Character.isUpperCase; +import static java.lang.Character.toLowerCase; + +public class ROT13 { + private int code; + + + public ROT13(Character cs, Character cf) { + code = cf - cs; + } + + public ROT13() { + code = 0; + } + + public String crypt(String text) throws UnsupportedOperationException { + for (int i = 0; i < text.length(); i++) { + char c = text.charAt(i); + if (c >= 'a' && c <= 'm') { c += 13; + } else if (c >= 'A' && c <= 'M') { c += 13; + } else if (c >= 'n' && c <= 'z') { c -= 13; + } else if (c >= 'N' && c <= 'Z') { c -= 13; + } + } + return text; + } + + public String cryptFile() { + String sonnet = "sonnet18.txt"; + sonnet = encrypt(sonnet); + return null ; + } + + + public String encrypt(String text) { + String encrypt = crypt(text); + return encrypt; + } + + public String decrypt(String text) { + String decrypt = crypt(text); + return decrypt; + } + + public static String rotate(String s, Character c) { + Integer index = s.indexOf(c); + return s.substring(index) + s.substring(0, index); + } + +} diff --git a/Crypto/src/ROT13.java b/Crypto/src/ROT13.java deleted file mode 100644 index 1c58731..0000000 --- a/Crypto/src/ROT13.java +++ /dev/null @@ -1,32 +0,0 @@ -import static java.lang.Character.isLowerCase; -import static java.lang.Character.isUpperCase; -import static java.lang.Character.toLowerCase; - -public class ROT13 { - - ROT13(Character cs, Character cf) { - } - - ROT13() { - } - - - public String crypt(String text) throws UnsupportedOperationException { - - return ""; - } - - public String encrypt(String text) { - return text; - } - - public String decrypt(String text) { - return text; - } - - public static String rotate(String s, Character c) { - - return ""; - } - -} diff --git a/Crypto/src/ROT13Test.java b/Crypto/src/Test/rocks/zipcode/ROT13Test.java similarity index 98% rename from Crypto/src/ROT13Test.java rename to Crypto/src/Test/rocks/zipcode/ROT13Test.java index 400c38b..b0ee84c 100644 --- a/Crypto/src/ROT13Test.java +++ b/Crypto/src/Test/rocks/zipcode/ROT13Test.java @@ -1,3 +1,5 @@ +package rocks.zipcode; + import org.junit.Test; import static org.junit.Assert.*; diff --git a/SimpleCrypt.iml b/SimpleCrypt.iml new file mode 100644 index 0000000..7567450 --- /dev/null +++ b/SimpleCrypt.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ 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 + +