Skip to content

Instantly share code, notes, and snippets.

@davisford
Created June 1, 2015 16:00
Show Gist options
  • Save davisford/2a89c39b82406b0482d5 to your computer and use it in GitHub Desktop.
Save davisford/2a89c39b82406b0482d5 to your computer and use it in GitHub Desktop.
usaepay UMhash example broken

USAePay, looks like your hash example is wrong. Consider your example listed here: http://wiki.usaepay.com/developer/transactionapi?#calculating_hash_value

You use as input string sale:sd*s3j002jd:53.21:34576721:1234, but claim it md5 hashes to 52d534dd45388432ac0a44c9174ffb3f, but this is wrong.

Using Mac OS built-in md5 binary:

$md5 -s sale:sd*s3j002jd:53.21:3456721:1234
MD5 ("sale:sd*s3j002jd:53.21:3456721:1234") = 423ce7188315e73be5d81dbe7f28db22

You can even dump this code in PHP repl and run it -- same result.

$umcommand = "sale" ;
$pin = "sd*s3j002jd";
$amount = "53.21" ;
$invoice = "3456721" ;
 
$hashseed = "1234";   // mktime returns the current time in seconds since epoch.
$hashdata = $umcommand . ":" . $pin . ":" . $amount . ":" . $invoice . ":" . $hashseed ;
 
$hash = md5 ( $hashdata );   // php includes a built-in md5 function that will create the hash

print($hash);
@davisford
Copy link
Author

@CharlesMcewen - nice catch! that was a subtle one...indeed. Thanks for the reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment