# Hash

The **Hash** connector allows you to generate hashed values from different types of input. Depending on your use case, you can choose to hash **specific fields**, **files**, or the **entire payload**.

Each option exposes its own set of parameters, but all configurations follow the same basic logic: you select the **operation**, define the **hashing algorithm**, and adjust additional parameters according to your needs.

## **Parameters**

The configuration parameters are organized into tabs: **General** and **Documentation**.

* The **General** tab contains all fields used to configure the connector. It includes parameters that are always visible, as well as those that appear dynamically depending on the selected **Crypto Operation** (for example, `Hash Fields`, `Hash File`, or `Hash Payload`) or **Crypto Algorithm** (for example, `HmacSHA256` or `BCrypt`).
* The **Documentation** tab provides an optional field where you can describe the connector configuration and add business rules or relevant notes.

Fields that support [Double Braces expressions](/documentation/connectors-and-triggers/double-braces/overview.md) are marked in the **Supports DB** column.

{% tabs fullWidth="true" %}
{% tab title="General" %}

#### **Common parameters**

These parameters are always displayed, regardless of the selected operation.

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Data type</th><th>Supports DB</th><th>Default value</th></tr></thead><tbody><tr><td><strong>Alias</strong></td><td>Name (alias) for this connector’s output, allowing you to reference it later in the flow using Double Braces expressions. <a href="/pages/1tsxJLcc1JpEDO9ZHSoU">Learn more</a>.</td><td>String</td><td>❌</td><td><code>hash-1</code></td></tr><tr><td><strong>Crypto Operation</strong></td><td>Type of operation to be performed. Possible values: <code>Hash Fields</code>, <code>Hash Payload</code>, or <code>Hash File</code>.</td><td>Select</td><td>❌</td><td><code>Hash Fields</code></td></tr><tr><td><strong>Crypto Algorithm</strong></td><td>Type of algorithm used to generate the hash. Possible values: <code>MD5</code>, <code>SHA-1</code>, <code>SHA-256</code>, <code>SHA-384</code>, <code>SHA-512</code>, <code>HmacSHA1</code>, <code>HmacSHA256</code>, <code>HmacSHA384</code>, <code>HmacSHA512</code>, and <code>BCrypt</code>.</td><td>Select</td><td>❌</td><td><code>SHA-512</code></td></tr><tr><td><strong>Result As Hexadecimal</strong></td><td>If enabled, keeps the hash in hexadecimal format; otherwise, the format will be base64.</td><td>Boolean</td><td>❌</td><td><code>true</code></td></tr><tr><td><strong>Fail On Error</strong></td><td>If enabled, interrupts the pipeline execution when an error occurs. If disabled, execution continues, but the <code>"success"</code> property will be set to <code>false</code>.</td><td>Boolean</td><td>❌</td><td><code>false</code></td></tr></tbody></table>

#### **Hash Fields**

These parameters are displayed only when the **Crypto Operation** is set to `Hash Fields`.

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Data type</th><th>Supports DB</th><th>Default value</th></tr></thead><tbody><tr><td><strong>JSON Field Path</strong></td><td>JSON path of the string field in dotted notation.</td><td>String</td><td>✅</td><td><code>xml.text</code></td></tr><tr><td><strong>Preserve Original</strong></td><td>If enabled, preserves the original field as a <code>"Field"</code> property at the same level as the original one.</td><td>Boolean</td><td>❌</td><td><code>true</code></td></tr></tbody></table>

#### **Hash File**

These parameters are displayed only when the **Crypto Operation** is set to `Hash File`.

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Data type</th><th>Supports DB</th><th>Default value</th></tr></thead><tbody><tr><td><strong>File Name</strong></td><td>Name of the file or full file path (for example, <code>tmp/processed/file.txt</code>).</td><td>String</td><td>✅</td><td>N/A</td></tr></tbody></table>

#### **Hash Payload**

These parameters are displayed only when the **Crypto Operation** is set to `Hash Payload`.

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Data type</th><th>Supports DB</th><th>Default value</th></tr></thead><tbody><tr><td><strong>Payload</strong></td><td>Field to directly inform the payload that will be hashed.</td><td>String</td><td>✅</td><td>N/A</td></tr></tbody></table>

#### **Algorithm-based configuration**

