Revision 19986,
1.1 KB
checked in by AMUAMU, 13 years ago
(diff) |
#818 (パスワードリマインダの答えのハッシュ暗号化) の解決
#819 (パスワードのハッシュ暗号化の強化) の解決
#335 (パスワードリマインダの改修) の準備修正
#895 (会員登録完了ページのタイトル異常) の解決
#899 (会員登録時にパスワードが正しく登録されない) の解決
#744 (PHP4 互換用途ソースを将来的に切り捨てやすい仕組みづくり) 関連の修正も含む
|
Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | require_once dirname(__FILE__) . '/hash.php'; |
---|
4 | |
---|
5 | /** |
---|
6 | * Replace hash_hmac() |
---|
7 | * |
---|
8 | * @category PHP |
---|
9 | * @package PHP_Compat |
---|
10 | * @license LGPL - http://www.gnu.org/licenses/lgpl.html |
---|
11 | * @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net> |
---|
12 | * @link http://php.net/function.hash_hmac |
---|
13 | * @author revulo <revulon@gmail.com> |
---|
14 | * @since PHP 5.1.2 |
---|
15 | * @require PHP 4.0.1 (str_pad) |
---|
16 | */ |
---|
17 | function php_compat_hash_hmac($algo, $data, $key, $raw_output = false) |
---|
18 | { |
---|
19 | // Block size (byte) for MD5, SHA-1 and SHA-256. |
---|
20 | $blocksize = 64; |
---|
21 | |
---|
22 | $ipad = str_repeat("\x36", $blocksize); |
---|
23 | $opad = str_repeat("\x5c", $blocksize); |
---|
24 | |
---|
25 | if (strlen($key) > $blocksize) { |
---|
26 | $key = hash($algo, $key, true); |
---|
27 | } else { |
---|
28 | $key = str_pad($key, $blocksize, "\x00"); |
---|
29 | } |
---|
30 | |
---|
31 | $ipad ^= $key; |
---|
32 | $opad ^= $key; |
---|
33 | |
---|
34 | return hash($algo, $opad . hash($algo, $ipad . $data, true), $raw_output); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | // Define |
---|
39 | if (!function_exists('hash_hmac')) { |
---|
40 | function hash_hmac($algo, $data, $key, $raw_output = false) |
---|
41 | { |
---|
42 | return php_compat_hash_hmac($algo, $data, $key, $raw_output); |
---|
43 | } |
---|
44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.