tags:

views:

46

answers:

1

Is it possible to "continue" a hash in PHP? Say for example I start hashing a large chuck of data like this:

$ctx = hash_init('sha1');
hash_update($ctx, $data_block);
$hash = hash_final($ctx);

That's all well and good but suppose the data is not fully available at that point and I want to "pause" the hashing mid-way and save where we're up to and then finish processing later. Is this possible?

Thanks, J

A: 

Not really, no. Why not just wait to call hash_final until you've received all the data?

Eric Petroelje
Because the data may come at a much later time, long after the request has died. Looks like I might have to write an extension to handle it then.
@user - Best way to handle this then might be to write the data to a file and compute the hash when you are sure that all the data has arrived.
Eric Petroelje