Process a variable size array through the Crypto node

Hello,

I need to hash some values using the crypto node. The problem is that the values are in an array, and the size of the array varies. So I may have multiple items, each of them has an array with values that need to be hashed:

[
  {
    "json": {
      "options": [
        {
          "id": "this needs to be hashed with md5"
        },
        {
          "id": "this needs to be hashed with md5"
        },
        {
          "id": "this needs to be hashed with md5"
        },
        {
          "id": "this needs to be hashed with md5"
        }
      ]
    }
  },
  {
    "json": {
      "options": [
        {
          "id": "this needs to be hashed with md5"
        },
        {
          "id": "this needs to be hashed with md5"
        }
      ]
    }
  }
]

Is there a solution for this?

Thanks,

Jos

Hi @Jos_van_Uden,

you can use the list node to separate each array into multiple items, like this:

2 Likes

Yes, that seems to be the only way, but then they all end up in one big pile. I’ll have to tag them with the item.id so I can merge them later by comparing the item.id field.

I was hoping that I might be overlooking a simpler method.

Thanks.

You could split the items into batches of 1 before putting them through the list and crypt node like this:

Then you only get the items which were in one array, I put a code block as placeholder where you can do anything with these items.

Does that help?

2 Likes

Yep that works.

Thanks

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.