|
|
@@ -1,21 +1,21 @@
|
|
1
|
1
|
import java.util.ArrayList;
|
|
2
|
2
|
import java.util.List;
|
|
3
|
3
|
|
|
4
|
|
-public class Crypto {
|
|
|
4
|
+class Crypto {
|
|
5
|
5
|
|
|
6
|
6
|
private String normalizedPlaintext;
|
|
7
|
7
|
private int squareSize;
|
|
8
|
8
|
|
|
9
|
|
- public Crypto(String text) {
|
|
|
9
|
+ Crypto(String text) {
|
|
10
|
10
|
this.normalizedPlaintext = normalizeText(text);
|
|
11
|
11
|
this.squareSize = calculateSquareSize(normalizedPlaintext);
|
|
12
|
12
|
}
|
|
13
|
13
|
|
|
14
|
|
- public String getNormalizedPlaintext() {
|
|
|
14
|
+ String getNormalizedPlaintext() {
|
|
15
|
15
|
return normalizedPlaintext;
|
|
16
|
16
|
}
|
|
17
|
17
|
|
|
18
|
|
- public int getSquareSize() {
|
|
|
18
|
+ int getSquareSize() {
|
|
19
|
19
|
return squareSize;
|
|
20
|
20
|
}
|
|
21
|
21
|
|
|
|
@@ -30,7 +30,7 @@ public class Crypto {
|
|
30
|
30
|
return (int) Math.ceil(Math.sqrt(text.length()));
|
|
31
|
31
|
}
|
|
32
|
32
|
|
|
33
|
|
- public List<String> getPlaintextSegments() {
|
|
|
33
|
+ List<String> getPlaintextSegments() {
|
|
34
|
34
|
return getSegmentText(normalizedPlaintext, squareSize);
|
|
35
|
35
|
}
|
|
36
|
36
|
|
|
|
@@ -50,11 +50,11 @@ public class Crypto {
|
|
50
|
50
|
return segments;
|
|
51
|
51
|
}
|
|
52
|
52
|
|
|
53
|
|
- public String getCipherText() {
|
|
|
53
|
+ String getCipherText() {
|
|
54
|
54
|
return getNormalizedCipherText().replaceAll("\\s", "");
|
|
55
|
55
|
}
|
|
56
|
56
|
|
|
57
|
|
- public String getNormalizedCipherText() {
|
|
|
57
|
+ String getNormalizedCipherText() {
|
|
58
|
58
|
StringBuilder cipherText = new StringBuilder(normalizedPlaintext.length());
|
|
59
|
59
|
|
|
60
|
60
|
for (int index = 0; index < squareSize; index++) {
|