Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Accessing individual bytes of a binary file as numerical values

by roboticus (Chancellor)
on Apr 24, 2019 at 12:36 UTC ( [id://1232942]=note: print w/replies, xml ) Need Help??


in reply to Accessing individual bytes of a binary file as numerical values

Chris01234:

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232942]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found