<mosaic.cnfolio.com>
PROGRAM
  1. //_____________________________Pseudo Code_________________________//
  2.  
  3. //Start Cipher Key Program
  4.  
  5. //The Length of the Cipher (Must be within the range of 2 - 16 Integers)
  6.  
  7.  
  8. //Print the following message if the cipher length is incorrect - “Cipher length is invalid. Solution: Please try characters between 2 and 16 in length.”
  9.  
  10.  
  11. //Input the cipher key which,must be must be less than 16 and greater than 4 (lower case Characters required and integers will not be accepted)
  12.  
  13.  
  14. //Print the following message if the cipher key length is incorrect “The integers that you have inputted are invalid. Solution: Please try to enter characters between a length of 4 and 16.”
  15.  
  16.  
  17. //The plain text within the cipher must be less than 256 and greater than 4 (Lower case characters will only be accepted)
  18.  
  19.  
  20. //Print the following message if the plain text length is incorrect “The characters that you have inputted are invalid. Solution: Enter characters that range between 4 to 256 characters in length)
  21.  
  22.  
  23.  
  24. //WHILE END
  25.  
  26.  
  27. //END
  28.  
  29. //Variables For Program
  30. #include <stdio.h>
  31.  
  32. int main(void)
  33.  
  34. {
  35.  
  36. //Cipher Variables
  37. char Ckey[16]; //The cipher key
  38. char Ctext[256]; // The Ciper text
  39. int CKlength; //The Cipher keys length
  40.  
  41.  
  42. //Plain Text Variables
  43. int PTlength; // The Plain text length
  44. char PT[256]; //The Plain text
  45.  
  46.  
  47. //Other Texts Variables
  48. char Text2[256]; //The Text
  49. int Tlength; //The Text length
  50. int Tchecker = 0; //The text Checker
  51.  
  52.  
  53. //other Variables
  54. char Cchecker; //The Cipher checker
  55. int counter = 0;
  56.  
  57.  
  58. //Inputs for Program
  59. scanf("%d", &CKlength);
  60. scanf("%s", &Ckey);
  61. scanf("%d", &PTlength);
  62. scanf("%s", &PT, &Text2);
  63.  
  64.  
  65. strcpy(Text2, PT);
  66.  
  67.  
  68. for(Cchecker = 0; Cchecker < CKlength; Cchecker++)
  69.    {
  70.        counter++;
  71.       for(Tchecker = 0; Tchecker < PTlength; Tchecker++)
  72.          {
  73.                if(PT[Tchecker] == Ckey[Cchecker])
  74.                   { 
  75.                      Text2[Tchecker] = Ckey[Cchecker + 1];
  76.                   }
  77.                   
  78.          
  79.          }
  80.          
  81.          if(Cchecker == CKlength - 1)
  82.          if(Tchecker == Tlength - 1)
  83.          
  84.          {
  85.          for(Tchecker = 0; Tchecker < PTlength; Tchecker++)
  86.          {
  87.                if(PT[Tchecker] == Ckey[Cchecker])
  88.                   { 
  89.                      Text2[Tchecker] = Ckey[0];
  90.                   }
  91.                            printf("Step %d substitute %c with %c\n", counter, Ckey[Cchecker], Ckey[0]);
  92.       printf("%s\n", Text2);
  93.       return 0;
  94.          
  95.          }
  96.          }
  97.  
  98.       printf("Step %d substitute %c with %c\n", counter, Ckey[Cchecker], Ckey[Cchecker +1]);
  99.       printf("%s\n", Text2);
  100.       
  101.    }
  102.  
  103.  
  104.   }