# 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');
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.netwalletpay.com/netwallet-api-docs/reference/security/hashing-algorithms.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
