<mosaic.cnfolio.com>
PROGRAM
  1. //
  2.  /*START
  3.                                      declare variables
  4.                                      
  5. char imperm[256];char cipherkey [16];char plaintext [256];int lengthofplain; int lengthofcypherkey;
  6.  
  7.                                   Variable i,j,n,m
  8.  
  9.  
  10.  
  11.       DISPLAY CIPHER KEY
  12.       IF LENGTH CHARACTER OF LENGTH OF CIPHER KEY IS BETWEEN 2 AND 16
  13.       OUTPUT SHOWS CIPHER KEY
  14.      
  15.       IF ELSE IT DOES NOT SHOW BETWEEN 2 AND 16 DISPLAY
  16.       OUTPUT ERROR
  17.      
  18.       IF CIPHER KEY AS THE SAME CHARACTER AS LENGTH OF CIPHER KEY
  19.       OUTPUT WILL SHOW LENGTH OF CIPHEER KEY
  20.      
  21.       FOR LOOP
  22.      
  23.       IF LENGTH OF PLAINTEXT = STEP 1 SUBSTITUTE KEY TEXT WITH KEY TEXT
  24.       OUTPUT DISPLAY STEP 1 SUBSTITUTE KEY TEXT WITH KEY TEXT
  25.      
  26.       END LOOP
  27.       IF LENGTH CHARACTER OF LENGTH OF CIPHER KEY IS BETWEEN 2 AND 16
  28.       OUTPUT SHOWS NUMBER 
  29.      
  30.       END
  31.  
  32.       IF LENGTHOFPLAIN AS THE SAME CHARACTER AS LENGTH OF CIPHER KEY
  33.       OUTPUT WILL SHOW LENGTH OF CIPHEER KEY
  34.          
  35.       END   
  36.  
  37.      
  38.  
  39.  
  40.  
  41.  
  42. */
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. #include<stdio.h>
  51. #include<string.h>
  52. #include<stdlib.h>
  53.  
  54. //declaring varibles
  55. int main(void)
  56. {
  57. char imperm[256];
  58. char cipherkey [16];
  59. char plaintext [256];
  60. int lengthofplain;
  61. int lengthofcypherkey;
  62. int i;
  63. int j;
  64. int n;
  65. int m;
  66.  
  67. //Length of cypher key
  68. scanf("%d",&lengthofcypherkey);
  69. printf("%d",lengthofcypherkey);
  70.  
  71.  
  72. //Cipher key text
  73. scanf(" %[^\n]s", cipherkey);
  74. printf("\n%s",cipherkey);
  75.  
  76.  
  77. //length of plain
  78. scanf("%d",&lengthofplain);
  79. printf("\n%d",lengthofplain);
  80.  
  81.  
  82. //plaintext
  83. scanf(" %[^\n]s", plaintext);
  84. printf("\n%s",plaintext);
  85.  
  86. strcpy(imperm,plaintext);
  87. m=strlen(cipherkey);
  88.  
  89. for(n=0; n<strlen(plaintext); n++){
  90. if(imperm [0] == cipherkey [n]){
  91. plaintext[n] = cipherkey[n+1];
  92. }
  93. }
  94.  
  95. printf("\nstep 1 substitute %c with %c", cipherkey[0], cipherkey[1]);
  96. printf("\n%s",plaintext);
  97.  
  98.  
  99.  
  100.  
  101. }