Rating: 1.0
```
import java.util.*;
import java.io.*;
public class Ramblings {
// Find row and column of a character in keysquare
public static int[] findrc(char[][] sub, char x)
{
for (int i = 0; i < 5; i++)
for (int j = 0; j < 5; j++)
if (sub[i][j] == x)
{
int[] nums = {i, j};
return nums;
}
return new int[0];
}
// Bifid cipher decryption algorithm hardcoded with period=5
public static String decrypt(String cipher, String key)
{
char[][] sub = new char[5][5];
for (int i = 0; i < key.length(); i++)
sub[i/5][i%5] = key.charAt(i);
ArrayList<Integer> list = new ArrayList<>();
for (int i = 0; i < cipher.length(); i++)
{
int[] rc = findrc(sub, cipher.charAt(i));
list.add(rc[0]);
list.add(rc[1]);
}
String build = "";
for (int start = 0; start < list.size(); start += 10)
for (int i = 0; i < 5; i++)
try
{
build += sub[list.get(start+i)][list.get(start+i+5)];
}
catch (Exception e) {}
return build;
}
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(new File("ramblings"));
ArrayList<String> keys = new ArrayList<>();
while (scan.hasNextLine())
{
String line = scan.nextLine();
String copy = line;
line = line.replace("." , "");
line = line.replace(" " , "");
line = line.replace("," , "");
line = line.replace("!" , "");
line = line.replace("?" , "");
line = line.replace("'" , "");
line = line.replace("-" , "");
line = line.replace("@" , "");
line = line.replace("\"" , "");
line = line.replace("+" , "");
line = line.replace(":" , "");
line = line.toLowerCase();
if (line.length() > 26)
continue;
line = line.replace("j" , "");
// System.out.println(line);
keys.add(line);
}
String msg = "snbwmuotwodwvcywfgmruotoozaiwghlabvuzmfobhtywftopmtawyhifqgtsiowetrksrzgrztkfctxnrswnhxshylyehtatssukfvsnztyzlopsv";
System.out.println(msg + "\n");
for (int i = keys.size()-1; i >= 0; i--)
msg = decrypt(msg, keys.get(i));
msg = msg.replace("x" , " ");
// Minor trivial corrections
char[] text = msg.toCharArray();
text[0] = 'j';
text[24] = 'x';
String solve = new String(text) + " way";
System.out.println(solve);
scan.close();
}
}
```