|
@@ -1,27 +1,59 @@
|
|
1
|
+package src;
|
|
2
|
+
|
1
|
3
|
import static java.lang.Character.isLowerCase;
|
2
|
4
|
import static java.lang.Character.isUpperCase;
|
3
|
5
|
import static java.lang.Character.toLowerCase;
|
4
|
6
|
|
5
|
7
|
public class ROT13 {
|
6
|
8
|
|
7
|
|
- ROT13(Character cs, Character cf) {
|
|
9
|
+ int elementa;
|
|
10
|
+ public String crypt(String str)
|
|
11
|
+ {
|
|
12
|
+ String str1="";
|
|
13
|
+ for (int i = 0; i < str.length(); i++)
|
|
14
|
+ {
|
|
15
|
+ char ch = str.charAt(i);
|
|
16
|
+ if (ch >= 'A' && ch <= 'Z')
|
|
17
|
+ {
|
|
18
|
+ ch = (char) (ch + elementa);
|
|
19
|
+ if (ch > 'Z')
|
|
20
|
+ {
|
|
21
|
+ ch = (char)(ch - 26);
|
|
22
|
+ }
|
|
23
|
+ }
|
|
24
|
+ else if (ch >= 'a' && ch <= 'z')
|
|
25
|
+ {
|
|
26
|
+ ch = (char)(ch + elementa);
|
|
27
|
+ if (ch > 'z')
|
|
28
|
+ {
|
|
29
|
+ ch = (char)(ch - 26);
|
|
30
|
+ }
|
|
31
|
+ }
|
|
32
|
+ str1 = str1 + ch;
|
|
33
|
+ }
|
|
34
|
+ return str1;
|
8
|
35
|
}
|
9
|
36
|
|
10
|
|
- ROT13() {
|
11
|
|
- }
|
12
|
37
|
|
13
|
38
|
|
14
|
|
- public String crypt(String text) throws UnsupportedOperationException {
|
|
39
|
+ public ROT13(Character cs, Character cf) {
|
|
40
|
+ elementa = cf - cs;
|
15
|
41
|
|
16
|
|
- return "";
|
17
|
42
|
}
|
18
|
43
|
|
|
44
|
+ public ROT13() {
|
|
45
|
+ elementa=0;
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
19
|
50
|
public String encrypt(String text) {
|
20
|
|
- return text;
|
|
51
|
+ return crypt(text);
|
|
52
|
+
|
21
|
53
|
}
|
22
|
54
|
|
23
|
55
|
public String decrypt(String text) {
|
24
|
|
- return text;
|
|
56
|
+ return crypt(text);
|
25
|
57
|
}
|
26
|
58
|
|
27
|
59
|
public static String rotate(String s, Character c) {
|