Index: branches/version-2_5-dev/data/module/Compat/tests/function/hash.phpt
===================================================================
--- branches/version-2_5-dev/data/module/Compat/tests/function/hash.phpt	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/tests/function/hash.phpt	(revision 19986)
@@ -0,0 +1,21 @@
+--TEST--
+Function -- hash
+--FILE--
+<?php
+require_once 'PHP/Compat/Function/hash.php';
+
+$content = "This is a sample string used to test the hash function with various hashing algorithms";
+
+echo "md5: " . php_compat_hash('md5', $content). "\n";
+echo "sha1: " . php_compat_hash('sha1', $content). "\n";
+echo "sha256: " . php_compat_hash('sha256', $content). "\n";
+echo "md5(raw): " . bin2hex(php_compat_hash('md5', $content, true)). "\n";
+echo "sha256(raw): " . bin2hex(php_compat_hash('sha256', $content, true)). "\n";
+
+?>
+--EXPECT--
+md5: bf33deeefaf5a9413160935be950cc07
+sha1: f0dc0e88cc1008e46762f40a1b4a4c0b6baedfa0
+sha256: a78149615dd1ef8aeb22a8254c36edd87713f2e79a052a89ff32ed94e827d47b
+md5(raw): bf33deeefaf5a9413160935be950cc07
+sha256(raw): a78149615dd1ef8aeb22a8254c36edd87713f2e79a052a89ff32ed94e827d47b
Index: branches/version-2_5-dev/data/module/Compat/tests/function/sha1.phpt
===================================================================
--- branches/version-2_5-dev/data/module/Compat/tests/function/sha1.phpt	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/tests/function/sha1.phpt	(revision 19986)
@@ -0,0 +1,24 @@
+--TEST--
+Function -- sha1
+--FILE--
+<?php
+require_once 'PHP/Compat/Function/sha1.php';
+
+$tests = array(
+    'abc',
+    'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq',
+    'a',
+    '0123456701234567012345670123456701234567012345670123456701234567',
+    ''
+);
+
+foreach ($tests as $test) {
+    echo php_compat_sha1($test), "\n";
+}
+?>
+--EXPECT--
+a9993e364706816aba3e25717850c26c9cd0d89d
+84983e441c3bd26ebaae4aa1f95129e5e54670f1
+86f7e437faa5a7fce15d1ddcb9eaeaea377667b8
+e0c094e867ef46c350ef54a7f59dd60bed92ae83
+da39a3ee5e6b4b0d3255bfef95601890afd80709
Index: branches/version-2_5-dev/data/module/Compat/tests/function/sha256.phpt
===================================================================
--- branches/version-2_5-dev/data/module/Compat/tests/function/sha256.phpt	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/tests/function/sha256.phpt	(revision 19986)
@@ -0,0 +1,20 @@
+--TEST--
+Function -- sha256
+--FILE--
+<?php
+require_once 'PHP/Compat/Function/_sha256.php';
+
+echo php_compat_sha256('') . "\n";
+echo php_compat_sha256('a') . "\n";
+echo php_compat_sha256('012345678901234567890123456789012345678901234567890123456789') . "\n";
+
+/* FIPS-180 Vectors */
+echo php_compat_sha256('abc') . "\n";
+echo php_compat_sha256('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq') . "\n";
+?>
+--EXPECT--
+e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb
+5e43c8704ac81f33d701c1ace046ba9f257062b4d17e78f3254cbf243177e4f2
+ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
+248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1
Index: branches/version-2_5-dev/data/module/Compat/tests/function/hash_algos.phpt
===================================================================
--- branches/version-2_5-dev/data/module/Compat/tests/function/hash_algos.phpt	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/tests/function/hash_algos.phpt	(revision 19986)
@@ -0,0 +1,17 @@
+--TEST--
+Function -- hash_algos
+--FILE--
+<?php
+require_once 'PHP/Compat/Function/hash_algos.php';
+
+var_dump(php_compat_hash_algos());
+?>
+--EXPECT--
+array(3) {
+  [0]=>
+  string(3) "md5"
+  [1]=>
+  string(4) "sha1"
+  [2]=>
+  string(6) "sha256"
+}
Index: branches/version-2_5-dev/data/module/Compat/tests/function/hash_hmac.phpt
===================================================================
--- branches/version-2_5-dev/data/module/Compat/tests/function/hash_hmac.phpt	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/tests/function/hash_hmac.phpt	(revision 19986)
@@ -0,0 +1,22 @@
+--TEST--
+Function -- hash_hmac
+--FILE--
+<?php
+require_once 'PHP/Compat/Function/hash_hmac.php';
+
+$content = "This is a sample string used to test the hash_hmac function with various hashing algorithms";
+$key = 'secret';
+
+echo "md5: " . php_compat_hash_hmac('md5', $content, $key) . "\n";
+echo "sha1: " . php_compat_hash_hmac('sha1', $content, $key) . "\n";
+echo "sha256: " . php_compat_hash_hmac('sha256', $content, $key) . "\n";
+echo "md5(raw): " . bin2hex(php_compat_hash_hmac('md5', $content, $key, true)) . "\n";
+echo "sha256(raw): " . bin2hex(php_compat_hash_hmac('sha256', $content, $key, true)) . "\n";
+
+?>
+--EXPECT--
+md5: 2a632783e2812cf23de100d7d6a463ae
+sha1: 5bfdb62b97e2c987405463e9f7c193139c0e1fd0
+sha256: 49bde3496b9510a17d0edd8a4b0ac70148e32a1d51e881ec76faa96534125838
+md5(raw): 2a632783e2812cf23de100d7d6a463ae
+sha256(raw): 49bde3496b9510a17d0edd8a4b0ac70148e32a1d51e881ec76faa96534125838
Index: branches/version-2_5-dev/data/module/Compat/Compat/Function/_sha256.php
===================================================================
--- branches/version-2_5-dev/data/module/Compat/Compat/Function/_sha256.php	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/Compat/Function/_sha256.php	(revision 19986)
@@ -0,0 +1,156 @@
+<?php
+
+/**
+ * PHP implementation of SHA-256 hash function
+ *
+ * @category    PHP
+ * @package     PHP_Compat
+ * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
+ * @copyright   2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
+ * @link        http://php.net/function.hash
+ * @author      revulo <revulon@gmail.com>
+ * @require     PHP 4.0.0
+ */
+function php_compat_sha256($str, $raw_output = false)
+{
+    $h0 = (int)0x6a09e667;
+    $h1 = (int)0xbb67ae85;
+    $h2 = (int)0x3c6ef372;
+    $h3 = (int)0xa54ff53a;
+    $h4 = (int)0x510e527f;
+    $h5 = (int)0x9b05688c;
+    $h6 = (int)0x1f83d9ab;
+    $h7 = (int)0x5be0cd19;
+
+    $k = array(
+        (int)0x428a2f98, (int)0x71374491, (int)0xb5c0fbcf, (int)0xe9b5dba5,
+        (int)0x3956c25b, (int)0x59f111f1, (int)0x923f82a4, (int)0xab1c5ed5,
+        (int)0xd807aa98, (int)0x12835b01, (int)0x243185be, (int)0x550c7dc3,
+        (int)0x72be5d74, (int)0x80deb1fe, (int)0x9bdc06a7, (int)0xc19bf174,
+        (int)0xe49b69c1, (int)0xefbe4786, (int)0x0fc19dc6, (int)0x240ca1cc,
+        (int)0x2de92c6f, (int)0x4a7484aa, (int)0x5cb0a9dc, (int)0x76f988da,
+        (int)0x983e5152, (int)0xa831c66d, (int)0xb00327c8, (int)0xbf597fc7,
+        (int)0xc6e00bf3, (int)0xd5a79147, (int)0x06ca6351, (int)0x14292967,
+        (int)0x27b70a85, (int)0x2e1b2138, (int)0x4d2c6dfc, (int)0x53380d13,
+        (int)0x650a7354, (int)0x766a0abb, (int)0x81c2c92e, (int)0x92722c85,
+        (int)0xa2bfe8a1, (int)0xa81a664b, (int)0xc24b8b70, (int)0xc76c51a3,
+        (int)0xd192e819, (int)0xd6990624, (int)0xf40e3585, (int)0x106aa070,
+        (int)0x19a4c116, (int)0x1e376c08, (int)0x2748774c, (int)0x34b0bcb5,
+        (int)0x391c0cb3, (int)0x4ed8aa4a, (int)0x5b9cca4f, (int)0x682e6ff3,
+        (int)0x748f82ee, (int)0x78a5636f, (int)0x84c87814, (int)0x8cc70208,
+        (int)0x90befffa, (int)0xa4506ceb, (int)0xbef9a3f7, (int)0xc67178f2
+    );
+
+    $len = strlen($str);
+
+    $str .= "\x80";
+    $str .= str_repeat("\0", 63 - ($len + 8) % 64);
+    $str .= pack('N2', $len >> 29, $len << 3);
+
+    for ($i = 0; $i < strlen($str); $i += 64) {
+
+        $w = array();
+        for ($j = 0; $j < 16; ++$j) {
+            $index = $i + $j * 4;
+            $w[$j] = ord($str[$index])     << 24
+                   | ord($str[$index + 1]) << 16
+                   | ord($str[$index + 2]) << 8
+                   | ord($str[$index + 3]);
+        }
+        for ($j = 16; $j < 64; ++$j) {
+            $s0 = php_compat_sha256_rotr_helper($w[$j - 15],  7)
+                ^ php_compat_sha256_rotr_helper($w[$j - 15], 18)
+                ^ php_compat_sha256_shr_helper ($w[$j - 15],  3);
+
+            $s1 = php_compat_sha256_rotr_helper($w[$j - 2], 17)
+                ^ php_compat_sha256_rotr_helper($w[$j - 2], 19)
+                ^ php_compat_sha256_shr_helper ($w[$j - 2], 10);
+
+            $w[$j] = php_compat_sha256_add32_helper(
+                     php_compat_sha256_add32_helper(
+                     php_compat_sha256_add32_helper($w[$j - 16], $s0), $w[$j - 7]), $s1);
+        }
+
+        $a = $h0;
+        $b = $h1;
+        $c = $h2;
+        $d = $h3;
+        $e = $h4;
+        $f = $h5;
+        $g = $h6;
+        $h = $h7;
+
+        for ($j = 0; $j < 64; ++$j) {
+            $s1 = php_compat_sha256_rotr_helper($e,  6)
+                ^ php_compat_sha256_rotr_helper($e, 11)
+                ^ php_compat_sha256_rotr_helper($e, 25);
+
+            $ch = ($e & $f) ^ (~$e & $g);
+
+            $s0 = php_compat_sha256_rotr_helper($a,  2)
+                ^ php_compat_sha256_rotr_helper($a, 13)
+                ^ php_compat_sha256_rotr_helper($a, 22);
+
+            $maj = ($a & $b) ^ ($a & $c) ^ ($b & $c);
+
+            $t1 = php_compat_sha256_add32_helper(
+                  php_compat_sha256_add32_helper(
+                  php_compat_sha256_add32_helper(
+                  php_compat_sha256_add32_helper($h, $s1), $ch), $k[$j]), $w[$j]);
+
+            $t2 = php_compat_sha256_add32_helper($s0, $maj);
+
+            $h = $g;
+            $g = $f;
+            $f = $e;
+            $e = php_compat_sha256_add32_helper($d, $t1);
+            $d = $c;
+            $c = $b;
+            $b = $a;
+            $a = php_compat_sha256_add32_helper($t1, $t2);
+        }
+
+        $h0 = php_compat_sha256_add32_helper($h0, $a);
+        $h1 = php_compat_sha256_add32_helper($h1, $b);
+        $h2 = php_compat_sha256_add32_helper($h2, $c);
+        $h3 = php_compat_sha256_add32_helper($h3, $d);
+        $h4 = php_compat_sha256_add32_helper($h4, $e);
+        $h5 = php_compat_sha256_add32_helper($h5, $f);
+        $h6 = php_compat_sha256_add32_helper($h6, $g);
+        $h7 = php_compat_sha256_add32_helper($h7, $h);
+    }
+
+    $h0 &= (int)0xffffffff;
+    $h1 &= (int)0xffffffff;
+    $h2 &= (int)0xffffffff;
+    $h3 &= (int)0xffffffff;
+    $h4 &= (int)0xffffffff;
+    $h5 &= (int)0xffffffff;
+    $h6 &= (int)0xffffffff;
+    $h7 &= (int)0xffffffff;
+
+    $hash = sprintf('%08x%08x%08x%08x%08x%08x%08x%08x', $h0, $h1, $h2, $h3, $h4, $h5, $h6, $h7);
+
+    if ($raw_output) {
+        return pack('H*', $hash);
+    } else {
+        return $hash;
+    }
+}
+
+function php_compat_sha256_add32_helper($x, $y)
+{
+    $lsw = ($x & 0xffff) + ($y & 0xffff);
+    $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
+    return ($msw << 16) | ($lsw & 0xffff);
+}
+
+function php_compat_sha256_shr_helper($x, $n)
+{
+    return ($x >> $n) & (0x7fffffff >> ($n - 1));
+}
+
+function php_compat_sha256_rotr_helper($x, $n)
+{
+    return ($x << (32 - $n)) | ($x >> $n) & (0x7fffffff >> ($n - 1));
+}
Index: branches/version-2_5-dev/data/module/Compat/Compat/Function/sha256.php
===================================================================
--- branches/version-2_5-dev/data/module/Compat/Compat/Function/sha256.php	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/Compat/Function/sha256.php	(revision 19986)
@@ -0,0 +1,156 @@
+<?php
+
+/**
+ * PHP implementation of SHA-256 hash function
+ *
+ * @category    PHP
+ * @package     PHP_Compat
+ * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
+ * @copyright   2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
+ * @link        http://php.net/function.hash
+ * @author      revulo <revulon@gmail.com>
+ * @require     PHP 4.0.0
+ */
+function php_compat_sha256($str, $raw_output = false)
+{
+    $h0 = (int)0x6a09e667;
+    $h1 = (int)0xbb67ae85;
+    $h2 = (int)0x3c6ef372;
+    $h3 = (int)0xa54ff53a;
+    $h4 = (int)0x510e527f;
+    $h5 = (int)0x9b05688c;
+    $h6 = (int)0x1f83d9ab;
+    $h7 = (int)0x5be0cd19;
+
+    $k = array(
+        (int)0x428a2f98, (int)0x71374491, (int)0xb5c0fbcf, (int)0xe9b5dba5,
+        (int)0x3956c25b, (int)0x59f111f1, (int)0x923f82a4, (int)0xab1c5ed5,
+        (int)0xd807aa98, (int)0x12835b01, (int)0x243185be, (int)0x550c7dc3,
+        (int)0x72be5d74, (int)0x80deb1fe, (int)0x9bdc06a7, (int)0xc19bf174,
+        (int)0xe49b69c1, (int)0xefbe4786, (int)0x0fc19dc6, (int)0x240ca1cc,
+        (int)0x2de92c6f, (int)0x4a7484aa, (int)0x5cb0a9dc, (int)0x76f988da,
+        (int)0x983e5152, (int)0xa831c66d, (int)0xb00327c8, (int)0xbf597fc7,
+        (int)0xc6e00bf3, (int)0xd5a79147, (int)0x06ca6351, (int)0x14292967,
+        (int)0x27b70a85, (int)0x2e1b2138, (int)0x4d2c6dfc, (int)0x53380d13,
+        (int)0x650a7354, (int)0x766a0abb, (int)0x81c2c92e, (int)0x92722c85,
+        (int)0xa2bfe8a1, (int)0xa81a664b, (int)0xc24b8b70, (int)0xc76c51a3,
+        (int)0xd192e819, (int)0xd6990624, (int)0xf40e3585, (int)0x106aa070,
+        (int)0x19a4c116, (int)0x1e376c08, (int)0x2748774c, (int)0x34b0bcb5,
+        (int)0x391c0cb3, (int)0x4ed8aa4a, (int)0x5b9cca4f, (int)0x682e6ff3,
+        (int)0x748f82ee, (int)0x78a5636f, (int)0x84c87814, (int)0x8cc70208,
+        (int)0x90befffa, (int)0xa4506ceb, (int)0xbef9a3f7, (int)0xc67178f2
+    );
+
+    $len = strlen($str);
+
+    $str .= "\x80";
+    $str .= str_repeat("\0", 63 - ($len + 8) % 64);
+    $str .= pack('N2', $len >> 29, $len << 3);
+
+    for ($i = 0; $i < strlen($str); $i += 64) {
+
+        $w = array();
+        for ($j = 0; $j < 16; ++$j) {
+            $index = $i + $j * 4;
+            $w[$j] = ord($str[$index])     << 24
+                   | ord($str[$index + 1]) << 16
+                   | ord($str[$index + 2]) << 8
+                   | ord($str[$index + 3]);
+        }
+        for ($j = 16; $j < 64; ++$j) {
+            $s0 = php_compat_sha256_rotr_helper($w[$j - 15],  7)
+                ^ php_compat_sha256_rotr_helper($w[$j - 15], 18)
+                ^ php_compat_sha256_shr_helper ($w[$j - 15],  3);
+
+            $s1 = php_compat_sha256_rotr_helper($w[$j - 2], 17)
+                ^ php_compat_sha256_rotr_helper($w[$j - 2], 19)
+                ^ php_compat_sha256_shr_helper ($w[$j - 2], 10);
+
+            $w[$j] = php_compat_sha256_add32_helper(
+                     php_compat_sha256_add32_helper(
+                     php_compat_sha256_add32_helper($w[$j - 16], $s0), $w[$j - 7]), $s1);
+        }
+
+        $a = $h0;
+        $b = $h1;
+        $c = $h2;
+        $d = $h3;
+        $e = $h4;
+        $f = $h5;
+        $g = $h6;
+        $h = $h7;
+
+        for ($j = 0; $j < 64; ++$j) {
+            $s1 = php_compat_sha256_rotr_helper($e,  6)
+                ^ php_compat_sha256_rotr_helper($e, 11)
+                ^ php_compat_sha256_rotr_helper($e, 25);
+
+            $ch = ($e & $f) ^ (~$e & $g);
+
+            $s0 = php_compat_sha256_rotr_helper($a,  2)
+                ^ php_compat_sha256_rotr_helper($a, 13)
+                ^ php_compat_sha256_rotr_helper($a, 22);
+
+            $maj = ($a & $b) ^ ($a & $c) ^ ($b & $c);
+
+            $t1 = php_compat_sha256_add32_helper(
+                  php_compat_sha256_add32_helper(
+                  php_compat_sha256_add32_helper(
+                  php_compat_sha256_add32_helper($h, $s1), $ch), $k[$j]), $w[$j]);
+
+            $t2 = php_compat_sha256_add32_helper($s0, $maj);
+
+            $h = $g;
+            $g = $f;
+            $f = $e;
+            $e = php_compat_sha256_add32_helper($d, $t1);
+            $d = $c;
+            $c = $b;
+            $b = $a;
+            $a = php_compat_sha256_add32_helper($t1, $t2);
+        }
+
+        $h0 = php_compat_sha256_add32_helper($h0, $a);
+        $h1 = php_compat_sha256_add32_helper($h1, $b);
+        $h2 = php_compat_sha256_add32_helper($h2, $c);
+        $h3 = php_compat_sha256_add32_helper($h3, $d);
+        $h4 = php_compat_sha256_add32_helper($h4, $e);
+        $h5 = php_compat_sha256_add32_helper($h5, $f);
+        $h6 = php_compat_sha256_add32_helper($h6, $g);
+        $h7 = php_compat_sha256_add32_helper($h7, $h);
+    }
+
+    $h0 &= (int)0xffffffff;
+    $h1 &= (int)0xffffffff;
+    $h2 &= (int)0xffffffff;
+    $h3 &= (int)0xffffffff;
+    $h4 &= (int)0xffffffff;
+    $h5 &= (int)0xffffffff;
+    $h6 &= (int)0xffffffff;
+    $h7 &= (int)0xffffffff;
+
+    $hash = sprintf('%08x%08x%08x%08x%08x%08x%08x%08x', $h0, $h1, $h2, $h3, $h4, $h5, $h6, $h7);
+
+    if ($raw_output) {
+        return pack('H*', $hash);
+    } else {
+        return $hash;
+    }
+}
+
+function php_compat_sha256_add32_helper($x, $y)
+{
+    $lsw = ($x & 0xffff) + ($y & 0xffff);
+    $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
+    return ($msw << 16) | ($lsw & 0xffff);
+}
+
+function php_compat_sha256_shr_helper($x, $n)
+{
+    return ($x >> $n) & (0x7fffffff >> ($n - 1));
+}
+
+function php_compat_sha256_rotr_helper($x, $n)
+{
+    return ($x << (32 - $n)) | ($x >> $n) & (0x7fffffff >> ($n - 1));
+}
Index: branches/version-2_5-dev/data/module/Compat/Compat/Function/hash_algos.php
===================================================================
--- branches/version-2_5-dev/data/module/Compat/Compat/Function/hash_algos.php	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/Compat/Function/hash_algos.php	(revision 19986)
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * Replace hash_algos()
+ *
+ * @category    PHP
+ * @package     PHP_Compat
+ * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
+ * @copyright   2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
+ * @link        http://php.net/function.hash_algos
+ * @author      revulo <revulon@gmail.com>
+ * @since       PHP 5.1.2
+ * @require     PHP 4.0.0
+ */
+function php_compat_hash_algos()
+{
+    return array('md5', 'sha1', 'sha256');
+}
+
+
+// Define
+if (!function_exists('hash_algos')) {
+    function hash_algos()
+    {
+        return php_compat_hash_algos();
+    }
+}
Index: branches/version-2_5-dev/data/module/Compat/Compat/Function/hash_hmac.php
===================================================================
--- branches/version-2_5-dev/data/module/Compat/Compat/Function/hash_hmac.php	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/Compat/Function/hash_hmac.php	(revision 19986)
@@ -0,0 +1,44 @@
+<?php
+
+require_once dirname(__FILE__) . '/hash.php';
+
+/**
+ * Replace hash_hmac()
+ *
+ * @category    PHP
+ * @package     PHP_Compat
+ * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
+ * @copyright   2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
+ * @link        http://php.net/function.hash_hmac
+ * @author      revulo <revulon@gmail.com>
+ * @since       PHP 5.1.2
+ * @require     PHP 4.0.1 (str_pad)
+ */
+function php_compat_hash_hmac($algo, $data, $key, $raw_output = false)
+{
+    // Block size (byte) for MD5, SHA-1 and SHA-256.
+    $blocksize = 64;
+
+    $ipad = str_repeat("\x36", $blocksize);
+    $opad = str_repeat("\x5c", $blocksize);
+
+    if (strlen($key) > $blocksize) {
+        $key = hash($algo, $key, true);
+    } else {
+        $key = str_pad($key, $blocksize, "\x00");
+    }
+
+    $ipad ^= $key;
+    $opad ^= $key;
+
+    return hash($algo, $opad . hash($algo, $ipad . $data, true), $raw_output);
+}
+
+
+// Define
+if (!function_exists('hash_hmac')) {
+    function hash_hmac($algo, $data, $key, $raw_output = false)
+    {
+        return php_compat_hash_hmac($algo, $data, $key, $raw_output);
+    }
+}
Index: branches/version-2_5-dev/data/module/Compat/Compat/Function/sha1.php
===================================================================
--- branches/version-2_5-dev/data/module/Compat/Compat/Function/sha1.php	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/Compat/Function/sha1.php	(revision 19986)
@@ -0,0 +1,117 @@
+<?php
+
+/**
+ * Replace sha1()
+ *
+ * @category    PHP
+ * @package     PHP_Compat
+ * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
+ * @copyright   2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
+ * @link        http://php.net/function.sha1
+ * @author      revulo <revulon@gmail.com>
+ * @since       PHP 4.3.0
+ * @require     PHP 4.0.0
+ */
+function php_compat_sha1($str, $raw_output = false)
+{
+    $h0 = (int)0x67452301;
+    $h1 = (int)0xefcdab89;
+    $h2 = (int)0x98badcfe;
+    $h3 = (int)0x10325476;
+    $h4 = (int)0xc3d2e1f0;
+
+    $len = strlen($str);
+
+    $str .= "\x80";
+    $str .= str_repeat("\0", 63 - ($len + 8) % 64);
+    $str .= pack('N2', $len >> 29, $len << 3);
+
+    for ($i = 0; $i < strlen($str); $i += 64) {
+
+        $w = array();
+        for ($j = 0; $j < 16; ++$j) {
+            $index = $i + $j * 4;
+            $w[$j] = ord($str[$index])     << 24
+                   | ord($str[$index + 1]) << 16
+                   | ord($str[$index + 2]) << 8
+                   | ord($str[$index + 3]);
+        }
+        for ($j = 16; $j < 80; ++$j) {
+            $w[$j] = php_compat_sha1_rotl_helper($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
+        }
+
+        $a = $h0;
+        $b = $h1;
+        $c = $h2;
+        $d = $h3;
+        $e = $h4;
+
+        for ($j = 0; $j < 80; ++$j) {
+            if ($j < 20) {
+                $f = ($b & $c) | (~$b & $d);
+                $k = (int)0x5a827999;
+            } else if ($j < 40) {
+                $f = $b ^ $c ^ $d;
+                $k = (int)0x6ed9eba1;
+            } else if ($j < 60) {
+                $f = ($b & $c) | ($b & $d) | ($c & $d);
+                $k = (int)0x8f1bbcdc;
+            } else {
+                $f = $b ^ $c ^ $d;
+                $k = (int)0xca62c1d6;
+            }
+
+            $t = php_compat_sha1_add32_helper(
+                 php_compat_sha1_add32_helper(
+                 php_compat_sha1_add32_helper(
+                 php_compat_sha1_add32_helper(
+                 php_compat_sha1_rotl_helper($a, 5), $f), $e), $k), $w[$j]);
+
+            $e = $d;
+            $d = $c;
+            $c = php_compat_sha1_rotl_helper($b, 30);
+            $b = $a;
+            $a = $t;
+        }
+
+        $h0 = php_compat_sha1_add32_helper($h0, $a);
+        $h1 = php_compat_sha1_add32_helper($h1, $b);
+        $h2 = php_compat_sha1_add32_helper($h2, $c);
+        $h3 = php_compat_sha1_add32_helper($h3, $d);
+        $h4 = php_compat_sha1_add32_helper($h4, $e);
+    }
+
+    $h0 &= (int)0xffffffff;
+    $h1 &= (int)0xffffffff;
+    $h2 &= (int)0xffffffff;
+    $h3 &= (int)0xffffffff;
+    $h4 &= (int)0xffffffff;
+
+    $hash = sprintf('%08x%08x%08x%08x%08x', $h0, $h1, $h2, $h3, $h4);
+
+    if ($raw_output) {
+        return pack('H*', $hash);
+    } else {
+        return $hash;
+    }
+}
+
+function php_compat_sha1_add32_helper($x, $y)
+{
+    $lsw = ($x & 0xffff) + ($y & 0xffff);
+    $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16);
+    return ($msw << 16) | ($lsw & 0xffff);
+}
+
+function php_compat_sha1_rotl_helper($x, $n)
+{
+    return ($x << $n) | ($x >> (32 - $n)) & (0x7fffffff >> (31 - $n));
+}
+
+// Define
+if (!function_exists('sha1')) {
+    function sha1($str, $raw_output = false)
+    {
+        return php_compat_sha1($str, $raw_output);
+    }
+}
Index: branches/version-2_5-dev/data/module/Compat/Compat/Function/hash.php
===================================================================
--- branches/version-2_5-dev/data/module/Compat/Compat/Function/hash.php	(revision 19986)
+++ branches/version-2_5-dev/data/module/Compat/Compat/Function/hash.php	(revision 19986)
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * Replace hash()
+ *
+ * @category    PHP
+ * @package     PHP_Compat
+ * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
+ * @copyright   2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>
+ * @link        http://php.net/function.hash
+ * @author      revulo <revulon@gmail.com>
+ * @since       PHP 5.1.2
+ * @require     PHP 4.0.0 (user_error)
+ */
+function php_compat_hash($algo, $data, $raw_output = false)
+{
+    $algo = strtolower($algo);
+    switch ($algo) {
+        case 'md5':
+            $hash = md5($data);
+            break;
+
+        case 'sha1':
+            if (!function_exists('sha1')) {
+                require dirname(__FILE__) . '/sha1.php';
+            }
+            $hash = sha1($data);
+            break;
+
+        case 'sha256':
+            if (!function_exists('php_compat_sha256')) {
+                require dirname(__FILE__) . '/_sha256.php';
+            }
+            $hash = php_compat_sha256($data);
+            break;
+
+        default:
+            user_error('hash(): Unknown hashing algorithm: ' . $algo, E_USER_WARNING);
+            return false;
+    }
+
+    if ($raw_output) {
+        return pack('H*', $hash);
+    } else {
+        return $hash;
+    }
+}
+
+
+// Define
+if (!function_exists('hash')) {
+    function hash($algo, $data, $raw_output = false)
+    {
+        return php_compat_hash($algo, $data, $raw_output);
+    }
+}
