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.1 2007/12/21 12:11:55 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" );
pla_error( "Unable to create a temporary file '$tmpfile' to create hashed password" );
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 ) {
/******************************************************************************/
|