Webhook: encrypted frm_payload content?

This is quite a basic question, but I’m struggeling to understand the content of the payload that I’ve setup in a webhook integration. I have a Dragino temp sensor (LHT65) which is sending data. On the website I can see the payload as hex (MAC payload: CB9D06EB03050106977FFF). That is the value I’m interested in. Looking at the JSON content the “uplink_message” contains the “frm_payload”, but it is a different value (e.g. “y50G6wMFAQaXf/8=”). Is it correct that the frm_payload is the encrypted version of the hex value? If that’s the case, does anyone know to decrypt that value?

No, not correct.

As it’s not decrypted, no one will know how to decrypt that value :wink:

But you can decode it, as can I, it says: CB9D06EB03050106977FFF

It’s encoded as Base64, many decoders via Ms Google, you would benefit from reading:

https://www.thethingsnetwork.org/docs/devices/bytes/

Thanks for the quick answer. I might have been a bit unclear. The value in the frm_payload is y50G6wMFAQaXf/8= and not CB9D06EB03050106977FFF. I can see the latter in the overview of the live data, but not in JSON

No, I think you were a bit quick not to read what I wrote.

The value in the frm_payload y50G6wMFAQaXf/8= IS CB9D06EB03050106977FFF that has been encoded as Base64.

Your device creates a payload as byte array (documentation link above), but is transferred over the internet in Base64 encoding as you can’t put non-ASCII bytes in to JSON.

1 Like

Yes I was a bit quick here, but now I got it. I tried the conversion from base64 with an online converter earlier and that didn’t work. I guess that is why I didn’t “see” the base64 part. Using this JS method gave the correct conversion:

function base64ToHex(str) {
  for (var i = 0, bin = atob(str.replace(/[ \r\n]+$/, "")), hex = []; i < bin.length; ++i) {
    var tmp = bin.charCodeAt(i).toString(16);
    if (tmp.length === 1) tmp = "0" + tmp;
    hex[hex.length] = tmp;
  }
  return hex.join(" ");
}

Thanks for your help.

1 Like