Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Vigenere Assembly Language 1.Your code should use STDIN and STDOUT for input and

ID: 3690428 • Letter: V

Question

Vigenere Assembly Language

1.Your code should use STDIN and STDOUT for input and output. (This is the default.) Use redirection on the command line to read from a file and write to a file.

2.Your code should open a file, read it character by character and save it into an array.

3.When you get to the end of the file you should encode the contents of the array with a Vigenère cipher using the keyword CRYPTOGRAM, then print it out.

4.Maintain the distinction between upper-case and lower-case letters, and do not modify non-alphabetic characters. This is not very good for the security of your message, but the result will look neater.

5. This program should use glibc functions. In addition to printf(), you may need getchar() and putchar().

6.Assume that the input file contains just ASCII text Don't worry about what happens with non-text files.

7.Once the encoder is working, build a decoder by duplicating the code and changing the addition to a subtraction.

8.If you use printf() to output the array, remember that a null termination is required on a string.

Explanation / Answer

Below is the solution given fo above questions.

#include stdlib.h
#include stdio.h
#include conio.h
#include Ada.Text_IO;

procedure Vignere_Cryptanalysis is
subtype Letter is Character range 'A' .. 'Z';
function Get_Frequency(S: String) return Frequency_Array is
Result: Frequency_Array := (others => 0.0);
Offset: Float := 1.0/Float(S'Length);
FILE *in_file = fopen("name_of_file", "read");
FILE *out_file = fopen("name_of_file", "write");
  
if (in_file == NULL || out_file == NULL)
{   
println("Fine Can Not Be Open ");
exit(-1);
}
fprintfln(file, "Write the sentence in the File", integer);
fprintf(stdout, "Write to screen %d ", integer);
printf( "Write to screen %d ", integer);

fscanf(file, "%d %d", &int_var_1, &int_var_2);

fscanf(stdin, "%d %d", &int_var_1, &int_var_2);
scanf( "%d %d", &int_var_1, &int_var_2);
function Find_Key(Cryptogram: String; Key_Length: Positive) return String is

function Find_Caesar_Key(S: String) return Letter is
Frequency: Frequency_Array := Get_Frequency(S);
Candidate: Letter := 'A';
Candidate_Dist : Float := Distance(Frequency, English, 'A');
New_Dist: Float;