Question: The star hash ( Subsets 1 , 2 , 3 ) It should also check the star magic number ( first byte ) of each
The star hash Subsets It should also check the star magic number first byte of each star, and emit an error if it is incorrect.
HINT:
spacemain.c calls the function checkgalaxy in space.c when the C option is specified on the
command line.
Add code to checkgalaxy in space.c
Call galaxyhash to calculate hash values.
Think carefully about the functions you can construct to avoid repeated code.
For example, for every byte you read with fgetc you need to call galaxyhash to calculate a new hash
value, so write a function that does both. Hint: have the function take a pointer to a hash value which it can
update.
Each star ends with a hash sometimes referred to as a digest which calculated from the other values of the star.
This allows us to detect if any bytes of the galaxy have changed, for example by disk or network errors.
The galaxyhash function makes one step of computation of the hash of a sequence of bytes:
Given the hash value of the sequence up to this byte, and the value of this byte it calculates the new halue
If we create a galaxy of a single onebyte file, like this:
We can then inspect the galaxy, and see its hash is
Here's the sequence of calls that calculated that value:
void checkgalaxychar galaxypathname
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
