Reputation: 73
I want to compute checksum for client/server program. To do that, I am obtaining the strings inside the file and then getting the corresponding integer value for each character (ASCII value) to compute the checksum.
This is suitable for the file format that contains strings, but will this work for the image file? I can obtain the strings out of image file that are in unreadable format. Is there a ASCII value for those unreadable characters?
Upvotes: 0
Views: 617
Reputation: 150108
Ultimately every file contains binary data, bits grouped into bytes.
ASCII is a code that maps certain bit patterns to certain English language characters, as well as numbers and some symbols. It also leaves undefined bytes for which the most significant bit is set (values > 127).
The proper way to compute the checksum of a file is to examine each byte of the file as input to the algorithm. This works equally well for ASCII text files, text files with a different encoding (e.g. one of the Unicode variants), image files, or any other file.
Upvotes: 1