<?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: SHA256  does not generate the same length of encryption? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/474391#M121890</link>
    <description>&lt;P&gt;You should not use md5 at all, see a &lt;A href="https://blogs.sas.com/content/sasdummy/2014/01/18/sha256-function-sas94/" target="_self"&gt;blog-post&lt;/A&gt; by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt; from 2014.&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jun 2018 09:43:10 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2018-06-29T09:43:10Z</dc:date>
    <item>
      <title>SHA256  does not generate the same length of encryption?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/367265#M87415</link>
      <description>&lt;P&gt;I am trying to encrpt a set of IDs using SHA256 in SAS 9.4.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I finished that I found the length of the hash does not always the 64 characters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data B;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length hashID $64;&lt;/P&gt;&lt;P&gt;&amp;nbsp;format hashID $hex64.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;set A;&lt;/P&gt;&lt;P&gt;&amp;nbsp;catxID = catx("XXX", ID, "XXXX");&lt;/P&gt;&lt;P&gt;hashID = sha256(catxID);&lt;/P&gt;&lt;P&gt;drop catxID ID;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;XXX are some random salts.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I examined the hashID, most of them were 64 characters, but some were only 22 characters and some even only contained 6 or 9 or othe number of characters.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone advice whether it is normal or not? and What would result in such variations?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 08:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/367265#M87415</guid>
      <dc:creator>windlove</dc:creator>
      <dc:date>2017-06-15T08:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: SHA256  does not generate the same length of encryption?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/367282#M87419</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/133203"&gt;@windlove&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;SHA256() returns always a 256Bit hash as per documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've done some testing and it appears that what you observe has to do with the table viewer in EG.&lt;/P&gt;
&lt;P&gt;I've used below code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  length hashid1Test $32 l_hashid1Test 8 hashID1 hashID2 $64;
  format hashid1Test $hex64.;

  do id=21 to 21;
    catxID = catx("XXX", ID, "XXXX");
    hashid1Test=sha256(catxID);
    l_hashid1Test=lengthn(hashid1Test);
    hashID1 = put(sha256(catxID),$hex64.);
    hashID2 = sha256hex(catxID);
    output;
  end;

  drop catxID ID;
run;

proc print data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That's what you see in the EG table viewer:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9441i2C91DA2CFEEE89F4/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.JPG" title="Capture.JPG" /&gt;&lt;/P&gt;
&lt;P&gt;Even though variable hashid1Test doesn't show the whole string, it still has a length of 32 characters. The length of 32 indicates that the values as such are still there internally; they just don't print in the data grid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having done a bit more analysis it appears that this always happens for HEX00.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you print the values to an output destination then everything shows up.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9443iC18052A79D6012C3/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.JPG" title="Capture.JPG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So... No serious issue and your data is o.k. It's just a glitch in the EG data grid viewer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 09:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/367282#M87419</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-06-15T09:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: SHA256  does not generate the same length of encryption?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/367336#M87438</link>
      <description>&lt;P&gt;Thanks for the detailed reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I am using EG too.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will check as adviced tomorrow whether those cases with only 6 or 9 characters hold the same story.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 12:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/367336#M87438</guid>
      <dc:creator>windlove</dc:creator>
      <dc:date>2017-06-15T12:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: SHA256  does not generate the same length of encryption?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/474355#M121874</link>
      <description>&lt;P&gt;We encounter similar difficulties with working with digests. Please check if the situation with shorter digest is related to 0x20 bytes (space character) at the end of digest. Similar situation is when you have&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;hashID = md5('a98');
l = length (hashid);
output;
hashID = md5('a99');
l = length (hashid);
output;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First case generates digest with 0x20 at last character and this causes some issues with e.g. length function or further exporting.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 07:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/474355#M121874</guid>
      <dc:creator>Rafall</dc:creator>
      <dc:date>2018-06-29T07:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: SHA256  does not generate the same length of encryption?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/474391#M121890</link>
      <description>&lt;P&gt;You should not use md5 at all, see a &lt;A href="https://blogs.sas.com/content/sasdummy/2014/01/18/sha256-function-sas94/" target="_self"&gt;blog-post&lt;/A&gt; by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt; from 2014.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 09:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SHA256-does-not-generate-the-same-length-of-encryption/m-p/474391#M121890</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-06-29T09:43:10Z</dc:date>
    </item>
  </channel>
</rss>

