15
15
*/
16
16
public class ADFGVXCipher {
17
17
18
- private static final char [] POLYBIUS_LETTERS = {'A' , 'D' , 'F' , 'G' , 'V' , 'X' };
19
- private static final char [][] POLYBIUS_SQUARE = {{'P ' , 'H ' , '0 ' , 'Q ' , 'G ' , '6 ' }, {'4 ' , 'M ' , 'E ' , 'A ' , '1 ' , 'Y ' }, {'L ' , '2 ' , 'N ' , 'O ' , 'F ' , 'D' }, {'X ' , 'K ' , 'R ' , '3 ' , 'C ' , 'V ' }, {'S ' , '5 ' , 'Z ' , 'W ' , '7 ' , 'B ' }, {'J ' , '9 ' , 'U ' , 'T ' , 'I ' , '8 ' }};
18
+ private static final char [] POLYBIUS_LETTERS = {'A' , 'D' , 'F' , 'G' , 'V' , 'X' };
19
+ private static final char [][] POLYBIUS_SQUARE = {{'N ' , 'A ' , '1 ' , 'C ' , '3 ' , 'H ' }, {'8 ' , 'T ' , 'B ' , '2 ' , 'O ' , 'M ' }, {'E ' , '5 ' , 'W ' , 'R ' , 'P ' , 'D' }, {'4 ' , 'F ' , '6 ' , 'G ' , '7 ' , 'I ' }, {'9 ' , 'J ' , '0 ' , 'K ' , 'L ' , 'Q ' }, {'S ' , 'U ' , 'V ' , 'X ' , 'Y ' , 'Z ' }};
20
20
private static final Map <String , Character > POLYBIUS_MAP = new HashMap <>();
21
21
private static final Map <Character , String > REVERSE_POLYBIUS_MAP = new HashMap <>();
22
22
@@ -31,7 +31,7 @@ public class ADFGVXCipher {
31
31
}
32
32
33
33
// Encrypts the plaintext using the ADFGVX cipher
34
- public String encrypt (String plaintext , String key ) {
34
+ private String encrypt (String plaintext , String key ) {
35
35
plaintext = plaintext .toUpperCase ().replaceAll ("[^A-Z0-9]" , "" );
36
36
StringBuilder fractionatedText = new StringBuilder ();
37
37
@@ -45,7 +45,7 @@ public String encrypt(String plaintext, String key) {
45
45
}
46
46
47
47
// Decrypts the ciphertext using the ADFGVX cipher
48
- public String decrypt (String ciphertext , String key ) {
48
+ private String decrypt (String ciphertext , String key ) {
49
49
// Step 1: Reverse the columnar transposition
50
50
String fractionatedText = reverseColumnarTransposition (ciphertext , key );
51
51
@@ -120,4 +120,4 @@ private String reverseColumnarTransposition(String ciphertext, String key) {
120
120
121
121
return fractionatedText .toString ();
122
122
}
123
- }
123
+ }
0 commit comments