These parameters depend on the selected **Crypto Algorithm**.

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Data type</th><th>Supports DB</th><th>Default value</th></tr></thead><tbody><tr><td><strong>Account</strong></td><td>Displayed only when <strong>Crypto Algorithm</strong> is one of <code>HmacSHA1</code>, <code>HmacSHA256</code>, <code>HmacSHA384</code>, or <code>HmacSHA512</code>. The account must be of the <strong>Secret Key</strong> type, and the key for the hash must be provided.</td><td>String</td><td>❌</td><td>N/A</td></tr><tr><td><strong>Secret Key</strong> <code>(DB)</code></td><td>Displayed only if no account is selected and the <strong>Crypto Algorithm</strong> is one of <code>HmacSHA1</code>, <code>HmacSHA256</code>, <code>HmacSHA384</code>, or <code>HmacSHA512</code>. Allows the connector to receive the key dynamically.</td><td>String</td><td>✅</td><td>N/A</td></tr><tr><td><strong>Secret Key Type</strong></td><td>Displayed only if no account is selected and the <strong>Crypto Algorithm</strong> is one of <code>HmacSHA1</code>, <code>HmacSHA256</code>, <code>HmacSHA384</code>, or <code>HmacSHA512</code>. Defines the type of key provided — <code>String</code>, <code>Hexadecimal</code>, or <code>Base64</code>.</td><td>Select</td><td>❌</td><td><code>Hexadecimal</code></td></tr><tr><td><strong>Charset</strong></td><td>Displayed only when the <strong>Secret Key Type</strong> is <code>String</code>. Defines the character encoding of the key.</td><td>String</td><td>❌</td><td><code>UTF-8</code></td></tr><tr><td><strong>BCrypt Version</strong></td><td>Displayed only when <strong>Crypto Algorithm</strong> is <code>BCrypt</code>. Defines the algorithm version to be used.</td><td>Select</td><td>❌</td><td><code>2y</code></td></tr><tr><td><strong>Salt</strong></td><td>Displayed only when <strong>Crypto Algorithm</strong> is <code>BCrypt</code>. A 16-byte string added to the hash value. If not informed, a random value is assumed.</td><td>String</td><td>✅</td><td>N/A</td></tr><tr><td><strong>Cost Factor</strong></td><td>Displayed only when <strong>Crypto Algorithm</strong> is <code>BCrypt</code>. Determines the number of hash rounds (2^n, where <em>n</em> is the cost factor, between 4 and 20).</td><td>Integer</td><td>❌</td><td><code>4</code></td></tr></tbody></table>
{% endtab %}

{% tab title="Documentation" %}

<table data-full-width="true"><thead><tr><th>Parameter</th><th>Description</th><th>Data type</th><th>Supports DB</th><th>Default value</th></tr></thead><tbody><tr><td><strong>Documentation</strong></td><td>Optional field to describe the connector configuration and any relevant business rules.</td><td>String</td><td>❌</td><td>N/A</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

## **Parameters additional information**

### **Generated hash**

The connector generates a hash from the string provided in the **Payload** field when the selected operation is **Hash Payload**.

If the selected operation is **Hash Fields**, the connector generates the hash from the string found in the fields specified in the input JSON.

### **Cost Factor**

In the **BCrypt** algorithm, the cost factor exponentially increases the processing time and required resources. The algorithm is executed consecutively according to the number of rounds derived from the calculation `2ⁿ`, where “n” is the cost factor.

The following examples illustrate how execution time can vary depending on the cost factor. The tests were performed using a 1 MB payload and the minimum and maximum allowed cost factor values for the BCrypt algorithm.

**Cost Factor 4**

* **Small pipeline:** Average of 0.98s
* **Medium pipeline:** Average of 0.64s
* **Large pipeline:** Average of 0.07s

**Cost Factor 20**

* **Small pipeline:** Average of 8m 7s
* **Medium pipeline:** Average of 3m 56s
* **Large pipeline:** Average of 1m 53s

These results may vary depending on the integration flow, message size, and cost factor applied.

The BCrypt cost factor can range from 4 to 31. However, values above 20 result in very high processing loads and execution times, often exceeding the pipeline timeout limits. For this reason, the **Hash** connector only accepts a maximum cost factor value of **20**.

When using the BCrypt algorithm with the **Hash** connector, make sure to keep the cost factor within this limit to avoid validation or processing issues in your integration flow.

## **Message flow**

### **Input**

#### **Operation: Hash Fields**

When using the **Hash Fields** operation, the connector can receive any input message, but you must configure the **JSON Field Path** property to define where the hash will be applied. For example:

**JSON Field Path:** `data.test`

**Payload:**

