> For the complete documentation index, see [llms.txt](https://developer.senangpay.my/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.senangpay.my/integration-api/manual-integration-api-open-api/generate-secure-hash.md).

# Generate Secure Hash

## **How to generate a secure hash**

The secure hash is generated by using **HMAC hashing algorithm with SHA256 or md5** on a string consisting of (according to sequence):

* Secret Key
* Detail
* Amount
* Order ID

For example, if the values for the parameters are as below:

| Item           | Detail                 |
| -------------- | ---------------------- |
| **Secret Key** | 53-784                 |
| **Detail**     | Shopping\_cart\_id\_30 |
| **Amount**     | 24.50                  |
| **Order ID**   | 56                     |

The string to be hashed is *$str = **53-784Shopping\_cart\_id\_3024.5056*** which will generate the hash value of :

* **md5($str) => 0bde51ff340f110ab7331a902aa969e7**<br>
* **hash\_hmac(‘SHA256′, $str, ’53-784’) => 74422328b44d30bf150fffbae89bbb42b885f9ac0960e2a3ddccc0cf9aa48e39**

&#x20;

## **How to verify if the secure hash is correct**

1\. Merchants will need to generate the secure hash and compare the secure hash that was received from senangPay.

2\. For example if the parameters received from senangPay are as below:

| Item                | Detail                   |
| ------------------- | ------------------------ |
| **secret key**      | 53-784                   |
| **status\_id**      | 1                        |
| **order\_id**       | 56                       |
| **transaction\_id** | 14363538840              |
| **msg**             | Payment\_was\_successful |

3\. The string to be hashed is **$str =&#x20;*****53-78415614363538840Payment\_was\_successful*** which will generate the hash value of :

* **md5($str) => 69686562c29ad3f7955b1843a5c275ca**<br>
* **hash\_hmac(‘SHA256′, $str, ’53-784’) => 4ca7837c6c4ddb5f6ba573ea701235b2d04bc6400d32787539e07aaf319eb70f**

4\. Now you need to compare the hash value that you have generated with the hash value sent from senangPay. If the values do not match, the data may have been tampered with. Please contact <help@senangpay.my> for further assistance.
