Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package unsch.efpis.cifrador;
  2. /**
  3.  *
  4.  * @author sin_querer@hotmail.com
  5.  */
  6.  
  7. public class CifradorVigenere {
  8.  
  9.     char tablaCesar[] = {
  10.         'A', 'B', 'C', 'D', 'E',
  11.         'F', 'G', 'H', 'I', 'J',
  12.         'K', 'L', 'M', 'N', 'Ñ',
  13.         'O', 'P', 'Q', 'R', 'S',
  14.         'T', 'U', 'V', 'W', 'X',
  15.         'Y', 'Z'
  16.     };
  17.  
  18.     public char getTextoCifrado(char parTextoClaro, char parTextoClave) {
  19.         int indiceX = 0;
  20.         int indiceY = 0;
  21.  
  22.         for (int i = 0; i < tablaCesar.length; i++) {
  23.             if (parTextoClaro == tablaCesar[i]) {
  24.                 indiceX = i;
  25.                 break;
  26.             }
  27.         }
  28.  
  29.         for (int j = 0; j < tablaCesar.length; j++) {
  30.             if (parTextoClave == tablaCesar[j]) {
  31.                 indiceY = j;
  32.                 break;
  33.             }
  34.         }
  35.  
  36.         return tablaCesar[(indiceX + indiceY) % 27];
  37.     }
  38. }