<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2.  
  3. var cipherlength
  4. var cipher
  5. var textlength
  6. var text
  7. var temp (subsitution)
  8.  
  9. INPUT cipherlength
  10. INPUT cipher
  11. INPUT textlength
  12. FOR(i = 0 to textlength;i++)
  13.   INPUT text
  14.   temp[i]=text[i]
  15. }
  16.  
  17. n=cipherlength
  18. OUTPUT (“Step” + n + “substitute” + valueTarget + “with” + valueSubstitution)
  19.  
  20. FOR(i=1; to text length;i++)
  21.    OUTPUT (valueTarget)
  22.  
  23. FOR(i=1; to text length;i++)
  24.    IF (text = cipher)
  25.    temp=cipher
  26.  
  27. OUTPUT NEW LINE
  28.  
  29. */
  30.  
  31. /*---------------------------------------------- Start of Program --------------------------------------------------------*/
  32.  
  33. #include <stdio.h>
  34.  
  35.  
  36. int main()
  37.     {
  38.     int    cipherlength = 0; //stores the length of the Cipher Key
  39.     char   cipher[16];       //stores the Cipher Encryption Key
  40.     int    textlength;       //stores the length of the input text       
  41.     char   text[256];        //stores the input text     
  42.     int    n = 0;             
  43.     int    i;           
  44.     char   substitution[256];//temp store for output text           
  45.    
  46. //Inputs
  47.  
  48.     scanf("%d", &cipherlength); //take inputed number for cipher length       
  49.    
  50.     for(i=0;i<=cipherlength;i++)     
  51.     {
  52.       scanf("%c", &cipher[i])//take inputed cipher key       
  53.     }
  54.    
  55.     scanf("%d", &textlength);   //take inputed length of encryptable text   
  56.  
  57.     for(i=0;i<=textlength;i++) 
  58.     {
  59.     scanf("%c", &text[i]);      //Take each character of the input text, character by character
  60.     substitution[i] = text[i]//hold input in temp memory
  61.     }
  62.    
  63.  
  64. //Secret Stuff
  65.  
  66.   for(n=1;n<=cipherlength;n++)      //character by character aproach until string is complete
  67.   {
  68.      if(n==cipherlength)            //run intruction when correct number of variables are met
  69.       {
  70.         for(i=1;i<=textlength;i++)
  71.          {
  72.             if(text[i]==cipher[n])
  73.             {
  74.               n=1;                   
  75.               substitution[i]=cipher[n];     //create a temp version to be edited by encryption key
  76.             }
  77.          }
  78. //Output(1)
  79.          
  80.          n=cipherlength;          //make variable equal to lenghth of cipher
  81.          printf("\nStep %d substitute %c with %c\n", n, cipher[n], cipher[1])//Output individual encryption steps
  82.            
  83.          for(i=1;i<=textlength;i++)      //Repeat output until all steps complete
  84.          {
  85.            printf("%c", substitution[i])//Output encrypted version from version one input text
  86.          }
  87.          break;
  88.       }
  89. //Duplication Prevention
  90.      
  91.       for(i=1;i<=textlength;i++)  //Repeat until all the characters in the text have been seen
  92.       {
  93.      
  94.         if(text[i]==cipher[n])      //Check if two characters are the same, if so complete task
  95.          {
  96.            substitution[i]=cipher[n+1];    //store encrypted output in temp variable
  97.          }
  98.       }
  99. //Output(2)
  100.      
  101.       printf("\nstep %d replace %c with %c\n", n, cipher[n], cipher[n+1])//Repeat output until all steps complete
  102.       {
  103.           printf("%c", substitution[i]);    //Show each step on output
  104.       }
  105.      
  106.    }
  107.   return 0; //Return main program to line 0
  108. }