#16 wtsimkins

오픈
wtsimkins wtsimkins/ZCW-SimpleCrypt0:master 에서 master 로 1 commits 를 머지하려 합니다
3개의 변경된 파일46개의 추가작업 그리고 5개의 파일을 삭제
  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 파일 보기

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

+ 29
- 5
Crypto/src/ROT13.java 파일 보기

@@ -4,6 +4,9 @@ import static java.lang.Character.toLowerCase;
4 4
 
5 5
 public class ROT13  {
6 6
 
7
+    private final String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
8
+    private final string lowercaseStart = "abcdefghijklmnopqrstuvwxyz";
9
+
7 10
     ROT13(Character cs, Character cf) {
8 11
     }
9 12
 
@@ -12,21 +15,42 @@ public class ROT13  {
12 15
 
13 16
 
14 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 31
     public String encrypt(String text) {
20
-        return text;
32
+      crypt(text);
21 33
     }
22 34
 
23 35
     public String decrypt(String text) {
24
-        return text;
36
+        crypt(text);
25 37
     }
26 38
 
27 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 파일 보기

@@ -0,0 +1,12 @@
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>