```json
{    
    "data":[
        {"test":"xpto"},        
        {"test":"xpto1"},        
        {"test":"xpto2"},        
        {"test":"xpto3"}    
    ]
}
```

In this case, the connector searches for the `test` property inside the `data` property.

#### **Operation: Hash Payload**

When using the **Hash Payload** operation, the message to be hashed must be provided in the **Payload** field.

#### **Operation: Hash Files**

When using the **Hash Files** operation, the file name must be provided in the **File Name** field.

### **Output**

#### **Operation: Hash Fields**

The output maintains the same structure as the input but includes the generated hash.

If the **Preserve Original** property is enabled, the output keeps the original field and adds a new one prefixed with an underscore (`_`):

{% code expandable="true" %}

```json
{
  "data": [
    {
      "test": "3851b1ae73ca0ca6e3c24a0256a80ace",
     "_test": "xpto"
    },
    {
      "test": "ca9e9bf198149d78f4aad334c838a263",
   "_test": "xpto1"
    },
    {
      "test": "83709b4f9067a83bbdfb0c358dc23a5e",
      "_test": "xpto2"
    },
    {
      "test": "e427f7e6f1bd29d91ea0cc53e40fba12",
      "_test": "xpto3"
    }
  ]
}
```

{% endcode %}

#### **Operation: Hash Payload**

The output contains the `result` property with the hash of the provided message:

```json
{  
    "result": "3851b1ae73ca0ca6e3c24a0256a80ace"
}
```

**Error example**

```json
{
  "success": false,
  "message": "Something went wrong while trying to use the HashConnector. Error: java.lang.StringIndexOutOfBoundsException: String index out of range: 1",
  "error": "java.lang.StringIndexOutOfBoundsException: String index out of range: 1"
}
```

* **`success`:** `false` — indicates that an error occurred during execution.
* **`message`:** connector error message.
* **`error`:** detailed error message returned by the hash algorithm.

#### **Operation: Hash Files**

The output displays a `result` property containing the generated hash according to the selected algorithm.

**Example using SHA-256:**

```json
{
  "result": "aff746225015b78af3c3f0a7540b10c300d73b3b562cec75ef2df9cfbf7ae2b6"
}
```

## **Hash in action**

### **Operation: Hash Fields**

#### **Example 1**

* **Crypto Operation:** `Hash Fields`
* **Crypto Algorithm:** `SHA-256`
* **JSON Field Path:** `data.test`
* **Preserve Original:** `true`
* **Result as Hexadecimal:** `true`

**Input**

```json
{
    "data": [
        {"test":"xpto"},
        {"test":"xpto1"},
        {"test":"xpto2"},
        {"test":"xpto3"}
    ]
}
```

**Output**

{% code expandable="true" %}

```json
{
  "data": [
    {
      "test": "2e954593b0b51547656f7f06ec3818a2b42fed46307b81bd493133aa1ce45173",
      "_test": "xpto"
    },
    {
      "test": "8b948d95169f851545f8161fb4dc8e1d37a4c79014ac1d02186fa8946a91aab9",
      "_test": "xpto1"
    },
    {
      "test": "4c9e0d7ca22d9ab7cc675de59226f9477fd847ede13894b835d0ae204139f63a",
      "_test": "xpto2"
    },
    {
      "test": "b5bd5abe3eb5958153af6615df06ccbdfe5857a13da2601f49e4de9fbb102f9a",
      "_test": "xpto3"
    }
 ]
}
```

{% endcode %}

#### **Example 2**

* **Crypto Operation:** `Hash Fields`
* **Crypto Algorithm:** `HmacSHA256`
* **Account:** *(empty)*
* **Secret Key:** `001def0209`
* **Secret Key Type:** `Hexadecimal` (the value in the **Secret Key** field must be in hexadecimal format)
* **JSON Field Path:** `data.test`
* **Preserve Original:** `true`
* **Result as Hexadecimal:** `true`

**Input**

```json
{
    "data": [
        {"test":"xpto"},
        {"test":"xpto1"},
        {"test":"xpto2"},
        {"test":"xpto3"}
    ]
}
```

**Output**

{% code expandable="true" %}

