#16 wtsimkins

Open
wtsimkins wants to merge 1 commits from wtsimkins/ZCW-SimpleCrypt0:master into master
3 changed files with 46 additions and 5 deletions
  1. 5
    0
      Crypto/src/Caesar.java
  2. 29
    5
      Crypto/src/ROT13.java
  3. 12
    0
      SimpleCrypt.iml

+ 5
- 0
Crypto/src/Caesar.java View File

1
+public class Caesar extends ROT13{
2
+    public Caesar() {
3
+        super();
4
+    }
5
+}

+ 29
- 5
Crypto/src/ROT13.java View File

4
 
4
 
5
 public class ROT13  {
5
 public class ROT13  {
6
 
6
 
7
+    private final String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
8
+    private final string lowercaseStart = "abcdefghijklmnopqrstuvwxyz";
9
+
7
     ROT13(Character cs, Character cf) {
10
     ROT13(Character cs, Character cf) {
8
     }
11
     }
9
 
12
 
12
 
15
 
13
 
16
 
14
     public String crypt(String text) throws UnsupportedOperationException {
17
     public String crypt(String text) throws UnsupportedOperationException {
15
-
16
-        return "";
18
+        StringBuilder sb = new StringBuilder();
19
+        for (int i = 0; i < input.length(); i++) {
20
+            char c = text.charAt(i);
21
+            if       (c >= 'a' && c <= 'm') c += 13;
22
+            else if  (c >= 'A' && c <= 'M') c += 13;
23
+            else if  (c >= 'n' && c <= 'z') c -= 13;
24
+            else if  (c >= 'N' && c <= 'Z') c -= 13;
25
+            sb.append(c);
26
+        }
27
+        return sb.toString();
28
+    }
17
     }
29
     }
18
 
30
 
19
     public String encrypt(String text) {
31
     public String encrypt(String text) {
20
-        return text;
32
+      crypt(text);
21
     }
33
     }
22
 
34
 
23
     public String decrypt(String text) {
35
     public String decrypt(String text) {
24
-        return text;
36
+        crypt(text);
25
     }
37
     }
26
 
38
 
27
     public static String rotate(String s, Character c) {
39
     public static String rotate(String s, Character c) {
40
+        if ( Character.isLowerCase( (s) c ) )
41
+        {
42
+            return ( ( c - (int)'a' + 13 ) % 26 + (int)'a' );
43
+        }
44
+        else
45
+        if ( Character.isUpperCase( (s) c ) )
46
+        {
47
+            return ( ( c - (int)'A' + 13 ) % 26 + (int)'A' );
48
+        }
49
+        else
50
+        {
51
+            return (int)' ';
52
+        }
28
 
53
 
29
-        return "";
30
     }
54
     }
31
 
55
 
32
 }
56
 }

+ 12
- 0
SimpleCrypt.iml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
4
+    <output url="file://$MODULE_DIR$/target/classes" />
5
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
6
+    <content url="file://$MODULE_DIR$">
7
+      <excludeFolder url="file://$MODULE_DIR$/target" />
8
+    </content>
9
+    <orderEntry type="inheritedJdk" />
10
+    <orderEntry type="sourceFolder" forTests="false" />
11
+  </component>
12
+</module>