<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Decrypt/Decode BASE64 from JSON extract in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342253#M110137</link>
    <description>&lt;P&gt;This code appears to work.....I just tested it and it converted your data into something meaningful &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String body = "ImlkIiwic3VibWl0ZGF0ZSIsImxhc3RwYWdlIiwic3RhcnRsYW5ndWFnZSIsInRva2VuIiwic3RhcnRkYXRlIiwiZGF0ZXN0YW1wIiwiaXBhZGRyIiwicmVmdXJsIiwiQTAxW1NRMDAxXSIsIkEwMiIsIkEwM1tTUTAwMV0iLCJBMDQiLCJBMDUiCiIxIiwiMjAxNS0wNS0xNSAxMToxOTowNCIsIjEiLCJlbiIsIj==";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;byte[] buf = new sun.misc.BASE64Decoder().decodeBuffer(body);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String str = new String(buf, java.nio.charset.StandardCharsets.UTF_8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;System.out.println(str);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You were just missing the code to convert your byte array into a String.&lt;/P&gt;</description>
    <pubDate>Fri, 24 Nov 2017 00:14:34 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-11-24T00:14:34Z</dc:date>
    <item>
      <title>Decrypt/Decode BASE64 from JSON extract</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342252#M110136</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;I am currently busy with a project to retrieve data from a third party website that we use to conduct surveys. The site uses a Remote control panel as an API and from there you can collect the data that you require.&lt;BR /&gt;&lt;BR /&gt;One of the functions is a 'export_responses' call. However, this particular call send the results back as a BASE64 encoded string. I can get the actual response from the JSON feed via XPATH, but I need to decode the BASE64 string to be of actual use.&lt;BR /&gt;&lt;BR /&gt;Any idea on how I can do this?&lt;BR /&gt;&lt;BR /&gt;Currently, after I have used tExtractJSON to get the string I tried;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt; 
&lt;PRE&gt;byte[] buf = new sun.misc.BASE64Decoder().decodeBuffer(row6.Body);
System.out.println("Decrypted survey responses: " + buf);
row7.Body = buf;&lt;/PRE&gt; 
&lt;P&gt;in a tJava component just to see if I can actually see what the responses are. But I get:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt; 
&lt;PRE&gt;Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
	Type mismatch: cannot convert from byte[] to String&lt;/PRE&gt; 
&lt;P&gt;Ok, type mismatch, but what should the input flow then be or how do I need to change the decoding to get the actual info.&lt;BR /&gt;&lt;BR /&gt;The string comes in as: (Only a small portion of the extract is below, adding the full extract gives me a warning that the post should not exceed 20 000 characters, so yeah, a rather large string...)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt; 
&lt;DIV class="lia-spoiler-container"&gt; 
 &lt;A class="lia-spoiler-link" href="#" rel="nofollow noopener noreferrer"&gt;Spoiler&lt;/A&gt; 
 &lt;NOSCRIPT&gt;
   (Highlight to read) 
 &lt;/NOSCRIPT&gt; 
 &lt;DIV class="lia-spoiler-border"&gt; 
  &lt;DIV class="lia-spoiler-content"&gt;
    {"id":1, "result":"ImlkIiwic3VibWl0ZGF0ZSIsImxhc3RwYWdlIiwic3RhcnRsYW5ndWFnZSIsInRva2VuIiwic3RhcnRkYXRlIiwiZGF0ZXN0YW1wIiwiaXBhZGRyIiwicmVmdXJsIiwiQTAxW1NRMDAxXSIsIkEwMiIsIkEwM1tTUTAwMV0iLCJBMDQiLCJBMDUiCiIxIiwiMjAxNS0wNS0xNSAxMToxOTowNCIsIjEiLCJlbiIsIj=", "error":null} 
  &lt;/DIV&gt; 
  &lt;NOSCRIPT&gt; 
   &lt;DIV class="lia-spoiler-noscript-container"&gt; 
    &lt;DIV class="lia-spoiler-noscript-content"&gt;
      {"id":1, "result":"ImlkIiwic3VibWl0ZGF0ZSIsImxhc3RwYWdlIiwic3RhcnRsYW5ndWFnZSIsInRva2VuIiwic3RhcnRkYXRlIiwiZGF0ZXN0YW1wIiwiaXBhZGRyIiwicmVmdXJsIiwiQTAxW1NRMDAxXSIsIkEwMiIsIkEwM1tTUTAwMV0iLCJBMDQiLCJBMDUiCiIxIiwiMjAxNS0wNS0xNSAxMToxOTowNCIsIjEiLCJlbiIsIj=", "error":null} 
    &lt;/DIV&gt; 
   &lt;/DIV&gt; 
  &lt;/NOSCRIPT&gt; 
 &lt;/DIV&gt; 
&lt;/DIV&gt; 
&lt;P&gt;&amp;nbsp;Now from tExtractJSON I can get the response, no issue, but how do I decode this?&lt;BR /&gt;&lt;BR /&gt;(I might be missing something simple, but that is on me and the fact that I have been working on this solid for the past day. A bit of an insomniac hahahah)&lt;/P&gt;</description>
      <pubDate>Thu, 23 Nov 2017 08:21:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342252#M110136</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-23T08:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Decrypt/Decode BASE64 from JSON extract</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342253#M110137</link>
      <description>&lt;P&gt;This code appears to work.....I just tested it and it converted your data into something meaningful &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String body = "ImlkIiwic3VibWl0ZGF0ZSIsImxhc3RwYWdlIiwic3RhcnRsYW5ndWFnZSIsInRva2VuIiwic3RhcnRkYXRlIiwiZGF0ZXN0YW1wIiwiaXBhZGRyIiwicmVmdXJsIiwiQTAxW1NRMDAxXSIsIkEwMiIsIkEwM1tTUTAwMV0iLCJBMDQiLCJBMDUiCiIxIiwiMjAxNS0wNS0xNSAxMToxOTowNCIsIjEiLCJlbiIsIj==";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;byte[] buf = new sun.misc.BASE64Decoder().decodeBuffer(body);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String str = new String(buf, java.nio.charset.StandardCharsets.UTF_8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;System.out.println(str);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You were just missing the code to convert your byte array into a String.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 00:14:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342253#M110137</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-24T00:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Decrypt/Decode BASE64 from JSON extract</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342254#M110138</link>
      <description>&lt;P&gt;Oooi...&lt;BR /&gt;&lt;BR /&gt;Yeah, knew I was missing something...&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MAqO.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/138343i9AC03FA68E7F4E1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MAqO.png" alt="0683p000009MAqO.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks again for the help, much appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 06:20:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342254#M110138</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-24T06:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Decrypt/Decode BASE64 from JSON extract</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342255#M110139</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did the same code, but the file oesn't decode properly, i get an empty pdf &lt;/P&gt;&lt;P&gt;would you help me please &lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 13:41:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342255#M110139</guid>
      <dc:creator>DBLONDEL1643728674</dc:creator>
      <dc:date>2022-01-03T13:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Decrypt/Decode BASE64 from JSON extract</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342256#M110140</link>
      <description>&lt;P&gt;Hi @Damien BLONDEL​&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry about the late reply. I have only just got back from holiday. It appears that there were two problems with the above....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;A final "=" was missing on the encrypted String to be decrypted. This *may* have happened during our migration of posts from one environment to another. I have edited this to correct it.&lt;/LI&gt;&lt;LI&gt;The code involving sun.misc.Base64Decoder() has been deprecated. As such, a slightly different method is required. I have built some replacement code and you can see this below.....&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String body = "ImlkIiwic3VibWl0ZGF0ZSIsImxhc3RwYWdlIiwic3RhcnRsYW5ndWFnZSIsInRva2VuIiwic3RhcnRkYXRlIiwiZGF0ZXN0YW1wIiwiaXBhZGRyIiwicmVmdXJsIiwiQTAxW1NRMDAxXSIsIkEwMiIsIkEwM1tTUTAwMV0iLCJBMDQiLCJBMDUiCiIxIiwiMjAxNS0wNS0xNSAxMToxOTowNCIsIjEiLCJlbiIsIj==";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;java.util.Base64.Decoder decoder = java.util.Base64.getDecoder();&lt;/P&gt;&lt;P&gt;&lt;B&gt;byte&lt;/B&gt;[] buf = decoder.decode(body.getBytes(java.nio.charset.StandardCharsets.UTF_8));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String str = &lt;B&gt;new&lt;/B&gt; String(buf, java.nio.charset.StandardCharsets.UTF_8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;System.out.println(str);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 15:50:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Decrypt-Decode-BASE64-from-JSON-extract/m-p/2342256#M110140</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-01-10T15:50:31Z</dc:date>
    </item>
  </channel>
</rss>