```json
{
  "data": [
    {
      "test": "257966929b29a6e0618d47a152e2856a888072400a5cb458fa1d40ff3cedc734",
      "_test": "xpto"
    },
    {
      "test": "ce0e754ab2f57f1fca1a00fce3e834a6940bea8013ae59b6641a4911e349b480",
      "_test": "xpto1"
    },
    {
      "test": "ff0cd9c0df219f99567aeb25d7d5ab9acff3c29728b0f4f71f50e750750a26d5",
      "_test": "xpto2"
    },
    {
      "test": "04a11cbc118ea455c0072e6c70607f68324e5444c8a4795443d25933d9dfa9c6",
      "_test": "xpto3"
    }
  ]
}
```

{% endcode %}

#### **Example 3**

* **Crypto Operation:** `Hash Fields`
* **Crypto Algorithm:** `BCrypt`
* **BCrypt Version:** `2y`
* **Salt:** `N9qo8uLOickgx2ZM`
* **Cost:** `6`
* **JSON Field Path:** `data.test`
* **Preserve Original:** `true`

**Input**

```json
{
    "data": [
        {"test":"xpto"},
        {"test":"xpto1"},
        {"test":"xpto2"},
        {"test":"xpto3"}
    ]
}
```

**Output**

{% code expandable="true" %}

```json
{
    "data": [
        {
            "test": "$2y$06$RhjvZxfzRC7nW0rlcBHYROhJmATBMG6eXfkYkffexdfdFHzzp27Iu",
            "_test": "xpto"
        },
        {
            "test": "$2y$06$RhjvZxfzRC7nW0rlcBHYROm9TaJZ6QQUstIomnJG/Qgc7fPU5x8S.",
            "_test": "xpto1"
        },
        {
            "test": "$2y$06$RhjvZxfzRC7nW0rlcBHYROHAP1dIbNu3SenuQ6B.W9OkJ0/NzYF6e",
            "_test": "xpto2"
        },
        {
            "test": "$2y$06$RhjvZxfzRC7nW0rlcBHYROPsXkmxUVt8Suo8d3GuOl9q0pryw6iJy",
            "_test": "xpto3"
        }
    ]
}

```

{% endcode %}

### **Operation: Hash Payload**

#### **Example 1**

* **Crypto Operation:** `Hash Payload`
* **Crypto Algorithm:** `SHA-256`
* **Payload:** *(any payload)*
* **Result as Hexadecimal:** `true`

**Output**

```json
{  
    "result": "2e954593b0b51547656f7f06ec3818a2b42fed46307b81bd493133aa1ce45173"
}
```

#### **Example 2**

* **Crypto Operation:** `Hash Payload`
* **Crypto Algorithm:** `HmacSHA512`
* **Account:** *(empty)*
* **Secret Key:** `001def0209`
* **Secret Key Type:** `Hexadecimal`
* **Payload:** *(any payload)*
* **Result as Hexadecimal:** `true`

**Output**

```json
{  
  "result": "517da9449385a43478309459adf9304bd3c8f63cd1d388abd5cbc02b81d8ccb39d303f877019aebfed073166e6c410197e10077f6df3f7a3b3f50adb8cd09580"
}
```

#### **Example 3**

* **Crypto Operation:** `Hash Payload`
* **Crypto Algorithm:** `BCrypt`
* **BCrypt Version:** `2b`
* **Salt:** `N9qo8uLOickgx2ZM`
* **Cost:** `10`
* **Payload:** `{{ message.data }}`

**Input**

```json
{
    "data": [
        {"test":"xpto"},
        {"test":"xpto1"},
        {"test":"xpto2"},
        {"test":"xpto3"}
    ]
}
```

**Output**

```json
{  
    "result": "$2b$10$RhjvZxfzRC7nW0rlcBHYROa3UXROXVeKZ3oK4DSc1mV6iJ/pBqBm6"
}
```

### **Operation: Hash Files**

When you select the **Hash Files** operation, the connector generates a hash from the file provided in the **File Name** field.

The file must have been previously passed in the pipeline, for example, through a [**File Writer**](/documentation/connectors-and-triggers/connectors/files/file-writer.md) connector.

#### **Example**

* **Crypto Operation:** `Hash File`
* **Crypto Algorithm:** `SHA-256`
* **File Name:** `{{ message.fileName }}` (the `data` is passed through the **File Writer** connector)
* **Result as Hexadecimal:** `true`

**Input**

```json
{
  "data": "linha 1",
  "fileName": "test"
}
```

**Output**

```json
{
  "result": "aff746225015b78af3c3f0a7540b10c300d73b3b562cec75ef2df9cfbf7ae2b6"
}
```


---

# 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.digibee.com/documentation/connectors-and-triggers/connectors/security/hash.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.
