Recall that a text file is just a sequence of bytes on disk

Recall that a text file is just a sequence of bytes on disk, each of which represents an ASCII code. Unlike BMPs, text files do not have a \"header.\" Suppose, though, that a file format for password-protected text files which doesn\'t actually exist) prescribes that any such file begin with a FILEHEADER, inside of which is an 8- character password with no trailing e, per the below. typedef struct char password[81: FILEHEADER; Immediately following that header is the file\'s actual text (i.e., ASCII codes), much like RGBTRIPLE s follow a BMP\'s BITMAPFILEHEADER and BITMAPINFOHEADER. Programs that support this file format should only display a file\'s text if a user first inputs the correct password Were Problem Set 5\'s ralph.txt password-protected with a password of, say, 12345678, it would be stored in this format per the below. 12345678when I grow up, I want to be a principal or a caterpillar. I love you Principal Skinner! -Ralph Wiggum

Solution

1) Text file format is less secure than other format like bmp,jpg etc because text file format does not contain any headers.They are just the plain text file with no file structure in it like bmp, jpg etc have .

For example : like bmp have fixed file format stucture or headers, their is specific work and size of these headers.

Name of few header in bmp file are:Extra bit masks, Bitmap file header, DIB header , Color table.... etc .

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

2).

#include<stdio.h>
#include<stdlib.h>
typedef struct{
char password[8];
}FILEHEADER;

int main (int args,char * argv[])
{ FILE *f1,*f2;
int i;
char *temp ,*ch;
f1 = fopen(argv[1],\"r\");
f2 = fopen(argv[2],\"w\");
i=fseek(f1,8,SEEK_SET);
if ( i ==0)
printf(\"pointer sucessfull placed\");

printf(\"%d\",args);
while (1)
{ ch=(char*)malloc(80*sizeof(char));
temp =fgets(ch,80,f1);
if(temp==NULL)
break;
fputs(ch,f2);
free(ch);

}
free(ch);

return 0;
}

 Recall that a text file is just a sequence of bytes on disk, each of which represents an ASCII code. Unlike BMPs, text files do not have a \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site