Problems? Is your data what you think it is? | |
PerlMonks |
Re: Accessing individual bytes of a binary file as numerical valuesby roboticus (Chancellor) |
on Apr 24, 2019 at 12:36 UTC ( [id://1232942]=note: print w/replies, xml ) | Need Help?? |
It looks like Fletch gave you the info you need to decode the bytes and make your checksum. I wanted to mention that simply adding bytes together is a weak method of detecting file changes. If you have two bytes transposed, for example, you'll get the same checksum. Similarly, if there are extra zeroes in the section you're checksumming, that would also give you the same checksum. So if you're trying to detect accidental changes, I'd suggest you at least look at a simple CRC. If you want to detect possible malicious changes, though, you'd want something even stronger, as it's easy enough to modify a file to generate any CRC you'd like. Finally, there are modules out there that can help you. If you go to http://cpan.org and put Digest or Checksum in the search bar, you'll find various modules you could use to generate your checksum. (One I've used, for example, is Digest::MD5.) ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|