-
Notifications
You must be signed in to change notification settings - Fork 103
some problem with the library not sure what #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
does the library introduce newline character at the end? |
Hi Shirish, I took a look at the base64 library you are using and it would appear a character is being appended at the end of the Base64 encoded payload. Take a look at this line: https://github.com/adamvr/arduino-base64/blob/master/Base64.cpp#L46. On that line, the character '\0' is appended to the end of the Base64 payload -- from my perspective this does not make sense as the payload does not require this character. Do you mind and checking if I am reading this correctly? Is there something I am missing here in regards to the behavior I am reading from this code? I see you opened an issue against this lib on Github -- feel free to read what I sent and see if this information should be added to your issue. Happy to assist further here in any way possible -- just let me know how I can be of assistance! Thanks, As Ryan Suggested I commented the line 46 in base64 but I don't know how the length has to be changed. but anyways when I print I get a correct converted string but with the input string also printed after that?? why is that?? I think that is because the last '\0' is removed and that encoded string lies above the input string so when println prints it does not stop until a \0 in the input string. |
Hi, |
I have not yet solved the problem but you can get into the code and put go to line no 64 where they add a \0 character... if you cange that character you will not be able to print ...because print requires \0 char .. if you remove that and put something else ..it prints a complete decoded string but gets into memory of ther variable... |
Hi @shirish47 In your ino file, try to get your input length by strlen(input). |
hey buddy pls how could I resolve this issue? @e-lin did you solved it? |
@shirish47 I've fixed it. I would rather say this is not the issue of this library but the string length of your input parameter is maybe not correct. |
I also run into some issue with this library because of the last assingment
Then the output result looks like this:
As you can see, the first string doesn't print any more. After several tests I found that the calculation of the encode and decode length doesn’t consider the trailing \0 for the string termination. In order to get correct results, two things in the example code need to be changed:
or use the runtime caclulation
|
I just sent a pull request #23 for a corrected example code. |
the below one is a base64 conversion by library:
eyJldmVudCI6IlVzZXIgUmF0aW5nIiwicHJvcGVydGllcyI6eyJkaXN0aW5jdF9pZCI6IjEzNzkzIiwidG9rZW4iOiJjZDVjOTVlMzZjZTFkZmJjMzE2Mjk1MDFmODQzYTYyNSIsIkRldmljZSI6IjMyMSIsIk1vdmllSUQiOiIzMjEiLCJSYXRpbmciOiIzMjEifX0A
and this one is online based conversion:
eyJldmVudCI6IlVzZXIgUmF0aW5nIiwicHJvcGVydGllcyI6eyJkaXN0aW5jdF9pZCI6IjEzNzkzIiwidG9rZW4iOiJjZDVjOTVlMzZjZTFkZmJjMzE2Mjk1MDFmODQzYTYyNSIsIkRldmljZSI6IjMyMSIsIk1vdmllSUQiOiIzMjEiLCJSYXRpbmciOiIzMjEifX0=
both have one minute difference and that is at the end. I am using this string to upload data to an online service called Mixpanel although both fails but I want to make sure this library is making proper convesion.
The text was updated successfully, but these errors were encountered: