Skip to main content

Hash Component

Compute hashes of strings using common hash functions

Component key: hash

Description#

The Hash component allows you to compute the hash of a string using a variety of common hash functions (MD5, SHA256, etc).

Triggers#

HMAC Webhook Trigger#

Validate a payload using an HMAC hash function | key: hmacWebhookTrigger

InputDefaultNotesExample
Input
Response Body
string
Default
Notes
The body to use for the response
Example
{  "executionId": "08293301-6d4f-4e4b-b5f1-bb322b704b71"}
Input
Response Content Type
string
Default
Notes
The Content-Type header to use for the response
Example
application/json
Input
HMAC Hash Function
string
/ Required
Default
sha256
Notes
 
Example
md5
Input
Additional Response Headers
string
Key Value List
Default
Notes
List of key/value pairs to use as additional headers for the response
Example
 
Input
HMAC Header Name
string
/ Required
Default
Notes
The name of the header that contains the HMAC hash of the payload's body
Example
x-hmac-sha256
Input
Secret Key
string
/ Required
Default
Notes
The cryptographic secret key used to hash the payload's body
Example
p@$sW0Rd
Input
Response Status Code
string
Default
Notes
The HTTP status code to use for the response
Example
200

HMAC (or hash-based message authentication code) is an authentication mechanism that allows you verify that incoming webhook messages are genuine.

How does HMAC work?#

An external system (yours or a third-party) produces a cryptographic hash of the webhook payload's body using a secret key, and sends the hash as an HTTP header along with the webhook request. Only the external system and your integration know the secret key.

This trigger, then, uses the secret key to produce a hash of the received payload. If the hash generated in the trigger matches the hash sent as a header, the payload is processed. If the hashes do not match, an error is thrown and the integration does not run. This prevents a bad actor from sending bogus payloads to your instances - they cannot spoof an HMAC hash without the correct signing key.

You can read more about HMAC on our blog.

Example HMAC Signature#

Suppose you would like to sign a JSON payload that reads {"foo":"bar","baz":123,"buz":false} using the SHA256 hashing algorithm (you can use a number of hashing algorithms, SHA256 being the most common for HMAC). You've chosen a secret key of secret123 (please use a more complex secret!). You can generate a hash in NodeJS using the crypto module:

Compute an HMAC hash in a third-party system
const body = '{"foo":"bar","baz":123,"buz":false}';const hmac = crypto.createHmac("sha256", "secret123");const hash = hmac.update(body, "utf-8").digest("hex");// Generates 44cfc2defd77a70bedef0228634c45800fce1e678174895e984bd608c221bdb8

Most modern languages have HMAC libraries: NodeJS, Python, PHP, .NET C#.

You can then take that hash and pass it in as a header in a webhook invocation request:

curl https://hooks.prismatic.io/example \  --request POST \  --header "my-hmac-hash: 44cfc2defd77a70bedef0228634c45800fce1e678174895e984bd608c221bdb8" \  --header "content-type: application/json" \  --data '{"foo":"bar","baz":123,"buz":false}'

When you configure your HMAC trigger in Prismatic, then, you can enter secret123 as your HMAC Secret Key, my-hmac-hash as your HMAC Header Name, and SHA256 as your HMAC Algorithm (you can obviously change those values).


Actions#

Compute BLAKE2b512 Hash#

Compute the BLAKE2b512 hash of a string | key: computeblake2b512

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "4386a08a265111c9896f56456e2cb61a64239115c4784cf438e36cc851221972da3fb0115f73cd02486254001f878ab1fd126aac69844ef1c1ca152379d0a9bd",    "base64": "Q4agiiZREcmJb1ZFbiy2GmQjkRXEeEz0OONsyFEiGXLaP7ARX3PNAkhiVAAfh4qx/RJqrGmETvHByhUjedCpvQ=="  }}

Compute BLAKE2s256 Hash#

Compute the BLAKE2s256 hash of a string | key: computeblake2s256

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "7706af019148849e516f95ba630307a2018bb7bf03803eca5ed7ed2c3c013513",    "base64": "dwavAZFIhJ5Rb5W6YwMHogGLt78DgD7KXtftLDwBNRM="  }}

Compute Hash#

Compute the hash of a string using a hash function | key: computeHash

InputDefaultNotesExample
Input
Hash Function
string
/ Required
Default
sha256
Notes
 
Example
md5
Input
Message
string
/ Required
Default
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "b10a8db164e0754105b7a99be72e3fe5",    "base64": "sQqNsWTgdUEFt6mb5y4/5Q=="  }}

Compute HMAC Hash#

Compute an HMAC hash given a message, secret and hash function | key: computeHmac

InputDefaultNotesExample
Input
Hash Function
string
/ Required
Default
sha256
Notes
 
Example
md5
Input
Message
string
/ Required
Default
Notes
The message to generate a hash of
Example
Hello World
Input
Secret Key
string
/ Required
Default
Notes
The cryptographic secret key used to hash the payload's body
Example
p@$sW0Rd

If you plan to send webhook requests to a third-party from Prismatic, you can use the Compute HMAC Hash action to compute the HMAC hash of a given string using a secret key.

Output Example Payload#

{  "data": {    "hex": "82ce0d2f821fa0ce5447b21306f214c99240fecc6387779d7515148bbdd0c415",    "base64": "gs4NL4IfoM5UR7ITBvIUyZJA/sxjh3eddRUUi73QxBU="  }}

Compute MD4 Hash#

Compute the MD4 hash of a string | key: computemd4

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "77a781b995cf1cfaf39d9e2f5910c2cf",    "base64": "d6eBuZXPHPrznZ4vWRDCzw=="  }}

Compute MD5 Hash#

