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
Input | Default | Notes | Example |
---|---|---|---|
Response Body string body | The body to use for the response | {"status":"success"} | |
Response Content Type string contentType | The Content-Type header to use for the response | application/json | |
HMAC Hash Function string / Required hashFunction | sha256 | md5 | |
Additional Response Headers string Key Value List headers | List of key/value pairs to use as additional headers for the response | ||
HMAC Header Name string / Required hmacHeaderName | The name of the header that contains the HMAC hash of the payload's body | x-hmac-sha256 | |
Secret Key string / Required secretKey | The cryptographic secret key used to hash the payload's body. This must be a string or byte array | p@$sW0Rd | |
Response Status Code string statusCode | The HTTP status code to use for the response | 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:
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
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute BLAKE2b512 Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}
Compute BLAKE2s256 Hash
Compute the BLAKE2s256 hash of a string | key: computeblake2s256
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute BLAKE2s256 Hash
{
"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
Input | Default | Notes | Example |
---|---|---|---|
Hash Function string / Required hashFunction | sha256 | md5 | |
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute Hash
{
"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
Input | Default | Notes | Example |
---|---|---|---|
Hash Function string / Required hashFunction | sha256 | md5 | |
Message string / Required message | The message to generate a hash of | Hello World | |
Secret Key string / Required secretKey | The cryptographic secret key used to hash the payload's body. This must be a string or byte array | 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.
Example Payload for Compute HMAC Hash
{
"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
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute MD4 Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}
Compute MD5 Hash
Compute the MD5 hash of a string | key: computemd5
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute MD5 Hash
{
"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
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute MD5-SHA1 Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}
Compute RIPEMD160 Hash
Compute the RIPEMD160 hash of a string | key: computeripemd160
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute RIPEMD160 Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}
Compute SHA1 Hash
Compute the SHA1 hash of a string | key: computesha1
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA1 Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}
Compute SHA224 Hash
Compute the SHA224 hash of a string | key: computesha224
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA224 Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}
Compute SHA256 Hash
Compute the SHA256 hash of a string | key: computesha256
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA256 Hash
{
"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
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA3-224 Hash
{
"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
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA3-256 Hash
{
"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
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA3-384 Hash
{
"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
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA3-512 Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}
Compute SHA384 Hash
Compute the SHA384 hash of a string | key: computesha384
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA384 Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}
Compute SHA512 Hash
Compute the SHA512 hash of a string | key: computesha512
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA512 Hash
{
"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
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA512-224 Hash
{
"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
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SHA512-256 Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}
Compute SM3 Hash
Compute the SM3 hash of a string | key: computesm3
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute SM3 Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}
Compute whirlpool Hash
Compute the whirlpool hash of a string | key: computewhirlpool
Input | Notes | Example |
---|---|---|
Message string / Required message | The message to generate a hash of | Hello World |
Example Payload for Compute whirlpool Hash
{
"data": {
"hex": "<hex encoded hash value>",
"base64": "<base64 encoded hash value>"
}
}