source: branches/version-2_5-dev/data/module/Compat/Compat/Function/mhash.php @ 20116

Revision 20116, 3.0 KB checked in by nanasess, 13 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2// +----------------------------------------------------------------------+
3// | PHP Version 4                                                        |
4// +----------------------------------------------------------------------+
5// | Copyright (c) 1997-2004 The PHP Group                                |
6// +----------------------------------------------------------------------+
7// | This source file is subject to version 3.0 of the PHP license,       |
8// | that is bundled with this package in the file LICENSE, and is        |
9// | available at through the world-wide-web at                           |
10// | http://www.php.net/license/3_0.txt.                                  |
11// | If you did not receive a copy of the PHP license and are unable to   |
12// | obtain it through the world-wide-web, please send a note to          |
13// | license@php.net so we can mail you a copy immediately.               |
14// +----------------------------------------------------------------------+
15// | Authors: Aidan Lister <aidan@php.net>                                |
16// +----------------------------------------------------------------------+
17//
18// $Id$
19
20
21if (!defined('MHASH_CRC32')) {
22    define('MHASH_CRC32', 0);
23}
24
25if (!defined('MHASH_MD5')) {
26    define('MHASH_MD5', 1);
27}
28
29if (!defined('MHASH_SHA1')) {
30    define('MHASH_SHA1', 2);
31}
32
33if (!defined('MHASH_HAVAL256')) {
34    define('MHASH_HAVAL256', 3);
35}
36
37if (!defined('MHASH_RIPEMD160')) {
38    define('MHASH_RIPEMD160', 5);
39}
40
41if (!defined('MHASH_TIGER')) {
42    define('MHASH_TIGER', 7);
43}
44
45if (!defined('MHASH_GOST')) {
46    define('MHASH_GOST', 8);
47}
48
49if (!defined('MHASH_CRC32B')) {
50    define('MHASH_CRC32B', 9);
51}
52
53if (!defined('MHASH_HAVAL192')) {
54    define('MHASH_HAVAL192', 11);
55}
56
57if (!defined('MHASH_HAVAL160')) {
58    define('MHASH_HAVAL160', 12);
59}
60
61if (!defined('MHASH_HAVAL128')) {
62    define('MHASH_HAVAL128', 13);
63}
64
65if (!defined('MHASH_TIGER128')) {
66    define('MHASH_TIGER128', 14);
67}
68
69if (!defined('MHASH_TIGER160')) {
70    define('MHASH_TIGER160', 15);
71}
72
73if (!defined('MHASH_MD4')) {
74    define('MHASH_MD4', 16);
75}
76
77if (!defined('MHASH_SHA256')) {
78    define('MHASH_SHA256', 17);
79}
80
81if (!defined('MHASH_ADLER32')) {
82    define('MHASH_ADLER32', 18);
83}
84
85
86/**
87 * Replace mhash()
88 *
89 * @category    PHP
90 * @package     PHP_Compat
91 * @link        http://php.net/function.mhash
92 * @author      Aidan Lister <aidan@php.net>
93 * @version     $Revision: 1.1 $
94 * @since       PHP 4.1.0
95 * @require     PHP 4.0.0 (user_error)
96 */
97if (!function_exists('mhash')) {
98    function mhash($hashtype, $data, $key = '')   
99    {
100        switch ($hashtype) {
101            case MHASH_MD5:
102                $key = str_pad((strlen($key) > 64 ? pack("H*", md5($key)) : $key), 64, chr(0x00));
103                $k_opad = $key ^ (str_pad('', 64, chr(0x5c)));
104                $k_ipad = $key ^ (str_pad('', 64, chr(0x36)));
105                return pack("H*", md5($k_opad . pack("H*", md5($k_ipad .  $data))));
106
107            default:
108                return false;
109
110            break;
111        }
112    }
113}
114
115?>
Note: See TracBrowser for help on using the repository browser.