1

I am testing a pay cart with Payfast. One thing they require is a signature which is a md5 hash based on, I quote:

A security signature of the transmitted data taking the form of an MD5 hash of the submitted variables.

The string from which the hash is created, is the concatenation of the name value pairs of all the non-blank variables with ‘&’ used as a separator eg. name_first=John&name_last=Doe&email_address=… where pairs are listed in the order in which they appear on this page.

This hash will be regenerated by the PayFast engine and the values compared to ensure the integrity of the data transfer.

I have tested my string in the Payfast sandbox and I am getting the identical string. When I create the md5 hash in the sandbox, it all works perfectly.

When I generate the hash in node I get a different hash. I have tried using:

crypto, md5-hash, blueimp-md5, and salted-md5 with and without the passphrase (secret) but never get the same md5 hash that is generated in the Payfast sandbox environment.

I have tried:

let saltedHash = md5(value, "Perfectstuff123");
let saltedHash = saltedMd5(value, "Perfectstuff123");

with value being the string(I am pretty sure it is correct as I have compared my node string with the string in the sandbox) and "Perfectstuff123" being the passphrase or secret that needs to get salted.

I am not sure if its a utf-8 or utf-16 or something else.

Any suggestions?

Wayne
  • 283
  • 1
  • 3
  • 21
  • Have you tried `CrtyoJS.MD5(value).toString()`?? Where value is the urlencoded string with the passphrase if you have one set. – Daniel_ZA Mar 31 '20 at 10:33

0 Answers0