PHP_Compat
[ class tree: PHP_Compat ] [ index: PHP_Compat ] [ all elements ]

Source for file mhash.php

Documentation is available at mhash.php

  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: mhash.php,v 1.1 2005/05/10 07:56:44 aidan Exp $
  19.  
  20.  
  21. if (!defined('MHASH_CRC32')) {
  22.     define('MHASH_CRC32'0);
  23. }
  24.  
  25. if (!defined('MHASH_MD5')) {
  26.     define('MHASH_MD5'1);
  27. }
  28.  
  29. if (!defined('MHASH_SHA1')) {
  30.     define('MHASH_SHA1'2);
  31. }
  32.  
  33. if (!defined('MHASH_HAVAL256')) {
  34.     define('MHASH_HAVAL256'3);
  35. }
  36.  
  37. if (!defined('MHASH_RIPEMD160')) {
  38.     define('MHASH_RIPEMD160'5);
  39. }
  40.  
  41. if (!defined('MHASH_TIGER')) {
  42.     define('MHASH_TIGER'7);
  43. }
  44.  
  45. if (!defined('MHASH_GOST')) {
  46.     define('MHASH_GOST'8);
  47. }
  48.  
  49. if (!defined('MHASH_CRC32B')) {
  50.     define('MHASH_CRC32B'9);
  51. }
  52.  
  53. if (!defined('MHASH_HAVAL192')) {
  54.     define('MHASH_HAVAL192'11);
  55. }
  56.  
  57. if (!defined('MHASH_HAVAL160')) {
  58.     define('MHASH_HAVAL160'12);
  59. }
  60.  
  61. if (!defined('MHASH_HAVAL128')) {
  62.     define('MHASH_HAVAL128'13);
  63. }
  64.  
  65. if (!defined('MHASH_TIGER128')) {
  66.     define('MHASH_TIGER128'14);
  67. }
  68.  
  69. if (!defined('MHASH_TIGER160')) {
  70.     define('MHASH_TIGER160'15);
  71. }
  72.  
  73. if (!defined('MHASH_MD4')) {
  74.     define('MHASH_MD4'16);
  75. }
  76.  
  77. if (!defined('MHASH_SHA256')) {
  78.     define('MHASH_SHA256'17);
  79. }
  80.  
  81. if (!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.  */
  97. if (!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)64chr(0x00));
  103.                 $k_opad $key (str_pad(''64chr(0x5c)));
  104.                 $k_ipad $key (str_pad(''64chr(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. ?>

Documentation generated on Mon, 11 Mar 2019 14:20:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.