Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package unsch.efpis.metodo;
  2.  
  3. import unsch.efpis.cifrador.CifradorCesar;
  4. import unsch.efpis.cifrador.DescifradorCesar;
  5.  
  6. /**
  7.  *
  8.  * @author sin_querer@hotmail.com
  9.  */
  10. public class CodigoCesar {
  11.     CifradorCesar cifradorCesar = new CifradorCesar();
  12.     DescifradorCesar descifradorCesar = new DescifradorCesar();
  13.    
  14.     public String encriptarTextoClaro(String textoClaro) {
  15.         String textoCifrado = "";
  16.         for(int i=0; i<textoClaro.length(); i++){
  17.             if(textoClaro.charAt(i) != ' ')
  18.                 textoCifrado += cifradorCesar.getTextoCifrado(textoClaro.charAt(i))+"";
  19.             else
  20.                 textoCifrado += " ";
  21.         }
  22.         return textoCifrado;
  23.     }    
  24.    
  25.     public String desencriptarTextoCifrado(String textoCifrado) {
  26.         String textoClaro = "";
  27.         for(int i=0; i<textoCifrado.length(); i++){
  28.             if(textoCifrado.charAt(i) != ' ')
  29.                 textoClaro += descifradorCesar.getTextoClaro(textoCifrado.charAt(i))+"";
  30.             else
  31.                 textoClaro += " ";
  32.         }
  33.         return textoClaro;
  34.     }    
  35. }