I started this course in 2015 and it is great. It is taking a while to work through it and loving the challenge.
For Recover in pset 4, my code works for finding and matching the first 3 static bytes of a JPEG.
The 4th byte in the signature of a JPEG is however a bit more dynamic. The problem states the first 4 bits are 1110 and the remaining 4 bits can have many options.
I'm hitting a wall on finding the functions and syntax in C that will just look at the first 4 bits in the 4th byte and see if they match the pattern of 1110.
The pseudo code for what I want to do is:
1) After finding the 3 JPG static bytes, take the 4th byte.
2) Does the 4th byte = 00e*? * being a wildcard. I have no idea if that is possible in C but that is my thought process.
Or
2) convert the 4th byte to binary string
3) somehow compare "1110" to the first bits of the binary string.
The reason I'm doing this is because if I don't validate the 4th byte, I'm guessing it is possible to create a "false positive" JPG file.
Plus, I'm just kind of curious how this is possible!
If I don't need to worry about the 4th byte to complete this problem, someone please let me know :)