I have a MD5 hash: 10f86782177490f2ac970b8dc4c51014
http://www.fileformat.info/tool/hash.htm?text=10f86782177490f2ac970b8dc4c51014 Result: c74e16d9
but PHP: crc32('10f86782177490f2ac970b8dc4c51014'); Result: -951183655
I don't understand!
If you want to check if two files are the same, CRC32 checksum is the way to go because it's faster than MD5. But be careful: CRC only reliably tells you if the binaries are different; it doesn't tell you if they're identical.
Returns a 32-bit Cyclic Redundancy Check (CRC32) value. Use CRC32 to find data transmission errors. You can also use CRC32 if you want to verify that data stored in a file has not been modified.
CRC32 works very well as a hash algorithm. The whole point of a CRC is to hash a stream of bytes with as few collisions as possible. That said, there are a few points to consider: CRC's are not secure.
A CRC32 is only reversible if the original string is 4 bytes or less.
It's only a matter of representation of the data :
c74e16d9
is the hexadecimal representation-951183655
is the decimal representation.
And here's a portion of code to illustrate that :
$crc = crc32('10f86782177490f2ac970b8dc4c51014');
var_dump($crc);
var_dump(dechex($crc));
It'll display :
int -951183655
string 'c74e16d9' (length=8)
Which corresponds to :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With