Showing results for 
Search instead for 
Did you mean: 

Sha-512 hash mismatch


SHA-512 hash mismatch when we enter non-ascii characters in the hosted payment page fields such as Firstname, lastname and address.

Example from Sandbox testing:

Tested with following card information:
  Card number: 4111111111111111
  CVV: 123
  Firstname: Renée
  Lastname: brown
  Address: 123 main street
  Zip: 30321

Transaction Response:
x_card_type: Visa
x_method: CC
x_last_name: brown
x_avs_code: P
x_tax_exempt: FALSE
x_auth_code: 000000
x_SHA2_Hash: CA8F8217A69502E67BAB881A4B6B008480E73DFBD2132D864D74E7F660D33F58B5C067011267D98DA4FEA9AEE98C35A7F581A2B8618D9537D470A7001A796ADF
x_type: auth_only
x_response_code: 1
x_invoice_num: 900002667
x_address: 123 main street
x_response_reason_text: (TESTMODE) This transaction has been approved.
x_description: Brygid - Test Store
x_duty: 0.00
x_cust_id: s900002667
x_account_number: XXXX1111
x_test_request: true
x_zip: 30321
x_first_name: Ren�
x_tax: 0.00
x_response_reason_code: 1
x_trans_id: 0
x_freight: 0.00
x_amount: 3.23

Datastring to generate hash = ^0^true^1^000000^^^P^CC^XXXX1111^3.23^^Ren�^brown^123 main street^^^30321^^^^^^^^^^^^^900002667^

Hash generated: 91D06EE60901B000B4308A1A10BBE916A8B2C939C69F5E976D37CB2096887AAA9BAC0F6E7B96A512C5B3650C6A3C11E9F3A9C8AE7939E4234BD36A0CD3C38255

It is an issue with character encoding but we don't know how handles the encoding before generating the hash which they send in the response.

Will really appreciate any help from the community to resolve this issue.





In your sandbox, are you running in testmode or setting testmode in your request?  If so, you'll want to set your sandbox to live mode.



Administrator Administrator



This is entirely an encoding issue and something that has to be handled on the developer's end. The response comes in a url encoded format and server side programming must be implemented to manipulate the encoding of the non-ASCII characters.  This step was not needed for md5 due to customer information fields like name, address, etc. not being used to calculate the hash. This issue is not unique to any one developer and there are a few who have commented on how they handle it in their applications. 


If wanted to pick up some of the work, they would need to send the SIM/DPM response in a different format, which would likely break 90% of existing integrations. Or you could change the method used to calculate the hash so it doesn't use customer info fields and have a forum gone wild with irate developers telling you to go to.....   




I would recommend you use webhooks. The sha512 validation for that is much simpler and you will find a solution using that much faster than you will grinding your wheels on this.  It took me 15 minutes to set up webhooks on the first go round, and it took me 4 hours to write the programming for the relay response you are working with. You are going to find it to be harder and harder to keep the pace with products that are no longer supported. 


We are setting testmode in the request. We having the exact same issue in production as well. All of our clients are affected.

As @Renaissance  mentioned, it is entirely an encoding issue. We need to know how to handle the non-Ascii characters data coming in the response so we can generate a correct hash. 

We are looking for a proper solution which can handle any character being entered by the customer on the payment page.


Do your customers frequently use a Lithuanian I with an accented bottom? That’s the one that throws a wrench in my function. As long as the customer enters no period in any place other than the email I can work with it. I simply use a str_replace to replace squigglyIcom with .com. Otherwise periods and that I get confused by my encoding manipulations.

I never see Lithuanian I with an accented bottom being entered. 


Did I ever IM you the link to test my script? You can run the transaction above on my test link and see if i generates the same hash (the test has a place to enter a sandbox signature key. Please don’t use production credentials). Without the Lithuanian I coming into play I bet my script would work for all of your clients. I have tested it repeatedly. I cram as many no-ASCII characters in as possible. I believe it may be possible that certain combinations of non-ASCII characters throw it off but I haven’t tested it enough. I can send you the link and you can run as many tests as you want while my test server is up.
Here is my post that contains all of the characters my script can validate. It will also validate responses with that Lith I as long as a period isn’t entered anywhere except in the email address.

@Renaissance  It will be great to see how you are handling the non-ascii characters. Will it be able to handle single quote ’ ? 

@RichardH Can you also give your input on how suggest to handle the non-ascii characters in the response so we can generate a correct hash? 
This issue is affecting all of our clients which are switched to SHA512 and there is nothing in the documentation which states how to handle the response data for non-ascii characters to generate a proper hash.


My function will validate responses containing any and everything on the standard keyboard on U.S. computers, as well as what I think is a complete list of diacritic characters (I found them on a site online and I think it was supposed to have them all). The exception is the Lithuanian I. I am unable to find any encoding technique that will distinguish that I (and it’s only the upper case one. The lower case lith I posed no problem) from a period.

So my options are- do not do any encoding on the lith I and hope that customers do not use it, or 2, use the lith I in my function, and hope that other than fields that predictably have a period, like an email address, the customer doesn’t enter a period on the payment form. In that case I can add that I to my function and go afterwards and replace Customer@mailIcom with,
And replace the total xxIxx with xx.xx.

If I did more work on it I could get it to validate responses containing 3 to 4 extra periods, but it wouldn’t be any encoding technique but rather a series of hashes calculated from different strings. I could program it to try 6 different scenarios for instance, where scenario 1 is that all Lith I’s are lith I’s, scenario 2 is that all lith I’s are Lith I’s except For the last one, which is period, and so on. Then I would call the validation a pass if any of the 6 possible strings matched the sha2 value in the response.

I will send you a link to test. My function took hours to create and is not on the freebie list like the other 400 posts I have helping any and everyone with everything under the sun.

I really think your best bet is to do webhooks. They are so, so, so much easier to use. You do not have this issue at all. What language are your apps written in?