Source for file emuhash_functions.php
Documentation is available at emuhash_functions.php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/emuhash_functions.php,v 1.6.10.2 2008/12/12 12:20:23 wurley Exp $
/*******************************************************************************
* emuhash - partly emulates the php mhash functions
* (c) 2004 - Simon Matter <simon.matter@invoca.ch>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************/
/******************************************************************************/
/* Do we have builtin mhash support in this PHP version ? */
/******************************************************************************/
if( ! isset
( $emuhash_openssl ) )
$emuhash_openssl =
'/usr/bin/openssl';
// don't create mhash functions if we don't have a working openssl
unset
( $emuhash_openssl );
unset
( $emuhash_openssl );
if( ! isset
( $emuhash_temp_dir ) )
$emuhash_temp_dir =
'/tmp';
/******************************************************************************/
/* Define constants used in the mhash emulation code. */
/******************************************************************************/
define('MHASH_RIPEMD160', 'rmd160');
/******************************************************************************/
/* Functions to emulate parts of php-mash. */
/******************************************************************************/
function openssl_hash( $openssl_hash_id, $password_clear ) {
global $emuhash_openssl, $emuhash_temp_dir;
$tmpfile =
tempnam( $emuhash_temp_dir, "emuhash" );
$pwhandle =
fopen( $tmpfile, "w" );
error(sprintf('Unable to create a temporary file %s to create hashed password',$tmpfile) ,'error','index.php');
fwrite( $pwhandle, $password_clear );
$cmd =
$emuhash_openssl .
' ' .
$openssl_hash_id .
' -binary < ' .
$tmpfile;
$prog =
popen( $cmd, "r" );
$pass =
fread( $prog, 1024 );
function mhash( $hash_id, $password_clear ) {
/******************************************************************************/
Documentation generated on Fri, 22 May 2009 19:08:56 +1000 by phpDocumentor 1.4.1