Is it possible to transform a string into base64 representation?

Hi guys,
Is there a way in KNIME to transform a string into a base64 representation?
I saw that there is a Table to String node from a contributor that transform a whole table into base64 representation but I would need to transform just individual strings. Is this possible?
Thanks in advance.
Gio

It would for sure be possible in a Java Snippet. the bigger question is why you would do / need that? base64 is to convert binary data to a string representation.

Hello,

I’m kind of stuck at the same problem. I need it for a Rest API call, a certain part of a url needs to be in base64.

From “urn:adsk.wipprod:fs.file:vf.EKZOuGboShKXrj24Ezhj4g?version=2” to “dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLkVLWk91R2JvU2hLWHJqMjRFemhqNGc/dmVyc2lvbj0y”. Done with codebeautify.org

I tried to solve it with a R snippet, as seen here, but no sucess.

You could check out this example and see if you could modify it.

5 Likes

Hello @mlauber71, thanks for the reply.

It took some trial and error but I figured it out.

  • How to use the R snippet.
  • How to instal R stuff on the KNIME server.
  • Lots of trial and error. :scream:
2 Likes

Hi , Can you please tell me how did you converted string to base64? as you have already figured out :slightly_smiling_face: The above knime workflow doesn’t work.

Thank you!

See my answer in the other thread:

2 Likes

Strin to Base64_R.knwf (6.2 KB)

Via R snippet:

library(jsonlite)

base64 <- base64_enc(toString(knime.in$"string"))

knime.out <- cbind(knime.in,base64)

It compains when I don’t force it into an R string, no idea. But should work…

5 Likes

There is a component for it:

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.