> For the complete documentation index, see [llms.txt](https://docs.netwalletpay.com/netwallet-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.netwalletpay.com/netwallet-api-docs/reference/security/hashing-algorithms.md).

# Hashing Algorithms

Hashing plays a crucial role in securing the integrity and authenticity of data exchanged within the payment API. In this document, we'll focus on utilizing the ***SHA-256 hashing algorithm***, a widely adopted cryptographic hash function known for its strength and security.

### Enable the hashing

Login to the portal with your credential, then access to [setting page](https://netwalletpay.com:8443/Branch/Configuration) you will see the option to enable hash for payment.

<figure><img src="/files/K0o8cgHqiPC4aLcKOwYw" alt=""><figcaption></figcaption></figure>

### Hashing format

#### Payment

```
{service}_{method}_{method provider}_{order id}_{secondary key}
```

Service: COLLECTION or PAYOUT

#### Webhook

```
{order id}_{secondary key}
```

### Code sample to generate  the hash

C#

```csharp
using System;
using System.Security.Cryptography;
using System.Text;

public class HashGenerator
{
    public static string ComputeSHA256Hash(string input)
    {
        using (SHA256 sha256 = SHA256.Create())
        {
            byte[] inputBytes = Encoding.UTF8.GetBytes(input);
            byte[] hashBytes = sha256.ComputeHash(inputBytes);
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < hashBytes.Length; i++)
            {
                builder.Append(hashBytes[i].ToString("x2"));
            }
            return builder.ToString();
        }
    }
}
```

Java:

```java
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class HashGenerator {
    public static String computeSHA256Hash(String input) throws NoSuchAlgorithmException {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        byte[] hashBytes = digest.digest(input.getBytes());
        StringBuilder builder = new StringBuilder();
        for (byte b : hashBytes) {
            builder.append(String.format("%02x", b));
        }
        return builder.toString();
    }
}

```

Javascript:

```javascript
const crypto = require('crypto');

function computeSHA256Hash(input) {
    const hash = crypto.createHash('sha256');
    hash.update(input);
    return hash.digest('hex');
}

```
