keybase
[m6w6/m6w6.github.io] / _posts / 2005-12-06-hash-extension.md
1 ---
2 title: Hash Extension
3 author: m6w6
4 tags:
5 - PHP
6 ---
7
8 If you didn't notice yet, there's a new, seemingly unimpressive, nevertheless
9 very useful, extension on the horizon, namely
10 ext/[hash](http://pecl.php.net/package/hash).
11
12 The initial version, proposed by Sara and Stefan -and it seems that Rasmus had
13 his hands on it too- already featured the most common algorithms, and it has
14 recently been extended to support now fairly every algo which libmhash
15 provides.
16
17 There's not been any public release yet, which means you'd need to build from
18 CVS. [pecl4win](http://pecl4win.php.net) though, already provides fresh
19 modules for Windows users.
20
21 ### It's usage is simple and intuitive
22 Hashing a string:
23 ```php
24 echo hash('sha384', 'The quick brown fox jumps over the lazy dog');
25 ```
26 Hashing a file:
27 ```php
28 echo hash_file('md5', 'release-1.0.tgz');
29 ```
30 There's also an incremental interface available.
31
32 The recently released version of the [HTTP
33 extension](http://pecl.php.net/package/pecl_http) now uses the HASH extension
34 instead of libmhash for generating its etag hashes.
35
36 ## Update:
37 Just in case you missed, Sara released
38 [pecl/hash](http://pecl.php.net/package/hash) today.
39 Check it out -- It'll be bundled with PHP-5.1.2!
40