Hash generates a hash from a string provided in the "Payload" field if the selected operation is Hash Payload.

However, if the selected operation is Hash Fields, then the component generates a hash from a string provided in the fields specified in the input JSON.

Take a look at the configuration parameters of the component:

  • Crypto Operation: types of available operation - Hash Fields and Hash Payload.
  • Crypto Algorithm: type of algorithm used to generate the hash.
  • Account: it will be shown only if the selected algorithm in the Crypto Algorithm field is HmacSHA1, HmacSHA256, HmacSHA384 or HmacSHA512. The account must be from the SECRET_KEY type and the key for the hash must be informed.
  • Secret Key: it will be shown only if no account is selected and the algorithm selected in the Crypto Algorithm field is HmacSHA1, HmacSHA256, HmacSHA384 or HmacSHA512. This is an alternative for the component to receive the key for the hash generation in a dynamic way.
  • Secret Key Type: it will be shown only if the algorithm selected in the Crypto Algorithm field is HmacSHA1, HmacSHA256, HmacSHA384 or HmacSHA512. This field also informs to the component which is the type of the informed key, which can be of the String, Hexadecimal or base64 type.
  • JSON Field Path: JSON as path of the string field in dotted notation.
  • Payload: field to directly inform the payload that will have the hash done. It will be shown only if the selected operation is Hash Payload.
  • Preserve Original: if activated, the option preserves the original field as "Field" property in the same level as the original one.
  • Result As Hexadecimal: if activated, the option keeps the hash in hexadecimal format; otherwise, the format will be base64.
  • Fail On Error: if "true", the pipeline with error execution will be suspended; if "false", the pipeline execution continues, but the result will show a false value for the success property.

Messages flow

Input

If you select the Hash Fields operation, the component receives any input message, but you must configure the path for the message hash in the Json Field Path property. For example:

Json Field Path: data.test

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

Therefore, the component makes a search in the “test” property, inside the “data” property.

On the other hand, if you select the Hash Payload operation, then the input message must be informed inside the Payload field.

Output

Operation Hash Fields

If you select the Hash Fields operation, the output has the same input structure, but shows the message hash. If the Preserve Original property is enabled, then the output preserves the original field in the same level, adding the '_' prefix before the field:

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

Operation Hash Payload

If you select the Hash Payload operation, the output shows the "result" property wuth the hash of the provided message:

{
"result": "3851b1ae73ca0ca6e3c24a0256a80ace"
}

Error

{
"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”, because there was an error in the execution
  • message: error message of the component
  • error: error message received from the hash algorithm

Hash in Action

Operation Hash Fields

Example 1

  • Crypto Operation: Hash Fields
  • Crypto Algorithm: SHA-256
  • JSON Field Path: data.test
  • Preserve Original: enabled
  • Result As Hexadecimal: enabled

Input

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

Output

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

Example 2

  • Crypto Operation: Hash Fields
  • Crypto Algorithm: HmacSHA256
  • Account: empty
  • Secret Key: 001def0209
  • Secret Key Type: Hexadecimal (the key provided in the Secret Key property must be in hexadecimal)
  • JSON Field Path: data.test
  • Preserve Original: enabled
  • Result As Hexadecimal: enabled

Input

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

Output

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

Operation Hash Payload

Example 1

  • Crypto Operation: Hash Payload
  • Crypto Algorithm: SHA-256
  • Payload: xpto
  • Result As Hexadecimal: enabled

Output

{
"result": "2e954593b0b51547656f7f06ec3818a2b42fed46307b81bd493133aa1ce45173"
}

Example 2

  • Crypto Operation: Hash Payload
  • Crypto Algorithm: HmacSHA512
  • Account: empty
  • Secret Key: 001def0209
  • Secret Key Type: Hexadecimal (the key provided in the Secret Key property must be in hexadecimal)
  • Payload: xpto
  • Result As Hexadecimal: enabled

Output

{
"result": "517da9449385a43478309459adf9304bd3c8f63cd1d388abd5cbc02b81d8ccb39d303f877019aebfed073166e6c410197e10077f6df3f7a3b3f50adb8cd09580"
}

Did this answer your question?