MD5 hash won't work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
696020
Forum Newbie
Posts: 16
Joined: Wed Aug 16, 2006 11:45 pm

MD5 hash won't work

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Do you have the mhash extension installed?

If you're wanting to use md5, you could use the built-in one: md5().
696020
Forum Newbie
Posts: 16
Joined: Wed Aug 16, 2006 11:45 pm

Post by 696020 »

that did it! thanks!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I think you can also use hash() on PHP 5.1.2+.
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

why not use good old fashion md5( ) ( http://www.php.net/md5 )
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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+.
Post Reply