Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package unsch.efpis.cifrador;
  2.  
  3. /**
  4.  *
  5.  * @author sin_querer@hotmail.com
  6.  */
  7. public class DescifradorPolybios {
  8.  
  9.     String tablaPolybios[][] = {
  10.         {"A", "B", "C", "D", "E"},
  11.         {"F", "G", "H", "[IJ]", "K"},
  12.         {"L", "M", "N", "O", "P"},
  13.         {"Q", "R", "S", "T", "U"},
  14.         {"V", "W", "X", "Y", "Z"}
  15.     };
  16.  
  17.     public String getTextoClaroDeLetras(String textoCifrado) {
  18.         String textoClaro = "";
  19.         char primeraLetra = textoCifrado.charAt(0);
  20.         char segundaLetra = textoCifrado.charAt(1);
  21.  
  22.         int indiceX = (int) primeraLetra % 5;
  23.         int indiceY = (int) segundaLetra % 5;
  24.  
  25.         textoClaro = tablaPolybios[indiceX][indiceY];
  26.         return textoClaro;
  27.     }
  28.    
  29.     public String getTextoClaroDeNumeros(String textoCifrado) {
  30.         String textoClaro = "";
  31.         char primeraLetra = textoCifrado.charAt(0);
  32.         char segundaLetra = textoCifrado.charAt(1);
  33.  
  34.         int indiceX = (((int) primeraLetra) + 1) % 5;
  35.         int indiceY = (((int) segundaLetra) + 1) % 5;
  36.  
  37.         textoClaro = tablaPolybios[indiceX][indiceY];
  38.         return textoClaro;
  39.     }    
  40. }