This code used to encrypt a homework file, using a pseudo-random number generato
ID: 3736618 • Letter: T
Question
This code used to encrypt a homework file, using a pseudo-random number generator (The Linear Congruence rand() Function in C), and I couldn't figure out a way to know the seed, I know that the plaintext of the file is propably started with documentclass[12pt]{article}, and the encrypted file was created on 21/3/2018, 8:31:47 PM
standard #de fine RAND MAX 32767 static unsigned long int next1; int rand (voidRAND MAX assumed to be 32767 next = next * 1103515245 + 12345; return (unsigned int) (next/65536) % 32768; void srand (unsigned int seed) next seed ; include include //Return a byte at a time of the rand () keystream char randchar) static int key: static int i-0 if (i-0) key rand ( ); return ((char ) (&key; [i++ int main (int argc, const char argv) static char randstate [64] srand (time (NULL)) FILE *input, *output; inputfopen ("Homeworklb.tex", "r") output = fopen ("Homework!b.tex.enc", int c,rc; while ((c fgetc (input))!-EOF) rc=randchar () ; printf ("c %d (tc) and rc-%d ", c, c, rc) ; fputc (chrc,output) fclose (input) fclose (output)Explanation / Answer
by following program you can get the seed value by changing the date and time of the struct tm to encrypted file created date and time : ------------>>>>>>>>>>
#include<stdio.h>
#include<time.h>
int main(){
struct tm *t = (struct tm *)malloc(sizeof(struct tm));
//here you can change the encrypted file created date and you will get the seed value
t->tm_hour = 20;
t->tm_min = 31;
t->tm_sec = 47;
t->tm_year = 2018;
t->tm_mday = 21;
t->tm_mon = 3;
time_t ts = mktime(t);
printf("seed value : %d",(unsigned int)time(&ts));
}