views:

129

answers:

2

The PHP's crc32 support string as input.And For a file , below code will work OFC.

crc32(file_get_contents("myfile.CSV"));

But if file goes huge (2 GB) it might raise out of memory Fatal error.

So any way around to find checksum of huge files ?

+1  A: 

PHP doesn't support files larger than 2GB (32bit limitation)

And more efficient way to calculate crc32 from files:

$hash = hash_file('crc32b',"myfile.CSV" );
dev-null-dweller
Oh okay you edited, Thanks for this buddy :)
Arsheep
edited once more - `crc32b` is correct hash algorithm for most cases.
dev-null-dweller
A: 

This function in the User Contributed Notes to crc32() claims to calculate the value without loading the file in full. If it works correctly, it should eliminate any memory problems.

For a file larger than 2 GB, it is however likely to stop at the same 32-bit limitation you are encountering right now.

If possible, I would invoke an external tool that can calculate the checksum for files as large as the one at hand.

Pekka
You know any external tool that will calculate crc32 ? I am on Linux( Debian Flavor.)
Arsheep
Source code for one here: http://www.csbruce.com/~csbruce/software/crc32.c
zaf
@zaf - Worked awesomely You are a **STAR**
Arsheep
Just doin' my job, Ma'am
zaf