Revision 19986,
1.3 KB
checked in by AMUAMU, 13 years ago
(diff) |
#818 (パスワードリマインダの答えのハッシュ暗号化) の解決
#819 (パスワードのハッシュ暗号化の強化) の解決
#335 (パスワードリマインダの改修) の準備修正
#895 (会員登録完了ページのタイトル異常) の解決
#899 (会員登録時にパスワードが正しく登録されない) の解決
#744 (PHP4 互換用途ソースを将来的に切り捨てやすい仕組みづくり) 関連の修正も含む
|
Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Replace hash() |
---|
5 | * |
---|
6 | * @category PHP |
---|
7 | * @package PHP_Compat |
---|
8 | * @license LGPL - http://www.gnu.org/licenses/lgpl.html |
---|
9 | * @copyright 2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net> |
---|
10 | * @link http://php.net/function.hash |
---|
11 | * @author revulo <revulon@gmail.com> |
---|
12 | * @since PHP 5.1.2 |
---|
13 | * @require PHP 4.0.0 (user_error) |
---|
14 | */ |
---|
15 | function php_compat_hash($algo, $data, $raw_output = false) |
---|
16 | { |
---|
17 | $algo = strtolower($algo); |
---|
18 | switch ($algo) { |
---|
19 | case 'md5': |
---|
20 | $hash = md5($data); |
---|
21 | break; |
---|
22 | |
---|
23 | case 'sha1': |
---|
24 | if (!function_exists('sha1')) { |
---|
25 | require dirname(__FILE__) . '/sha1.php'; |
---|
26 | } |
---|
27 | $hash = sha1($data); |
---|
28 | break; |
---|
29 | |
---|
30 | case 'sha256': |
---|
31 | if (!function_exists('php_compat_sha256')) { |
---|
32 | require dirname(__FILE__) . '/_sha256.php'; |
---|
33 | } |
---|
34 | $hash = php_compat_sha256($data); |
---|
35 | break; |
---|
36 | |
---|
37 | default: |
---|
38 | user_error('hash(): Unknown hashing algorithm: ' . $algo, E_USER_WARNING); |
---|
39 | return false; |
---|
40 | } |
---|
41 | |
---|
42 | if ($raw_output) { |
---|
43 | return pack('H*', $hash); |
---|
44 | } else { |
---|
45 | return $hash; |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | // Define |
---|
51 | if (!function_exists('hash')) { |
---|
52 | function hash($algo, $data, $raw_output = false) |
---|
53 | { |
---|
54 | return php_compat_hash($algo, $data, $raw_output); |
---|
55 | } |
---|
56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.