# crc32, md5 & sha1 functions

- Thread: https://externals.io/message/15527
- Original archive: https://news-web.php.net/php.internals/15527
- Started by Alexander Valyalkin on 2005-03-21T20:17:19+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #15527 — Alexander Valyalkin — 2005-03-21T20:17:19+00:00

URL: https://externals.io/message/15527#15527

crc32, md5 and sha1 functions, implemented in PHP, are widely used for
computing "fingerprint" of any data. But current implementation has not very
good limitation - there is no way to get/set current state vector of these
functions. So, we have to pass whole amount of data as argument of these
functions at once instead of sequently data processing.
Of course, we can use `md5_file()` or `sha1_file()` to get hash of huge amounts
of data, but there is missing crc32_file() analog.

I think, the best way is to add optional parameter to these functions, which
will allow to get/set current state vector of hash algorithms. This change
will not break backward compatibility.

---

## #15529 — Sara Golemon — 2005-03-21T23:06:54+00:00

URL: https://externals.io/message/15527#15529 · In reply to: #15527

> crc32, md5 and sha1 functions, implemented in PHP, are widely used for
> computing "fingerprint" of any data. But current implementation has not
very
> good limitation - there is no way to get/set current state vector of these
> functions. So, we have to pass whole amount of data as argument of these
> functions at once instead of sequently data processing.
> Of course, we can use `md5_file()` or `sha1_file()` to get hash of huge
amounts
> of data, but there is missing crc32_file() analog.
>
> I think, the best way is to add optional parameter to these functions,
which
> will allow to get/set current state vector of hash algorithms. This change
> will not break backward compatibility.
>
I like the concept of exposing hash contexts to userspace the way they work
in C (HASH_init(), `HASH_update()`, `HASH_final()`) but I think the more
appropriate place to put this "extended" functionality is in the mhash
extension.

-Sara
