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

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

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute BLAKE2s256 Hash

Compute the BLAKE2s256 hash of a string | key: computeblake2s256

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute Hash

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

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute HMAC Hash

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

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": "<hex encoded hmac value>",
"base64": "<base64 encoded hmac value>",
"byteArray": {
"type": "Buffer",
"data": [
60,
98,
121,
116,
101,
32,
97,
114,
114,
97,
121,
32,
104,
109,
97,
99,
32,
118,
97,
108,
117,
101,
62
]
}
}
}

Compute MD4 Hash

Compute the MD4 hash of a string | key: computemd4

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute MD5 Hash

Compute the MD5 hash of a string | key: computemd5

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute MD5-SHA1 Hash

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

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute RIPEMD160 Hash

Compute the RIPEMD160 hash of a string | key: computeripemd160

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA1 Hash

Compute the SHA1 hash of a string | key: computesha1

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA224 Hash

Compute the SHA224 hash of a string | key: computesha224

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA256 Hash

Compute the SHA256 hash of a string | key: computesha256

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA3-224 Hash

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

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA3-256 Hash

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

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA3-384 Hash

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

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA3-512 Hash

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

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA384 Hash

Compute the SHA384 hash of a string | key: computesha384

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA512 Hash

Compute the SHA512 hash of a string | key: computesha512

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA512-224 Hash

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

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SHA512-256 Hash

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

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute SM3 Hash

Compute the SM3 hash of a string | key: computesm3

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}

Compute whirlpool Hash

Compute the whirlpool hash of a string | key: computewhirlpool

Output Example Payload

{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}