CLJ
CLJ

Reputation: 1927

Is a checksum a good way of determining if a file/string of text is the same from machine to machine?

I have heard, but I now cannot find evidence that a checksum can vary from machine to machine where the file is the same. Is that true? We are considering relying on a checksum in our application that will be calculated on many different machines, will this be reliable?

Upvotes: 0

Views: 525

Answers (2)

T.E.D.
T.E.D.

Reputation: 44804

It depends on the algorithm. If you are using a multibyte (>8 bit) checksum that uses integer (two's complement) math, then you will get different results depending on the endianness of the machine.

This is why a lot of network checksum algorithms use one's complement math instead of two's complement.

If both machines are the same OS and archtecture, you should be OK (unless your algorithm does something really weird).

Upvotes: 1

Gustav Larsson
Gustav Larsson

Reputation: 8487

Yes, as long as you make sure you are using the same checksum algorithm, it will be fine.

Upvotes: 0

Related Questions