Convert to Base64 and then SHA256

I’m working on an automation that I need to first convert a string to Base64 and then hash it with SHA256. I’ve searched the community and found some stuff, but the config is failing.

For the Base64 conversion, I used a manual Set which goes to a Code function. The code function runs the below:

$item.encoded_message = Buffer.from(item.message).toString(‘base64’);
return $item;

I get this error back:

The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined [line 1, for item 0]

TypeError

Once I get this working I need to hash it via SHA256 which I’m trying to figure out how to do still.

I’m using the Cloud version of N8N.

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Sorry thought I mentioned this at the end:

  • n8n version: 1.44.1
  • Database (default: SQLite): Whatever comes with N8N Cloud
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): N8N Cloud
  • Operating system: N8N Cloud

Welcome to the community @AutomationFail !

Tip for sharing information

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

That implies to any JSON output you would like to share with us.


n8n has its own dedicated method to base64 encode strings, namely base64Encode().

Here’s a simple workflow to demonstrate this method as well hashing the message (using Crypto mode).