Picture of mitop
Registered 3 years 291 days
mitop Monday, 16 May 2022, 05:14 PM
Base64 encoding on Javascript Side
Hi all,

on C++ i found this one here:
- https://sdk.innovaphone.com/13r2/common/ilib/base64.htm

What is the Javascript equivalent for this?
(- Perhaps i was blind in my search)

Some background info: I have a C++ App, which will does encode_base64 and post the data. Another app, this time a Javascript Runtime app should be able to do the decode_base64. What i found was the build in functions btoa/atob in Javascript, but it does not work inside myappservice.js file, btoa/atob seems to be undefined.

Is it possible to do the base64 encoding in C++ Backend and to do base64 decode inside a Javascript Backend?


Best regards
Mladen
Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Tuesday, 24 May 2022, 12:19 PM
Re: Base64 encoding on Javascript Side
Hello Mladen,

please refer to the enc and dec properties of the Duktape object, which can be used for the format conversion:



const encoded = Duktape.enc('base64', new TextEncoder("utf-8").encode("hello"));
log(encoded);
const decoded = Duktape.dec('base64', encoded);
log(new TextDecoder("utf-8").decode(decoded));

Best Reagrds
Andreas Fink
Picture of mitop
Registered 3 years 291 days
mitop Tuesday, 24 May 2022, 03:19 PM
Re: Base64 encoding on Javascript Side
Hello Andreas,

thank you very much!


Best regards
Mladen Topic
← You can define your color theme preference here