Hash
Discover more about the Hash component and how to use it on the Digibee Integration Platform.
Hash generates a hash from a string.
Parameters
Take a look at the configuration parameters of the component. Parameters supported by Double Braces expressions are marked with (DB)
.
Crypto Operation
Types of available operation (Hash Fields, Hash Payload, and Hash File).
Hash Fields
String
File name
Name of the file or full file path (i.e. tmp/processed/file.txt). This field is available only when Hash File is selected in the Crypto Operation parameter and supports MD5 Crypto Algorithm only.
N/A
String
Crypto Algorithm
Type of algorithm used to generate the hash. Possible values for this parameter are MD5, SHA-1, SHA-256, SHA-384, SHA-512, HmacSHA1, HmacSHA256, HmacSHA384, HmacSHA512, and BCrypt.
SHA-512
String
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.
N/A
String
Secret Key (DB)
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.
N/A
String
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 the component which is the type of the informed key, which can be of the String, Hexadecimal, or base64 type.
Hexadecimal
String
Charset
Charset of the provided key type. This field is only available when the Secret Key Type parameter value is String.
UTF-8
String
BCrypt Version
Version of the BCrypt algorithm to be considered when generating the hash. This option is only available when the Crypto Algorithm parameter value is BCrypt.
2y
N/A
Salt
A 16-byte string added to the hash value. If not informed, a random value will be assumed. This option is only available when the Crypto Algorithm parameter value is BCrypt.
N/A
String
Cost Factor
Determines the number of rounds for the hash to be executed. The cost factor will be raised to a power of 2, and the possible values are between 4 and 20. E.g.: if the parameter value is 10, then the number of rounds for the hash will be 2^10 = 1024 rounds. This option is only available when the Crypto Algorithm parameter value is BCrypt. See more in the section below.
0
Integer
JSON Field Path
JSON as the path of the string field in dotted notation.
xml.text
String
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.
N/A
String
Preserve Original
If activated, the option preserves the original field as "Field" property in the same level as the original one.
True
Boolean
Result As Hexadecimal
If activated, the option keeps the hash in hexadecimal format; otherwise, the format will be base64.
True
Boolean
Fail On Error
If the option is enabled, the execution of the pipeline with an error will be interrupted; otherwise, the pipeline execution proceeds, but the result will show a false value for the “success” property.
False
Boolean
Important: the component gerenates 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.
Cost Factor
In the BCrypt algorithm, the cost factor exponentially affects processing time and resources, as the algorithm will be executed consecutively according to the number of rounds obtained from the 2ˆn calculation result, in which “n” is the cost factor.
These are some execution examples to serve as a hash calculation duration parameter. As a premise to apply the BCrypt algorithm hash, a 1MB payload and a cost factor with a minimum and maximum allowed are being used. The obtained results are:
Cost Factor 4
Pipeline Small: average of 0.98s
Pipeline Medium: average of 0.64s
Pipeline Large: average of 0.07s
Cost Factor 20
Pipeline Small: average of 8m 7s
Pipeline Medium: average of 3m 56s
Pipeline Large: average of 1m 53s
The results above may vary according to the integration flow built, the message size to be applied to the hash and the cost factor.
Another important point to be highlighted is the limit of the cost factor. The cost factor of the BCrypt algorithm allows a range between 4 and 31, but factors above 20 end up consuming very high processing load and time, what makes the execution timeout parameters of a pipeline unfeasible.
Therefore, the Hash component was limited to accept a maximum value of 20 as a cost factor. Based on this premise, when a value is hashed through the Hash component and the BCrypt algorithm is used, mind the limit of 20 as a cost factor so that you don't have problems with validation or checking in your integration flow.
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
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:
Operation Hash Payload
If you select the Hash Payload operation, the output shows the "result" property with the hash of the provided message:
Error
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: active
Result As Hexadecimal: active
Input
Output
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: active
Result As Hexadecimal: active
Input
Output
Example 3
Crypto Operation: Hash Fields
Crypto Algorithm: BCrypt
Bcrypt Version: 2y
Salt: N9qo8uLOickgx2ZM
Cost: 6
JSON Field Path: data.test
Preserve Original: active
Input
Output
Operation Hash Payload
Example 1
Crypto Operation: Hash Payload
Crypto Algorithm: SHA-256
Payload: xpto
Result As Hexadecimal: active
Output
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: active
Output
Example 3
Crypto Operation: Hash Payload
Crypto Algorithm: BCrypt
Bcrypt Version: 2b
Salt: N9qo8uLOickgx2ZM
Cost: 10
Payload: {{ message.data }}
Input
Output
Last updated