base64 encode/decode: btoa() and nodejs Buffer work different way? #705
Unanswered
espruino-discuss
asked this question in
JavaScript
Replies: 2 comments
-
Posted at 2017-03-15 by @gfwilliams The problem is actually with your node.js code :) If you look at what's in your buffer:
You'll see that it's magically turned the string into a 5 byte buffer. Most likely it's because it is interpreting your string as a UTF8 string, when I guess you intended to use it just as a string of bytes. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Posted at 2017-03-15 by Aifer Yes. Thanks a lot.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-03-15 by Aifer
in nodejs terminal:
string is String.fromCharCode(0x00,0x2B,0x20,0xFC) , the base64 string is "ACsgw7w="
and in Espruino Web IDE left-hand terminal:
string is String.fromCharCode(0x00,0x2B,0x20,0xFC) , the base64 string is "ACsg/A=="
Why the same string gets different base64 encoded string in Espruino and nodejs?
Beta Was this translation helpful? Give feedback.
All reactions