Page 1 of 1

MD5 hash won't work

Posted: Mon Mar 19, 2007 11:34 am
by 696020
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


The script exits when it comes across this line of code: $hash = mhash(MHASH_MD5, $data);

According to the PHP documentation, the code is correct. Any ideas what is wrong?

Running PHP 5.1.2:

Code: Select all

//FIGURE OUT FINGERPRINT
		$x_tran_key="4BNm8gv2CZ7u2N9Q";
		$loginid="A7C73EEFE1D";
		$sequence=$_REQUEST['invoice_ID'];
		$tstamp=time();
		$amount=$row['grand_total'];
		$currency='USD';

		$data = $x_tran_key . $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency;
		$hash = mhash(MHASH_MD5, $data);
		$fingerprint = bin2hex($hash);

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Mar 19, 2007 11:38 am
by feyd
Do you have the mhash extension installed?

If you're wanting to use md5, you could use the built-in one: md5().

Posted: Mon Mar 19, 2007 11:43 am
by 696020
that did it! thanks!

Posted: Mon Mar 19, 2007 12:20 pm
by RobertGonzalez
I think you can also use hash() on PHP 5.1.2+.

Posted: Mon Mar 19, 2007 4:41 pm
by PrObLeM
why not use good old fashion md5( ) ( http://www.php.net/md5 )

Posted: Mon Mar 19, 2007 5:04 pm
by RobertGonzalez
feyd had suggested that. And it is a good suggestion. I was only adding my two cents because some folks may have a need for various hashing algorithms, and hash() offers that on php5.1.2+.