package unsch.efpis.cifrador;
/**
*
* @author sin_querer@hotmail.com
*/
public class DescifradorPolybios {
String tablaPolybios[][] = {
{"A", "B", "C", "D", "E"},
{"F", "G", "H", "[IJ]", "K"},
{"L", "M", "N", "O", "P"},
{"Q", "R", "S", "T", "U"},
{"V", "W", "X", "Y", "Z"}
};
public String getTextoClaroDeLetras(String textoCifrado) {
String textoClaro = "";
char primeraLetra = textoCifrado.charAt(0);
char segundaLetra = textoCifrado.charAt(1);
int indiceX = (int) primeraLetra % 5;
int indiceY = (int) segundaLetra % 5;
textoClaro = tablaPolybios[indiceX][indiceY];
return textoClaro;
}
public String getTextoClaroDeNumeros(String textoCifrado) {
String textoClaro = "";
char primeraLetra = textoCifrado.charAt(0);
char segundaLetra = textoCifrado.charAt(1);
int indiceX = (((int) primeraLetra) + 1) % 5;
int indiceY = (((int) segundaLetra) + 1) % 5;
textoClaro = tablaPolybios[indiceX][indiceY];
return textoClaro;
}
}