How to create SHA1 hash in n8n

I’m trying to generate a SHA-1 hash for a Netlify deployment (via API http request node) through n8n, but I’m unsure of the best approach. I’ve tried using the Code node with JavaScript’s crypto module, as well as the Crypto node, but it doesn’t support SHA-1. My goal is to take a JSON input and generate a SHA-1 hash that Netlify requires for its API to deploy changes to my web app.
Has anyone done this before in n8n, and what’s the cleanest way to achieve it?

Please share your workflow

Information on your n8n setup

  • n8n version: 1.107.4
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via : Docker / digital ocean
  • Operating system: MAC OS

Hey @MasterG hope all is good. Here are two ways you can calculate SHA1 of a given JSON:

Kindly mark this answer as solution if it was helpful. Thank you.

Cheers.

@jabbson Thanks so much for your reply! It was really helpful for my journey.

I tried your Code node SHA1 JS approach, but ran into issues with the crypto syntax – for some reason, my n8n instance didn’t like it.

I then tried your Expression node suggestion, which seemed to work initially… until I started getting error messages from the Netlify API and couldn’t figure out why. After a lot of tinkering, I realised the SHA1 hash generated by the Expression node wasn’t compatible with Netlify – it was slightly different from what was expected.

In the end, I found a solution: I created an Edit Fields (Set) node before the HTTP node, using this JS expression:

{{ $json.toJsonString().hash('sha1') }}

This produced a SHA1 hash that Netlify could actually use in Notify – problem solved!