Compute the MD5 hash of a string | key: computemd5

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "b10a8db164e0754105b7a99be72e3fe5",    "base64": "sQqNsWTgdUEFt6mb5y4/5Q=="  }}

Compute MD5-SHA1 Hash#

Compute the MD5-SHA1 hash of a string | key: computemd5-sha1

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "b10a8db164e0754105b7a99be72e3fe50a4d55a8d778e5022fab701977c5d840bbc486d0",    "base64": "sQqNsWTgdUEFt6mb5y4/5QpNVajXeOUCL6twGXfF2EC7xIbQ"  }}

Compute RIPEMD160 Hash#

Compute the RIPEMD160 hash of a string | key: computeripemd160

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "a830d7beb04eb7549ce990fb7dc962e499a27230",    "base64": "qDDXvrBOt1Sc6ZD7fcli5JmicjA="  }}

Compute SHA1 Hash#

Compute the SHA1 hash of a string | key: computesha1

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "0a4d55a8d778e5022fab701977c5d840bbc486d0",    "base64": "Ck1VqNd45QIvq3AZd8XYQLvEhtA="  }}

Compute SHA224 Hash#

Compute the SHA224 hash of a string | key: computesha224

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "c4890faffdb0105d991a461e668e276685401b02eab1ef4372795047",    "base64": "xIkPr/2wEF2ZGkYeZo4nZoVAGwLqse9DcnlQRw=="  }}

Compute SHA256 Hash#

Compute the SHA256 hash of a string | key: computesha256

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e",    "base64": "pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4="  }}

Compute SHA3-224 Hash#

Compute the SHA3-224 hash of a string | key: computesha3-224

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "8e800079a0b311788bf29353f400eff969b650a3597c91efd9aa5b38",    "base64": "joAAeaCzEXiL8pNT9ADv+Wm2UKNZfJHv2apbOA=="  }}

Compute SHA3-256 Hash#

Compute the SHA3-256 hash of a string | key: computesha3-256

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "e167f68d6563d75bb25f3aa49c29ef612d41352dc00606de7cbd630bb2665f51",    "base64": "4Wf2jWVj11uyXzqknCnvYS1BNS3ABgbefL1jC7JmX1E="  }}

Compute SHA3-384 Hash#

Compute the SHA3-384 hash of a string | key: computesha3-384

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "a78ec2851e991638ce505d4a44efa606dd4056d3ab274ec6fdbac00cde16478263ef7213bad5a7db7044f58d637afdeb",    "base64": "p47ChR6ZFjjOUF1KRO+mBt1AVtOrJ07G/brADN4WR4Jj73ITutWn23BE9Y1jev3r"  }}

Compute SHA3-512 Hash#

Compute the SHA3-512 hash of a string | key: computesha3-512

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "3d58a719c6866b0214f96b0a67b37e51a91e233ce0be126a08f35fdf4c043c6126f40139bfbc338d44eb2a03de9f7bb8eff0ac260b3629811e389a5fbee8a894",    "base64": "PVinGcaGawIU+WsKZ7N+UakeIzzgvhJqCPNf30wEPGEm9AE5v7wzjUTrKgPen3u47/CsJgs2KYEeOJpfvuiolA=="  }}

Compute SHA384 Hash#

Compute the SHA384 hash of a string | key: computesha384

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "99514329186b2f6ae4a1329e7ee6c610a729636335174ac6b740f9028396fcc803d0e93863a7c3d90f86beee782f4f3f",    "base64": "mVFDKRhrL2rkoTKefubGEKcpY2M1F0rGt0D5AoOW/MgD0Ok4Y6fD2Q+Gvu54L08/"  }}

Compute SHA512 Hash#

Compute the SHA512 hash of a string | key: computesha512

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "2c74fd17edafd80e8447b0d46741ee243b7eb74dd2149a0ab1b9246fb30382f27e853d8585719e0e67cbda0daa8f51671064615d645ae27acb15bfb1447f459b",    "base64": "LHT9F+2v2A6ER7DUZ0HuJDt+t03SFJoKsbkkb7MDgvJ+hT2FhXGeDmfL2g2qj1FnEGRhXWRa4nrLFb+xRH9Fmw=="  }}

Compute SHA512-224 Hash#

Compute the SHA512-224 hash of a string | key: computesha512-224

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "feca41095c80a571ae782f96bcef9ab81bdf0182509a6844f32c4c17",    "base64": "/spBCVyApXGueC+WvO+auBvfAYJQmmhE8yxMFw=="  }}

Compute SHA512-256 Hash#

Compute the SHA512-256 hash of a string | key: computesha512-256

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "ff20018851481c25bfc2e5d0c1e1fa57dac2a237a1a96192f99a10da47aa5442",    "base64": "/yABiFFIHCW/wuXQweH6V9rCojehqWGS+ZoQ2keqVEI="  }}

Compute SM3 Hash#

Compute the SM3 hash of a string | key: computesm3

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "77015816143ee627f4fa410b6dad2bdb9fcbdf1e061a452a686b8711a484c5d7",    "base64": "dwFYFhQ+5if0+kELba0r25/L3x4GGkUqaGuHEaSExdc="  }}

Compute whirlpool Hash#

Compute the whirlpool hash of a string | key: computewhirlpool

InputNotesExample
Input
Message
string
/ Required
Notes
The message to generate a hash of
Example
Hello World

Output Example Payload#

{  "data": {    "hex": "b77b284bffc952efee36a94397a0ce11e8624668e33b7020a80eb2fb21096f0a08518c50d023de12b010c2e30b93b5837dc471d899608d786fe9a6b60112ea4a",    "base64": "t3soS//JUu/uNqlDl6DOEehiRmjjO3AgqA6y+yEJbwoIUYxQ0CPeErAQwuMLk7WDfcRx2JlgjXhv6aa2ARLqSg=="  }}