How to generate a SHA-256 Hash

If you are using a HTML form to initiate the sale or preauth transaction, your request needs to include a security hash in order to allow us to verify the message integrity.

There are two options for you to chose from - a simple version with only five transaction parameters (parameter hash) or a hash that includes all request parameters in ascending order of the parameter names (parameter hashExtended).

 

Creating the simple version (hash)

  • storename = 98765432101
  • txndatetime = 2013:07:16-09:57:08
  • chargetotal = 1.00
  • currency = 826
  • sharedsecret = TopSecret
     

Step 1 - Collect selected parameters: storename, txndatetime, chargetotal, currency and sharedsecret and join the parameters’ values to one string (use only parameters’ values and not the parameters’ names).

987654321012013:07:16-09:57:081.00826TopSecret

Step 2 - Convert the created string to its ascii hexadecimal representation.

3938373635343332313031323031333a30373a31362d30393a35373a3038312e3030383236546f70536563726574

Step 3 - Pass the ascii hexadecimal representation of the created string to the SHA-256 algorithm.

SHA256(3938373635343332313031323031333a30373a31362d30393a35373a3038312e3030383236546f70536563726574)

Step 4 - Use the value returned by the SHA-256 algorithm and submit it to our payment gateway in the given form.

3d7e75aa0b4e0e1d4a7ac87e451e64692cced46f4358ef35a69d96721341243c
<input type="hidden" name="hash"
value="3d7e75aa0b4e0e1d4a7ac87e451e64692cced46f4358ef35a69d96721341243c"/>

 

Creating the hash with all parameters (hashExtended)

  • P1 = abc
  • P2 = xyz
  • P3 = ccc
  • sharedsecret = TopSecret
  • t1=zzz
  • t2=yyy
     

Step 1  - Extended hash needs to be calculated using all request parameters in ascending order of the parameter names, adding sharedsecret at last. Join the parameters’ values to one string (use only parameters’ values and not the parameters’ names).

abcxyzccczzzyyyTopSecret

Step 2 - Convert the created string to its ascii hexadecimal representation.

3938373635343332313031323031333a30373a31362d30393a35373a3038312e3030383236546f70536563726574

Step 3 - Pass the ascii hexadecimal representation of the created string to the SHA-256 algorithm.

SHA256(3938373635343332313031323031333a30373a31362d30393a35373a3038312e3030383236546f70536563726574)

Step 4 - Use the value returned by the SHA-256 algorithm and submit it to our payment gateway in the given form.

3d7e75aa0b4e0e1d4a7ac87e451e64692cced46f4358ef35a69d96721341243c
<input type="hidden" name="hashExtended"
value="3d7e75aa0b4e0e1d4a7ac87e451e64692cced46f4358ef35a69d96721341243c"/>

 

Hash Generation Code Examples

> PHP
> ASP