[racktables-users] Mhash support

Hello,

I want to run RackTables on SLES but can't find a php hash package and
it seemed easier modifying RackTables to support mhash than installing
php-hash support. Is it possible to include the following or part of the
following function in RackTables? I have borrowed it from another open
source application but it integrates into RackTables without making many
changes.


function _ssiHash($algo, $data)
{
# Taken from: "svn.wp-plugins.org/simple-sign-in/trunk/ssi/ssi.php"

        $algo = str_replace("-", "", $algo);

        switch ($algo) {
                case 'md5':
                        return md5($data);
                break;
                case 'sha1':
                        return sha1($data);
                break;
                case 'crc32':
                        return crc32($data);
                break;
        }
        
        if (function_exists('mhash')) {
                $mhash_algos = array(
                        'adler32' => MHASH_ADLER32,
                        'crc32b' => MHASH_CRC32B, 
                        'gost' => MHASH_GOST, 
                        'haval128' => MHASH_HAVAL128, 
                        'haval160' => MHASH_HAVAL160, 
                        'haval192' => MHASH_HAVAL192, 
                        'haval256' => MHASH_HAVAL256, 
                        'ripemd160' => MHASH_RIPEMD160, 
                        'sha256' => MHASH_SHA256, 
                        'tiger' => MHASH_TIGER, 
                        'tiger128' => MHASH_TIGER128, 
                        'tiger160'  => MHASH_TIGER160);
                
                if(array_key_exists($algo, $mhash_algos)) {
                        return bin2hex(mhash($mhash_algos[$algo],
$data));
                } else {
                        return false;
                }
        } else if (function_exists('hash') &&
function_exists('hash_algos')) {
                if(in_array($algo, hash_algos())) {
                        return hash($algo, $data);
                } else {
                        return false;
                }
        } else {
                return false;
        }
}



I add this function to auth.php, just above authenticate_via_database
(no particular reason), and change all references of 'hash (' to
'_ssiHash ('. 

I also comment out the hash check code (about 6 lines) that is in
authenticate_via_database in auth.php.

I also change the install.php to detect mhash as well as hash_algos.


Regards
Andrew Milne.


Other related posts: