note 71567 added to ref.mhash

From: Date: Wed, 06 Dec 2006 08:44:10 +0000
Subject: note 71567 added to ref.mhash
Groups: php.notes 
Request: Send a blank email to php-notes+get-120332@lists.php.net to get a copy of this message
function getHashNotWorking($argStrHashMethod, $argStrString) { $strHashMethod = 'MHASH_' . $argStrHashMethod; $strHashedString = bin2hex(mhash($strHashMethod, $argStrString)); return $strHashedString; } echo getHashNotWorking('SHA512', 'some string'); This will return an error about the mhash function expecting a long type instead of a string. ============================= for ($intI = 0; $intI <= mhash_count(); $intI++) { $arrHashTypes[mhash_get_hash_name($intI)] = $intI; } function getHashWorking($argStrType, $argStrString) { global $arrHashTypes; $strHashedString = bin2hex(mhash($arrHashTypes[$argStrType], $argStrString)); return $strHashedString; } echo getHashWorking('SHA512', 'some string'); This will return the hash with the desired hash method ---- Server IP: 194.109.193.94 Probable Submitter: 82.204.32.210 ---- Manual Page -- http://www.php.net/manual/en/ref.mhash.php Edit -- https://master.php.net/note/edit/71567 Del: integrated -- https://master.php.net/note/delete/71567/integrated Del: useless -- https://master.php.net/note/delete/71567/useless Del: bad code -- https://master.php.net/note/delete/71567/bad+code Del: spam -- https://master.php.net/note/delete/71567/spam Del: non-english -- https://master.php.net/note/delete/71567/non-english Del: in docs -- https://master.php.net/note/delete/71567/in+docs Del: other reasons-- https://master.php.net/note/delete/71567 Reject -- https://master.php.net/note/reject/71567 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120332) next »