Open
Description
In the example code... using it to authenticate a RESTAPI, I ran into a problem, but fixed it by decreasing the input size by 1.
// encoding
char input[] = "username:password";
int inputLen = sizeof(input)-1; <== Need to do this (most likely the code is processing the \0)
int encodedLen = base64_enc_len(inputLen);
char encoded[encodedLen];
// note input is consumed in this step: it will be empty afterwards
base64_encode(encoded, input, inputLen);
Serial.println(encoded);
will produce the following:
dXNlcm5hbWU6cGFzc3dvcmQ=
Here is what Apache will provide in the header for basic authentication... They match, but without decreasing the inputLen by 1, they will not.
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Metadata
Metadata
Assignees
Labels
No labels