<?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 String to sha-512, base64 in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/String-to-sha-512-base64/m-p/2313734#M84560</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;When trying to connect to an API I have to convert a string to SHA-512. I found a similar question here: &lt;A href="https://community.qlik.com/s/feed/0D53p00007vCmYeCAK" target="_self" rel="nofollow noopener noreferrer"&gt;https://community.talend.com/t5/Design-and-Development/resolved-String-to-SHA-256/td-p/84300&lt;/A&gt;&lt;/P&gt; 
&lt;P&gt;Although I am not used to java coding, I did get that routine working. It seems the routine is not entirely applicable because my output string is different from the output string the API manual says I should have:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The documentation provides this example string:&lt;/P&gt; 
&lt;P&gt;MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOUspRHGNhIMnZ6say4k3swVMfKER8UYbVOREqq7t71VL89bagEFZW4rSjkTcBg7fVZCWX5ijgQVEX4xfV5lapcCAwEAAQ==GET/authefec3dc1-9a99-4825-9e09-3e7772fc205d1456823909&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The documentation says the output string&amp;nbsp;should be:&lt;/P&gt; 
&lt;P&gt;RK+xg4V0hfgKs27ORFA2mVkXhYIX14zRH/f5bl6KqZB8zxJNgDpC6yHVIlN0uPuDXsR0cfdU9jAM1GdG7yzUSg==&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The instruction says: &lt;EM&gt;"When extracting the byte array from the string, UTF8 decoding should be used. The SHA512 hash should be Base64 encoded."&amp;nbsp;&amp;nbsp;&lt;/EM&gt;Probably I need to&amp;nbsp;adjust&amp;nbsp;the routine to decode/encode correctly based on this instruction, I don't know how to&amp;nbsp;apply the necessary changes.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;My question: Does anyone get the output string above, if so, how did you succeed?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thank you&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;EDIT: edited the title and first sentence because it said SHA-256 instead of SHA-512&lt;/P&gt; 
&lt;P&gt;PS: I do see the correct output when testing the string on this page: &lt;A href="http://approsto.com/sha-generator/" target="_self" rel="nofollow noopener noreferrer"&gt;http://approsto.com/sha-generator/&lt;/A&gt;&amp;nbsp;the correct output is show in field '&lt;SPAN&gt;SHA512 base64 hash'&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 09:02:26 GMT</pubDate>
    <dc:creator>hvanderborg</dc:creator>
    <dc:date>2024-11-16T09:02:26Z</dc:date>
    <item>
      <title>String to sha-512, base64</title>
      <link>https://community.qlik.com/t5/Talend-Studio/String-to-sha-512-base64/m-p/2313734#M84560</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;When trying to connect to an API I have to convert a string to SHA-512. I found a similar question here: &lt;A href="https://community.qlik.com/s/feed/0D53p00007vCmYeCAK" target="_self" rel="nofollow noopener noreferrer"&gt;https://community.talend.com/t5/Design-and-Development/resolved-String-to-SHA-256/td-p/84300&lt;/A&gt;&lt;/P&gt; 
&lt;P&gt;Although I am not used to java coding, I did get that routine working. It seems the routine is not entirely applicable because my output string is different from the output string the API manual says I should have:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The documentation provides this example string:&lt;/P&gt; 
&lt;P&gt;MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOUspRHGNhIMnZ6say4k3swVMfKER8UYbVOREqq7t71VL89bagEFZW4rSjkTcBg7fVZCWX5ijgQVEX4xfV5lapcCAwEAAQ==GET/authefec3dc1-9a99-4825-9e09-3e7772fc205d1456823909&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The documentation says the output string&amp;nbsp;should be:&lt;/P&gt; 
&lt;P&gt;RK+xg4V0hfgKs27ORFA2mVkXhYIX14zRH/f5bl6KqZB8zxJNgDpC6yHVIlN0uPuDXsR0cfdU9jAM1GdG7yzUSg==&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The instruction says: &lt;EM&gt;"When extracting the byte array from the string, UTF8 decoding should be used. The SHA512 hash should be Base64 encoded."&amp;nbsp;&amp;nbsp;&lt;/EM&gt;Probably I need to&amp;nbsp;adjust&amp;nbsp;the routine to decode/encode correctly based on this instruction, I don't know how to&amp;nbsp;apply the necessary changes.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;My question: Does anyone get the output string above, if so, how did you succeed?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thank you&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;EDIT: edited the title and first sentence because it said SHA-256 instead of SHA-512&lt;/P&gt; 
&lt;P&gt;PS: I do see the correct output when testing the string on this page: &lt;A href="http://approsto.com/sha-generator/" target="_self" rel="nofollow noopener noreferrer"&gt;http://approsto.com/sha-generator/&lt;/A&gt;&amp;nbsp;the correct output is show in field '&lt;SPAN&gt;SHA512 base64 hash'&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 09:02:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/String-to-sha-512-base64/m-p/2313734#M84560</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2024-11-16T09:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: String to sha-512, base64</title>
      <link>https://community.qlik.com/t5/Talend-Studio/String-to-sha-512-base64/m-p/2313735#M84561</link>
      <description>&lt;P&gt;Update: first I managed to get&amp;nbsp;a hex hash, with this code below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;	public static String getHashCodeFromString(String str) throws NoSuchAlgorithmException {
	    MessageDigest md = MessageDigest.getInstance("SHA-512");
	    md.update(str.getBytes());
	    byte byteData[] = md.digest();

	    //convert the byte to hex format method 1
	    StringBuffer hashCodeBuffer = new StringBuffer();
	    for (int i = 0; i &amp;lt; byteData.length; i++) {
	        hashCodeBuffer.append(Integer.toString((byteData[i] &amp;amp; 0xff) + 0x100, 16).substring(1));
	    }
	    return hashCodeBuffer.toString();
	}&lt;/PRE&gt;
&lt;P&gt;What I needed is base64. I changed the code above, to the final code below, which gave me the expected result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;package routines;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import sun.misc.BASE64Encoder;
public class MyRoutineStringToSHA512test7 {

	public static String getHashCodeFromString(String str) throws NoSuchAlgorithmException {
	    MessageDigest md = MessageDigest.getInstance("SHA-512");
	    md.update(str.getBytes());
	    byte byteData[] = md.digest();

	    String hashCodeBuffer = (new BASE64Encoder()).encode(byteData);
	    return hashCodeBuffer.toString();
	}
}&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Nov 2017 20:47:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/String-to-sha-512-base64/m-p/2313735#M84561</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2017-11-19T20:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: String to sha-512, base64</title>
      <link>https://community.qlik.com/t5/Talend-Studio/String-to-sha-512-base64/m-p/2313736#M84562</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Thanks for posting that you have resolved it by yourself.&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;Sabrina&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 09:45:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/String-to-sha-512-base64/m-p/2313736#M84562</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-13T09:45:25Z</dc:date>
    </item>
  </channel>
</rss>

