sketch_jun13b:3:52: error: invalid operands of types 'const char [29]' and 'unsigned char [128]' to binary 'operator+'
String req = "{\"message-id\":\"002\",\"auth\":\"" + auth + "\",\"request-type\":\"Authenticate\"}";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
Which is trying to tell you that the String + operator only works on Strings and needs at least one side the + to be a String.
Break the statement down into
However is auth null terminated? or just an array of bytes?
You may need to use auth[hashb64_len] = '\0';
to terminate the array.
But check that hashb64_len is < sizeof(auth)
p.s. @UKHeliBob code will crash if hashn64_len turns out to be >40
replacing strcat wth strlcat will avoid the crash but still not give you the answer you want.
To be more precise, the code will crash if buffer is declared too small to hold the final string. I am well aware of that but what I posted was an example, not a solution
No Strings work just fine and no need to fuss about exactly how big to make Bob's buffer. Edit - if you look in the library code you will probably find they are using Strings all over the place. No. The websockets library I found uses c-strings underneath.
p.s. you need to check the hashn64_len to make sure the result was actually written.
even if you use @UKHeliBob strcat code your auth needs to be '\0' terminated. Edit - looks like mbedtls_base64_encode does terminate the result and check there is space for the terminating '\0', so the memset(auth, 0, sizeof(auth)); is unnecessary
As I said strlcat is safer then strcat. This sketch, strlcpy_strlcat.ino, shows you how to use it and how to check for buffer overruns.
Run the example and get this, wondering if something related to ESP32 and Arduino core?
In function 'void setup()':
55:53: error: 'strlcpy_P' was not declared in this scope
count = strlcpy_P(result, progStr1, sizeof(result));
^
75:53: error: 'strlcat_P' was not declared in this scope
count = strlcat_P(result, progStr2, sizeof(result));
^
exit status 1
'strlcpy_P' was not declared in this scope
That's good. Note that I deliberately went overboard with the size of the buffer array and it should be reduced to a more sensible size to suit your requirements