---
title: Checksum
description: Generate SHA-256 checksums to verify data integrity in API requests.
---

A checksum helps verify that your data hasn't been changed while being sent to an API.Follow these simple steps:

- Collect all the key-value pairs you want to send to the API.
- Arrange these pairs in alphabetical order by their keys.
- Combine the values of all sorted key-value pairs into a single string.
- Append current date in the format YYYY-MM-DD to this combined string.
- Use the SHA-256 algorithm to compute a hash of the complete string. This hash is your checksum.

#### What is SHA-256

SHA-256 is a cryptographic hash function that produces a unique 256-bit output for any given input, ensuring data integrity and authenticity. While it is a one-way function and cannot be decrypted, it is often used alongside encryption methods that require a decryption key. This combination secures sensitive information during transmission, ensuring that only authorized parties can access the original data.

## PHP

```php
<?php
$data   = array();
$data['orderid'] = 'ORDER1234';
$data['amount']  = 100.00;

$checksum  = checksum($data);

function checksum($data) {
    ksort($data);
        $checksumdata = '';
        foreach ($data as $key => $value) {
            $checksumdata .= $value;
        }
    return hash('SHA256', $checksumdata.date('Y-m-d'));
}
```