<?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 wrong values in table in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SHA256-wrong-values-in-table/m-p/705343#M26247</link>
    <description>&lt;P&gt;I did some experiment:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  have;
  a1 = 'A00783126';
run;

data _null_;
  set have;

  h1 = SHA256('A00783126');
  h2 = SHA256(a1);

  length h3 h4 $ 64;

  h3 = SHA256('A00783126');
  h4 = SHA256(a1);

  h5 = HASHING('SHA256', 'A00783126');
  h6 = HASHING('SHA256', a1);

  put 
  h1= $hex64.
  /
  h2= $hex64. 
  /
  h3= $hex64. 
  /
  h4= $hex64.
  /
  h5=
  /
  h6= 
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and the result was:&lt;/P&gt;
&lt;PRE&gt;h1=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h2=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h3=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h4=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h5=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h6=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;Looks fine to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are the data you have proper? Maybe try to add strip() function to remove leading and trailing blanks.&lt;/P&gt;
&lt;P&gt;Additional spaces at the end changes the result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have;

  h1 = SHA256('A00783126');
  h7 = SHA256('A00783126   ');

  put 
  h1= $hex64.
  /
  h7= $hex64.
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;log:&lt;/P&gt;
&lt;PRE&gt;h1=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h7=73BC4975C5E495EF2096E860423C80FC19E1C0805E889F8823CB8917F8FA5541
NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Dec 2020 17:49:55 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2020-12-11T17:49:55Z</dc:date>
    <item>
      <title>SHA256 wrong values in table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SHA256-wrong-values-in-table/m-p/705337#M26246</link>
      <description>&lt;P&gt;Hi All -&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SHA256 function seems to work if I pass it a value directly - output from below is:&lt;/P&gt;&lt;P&gt;43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9&lt;/P&gt;&lt;P&gt;It is 100% correct SHA256 value.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hashingtest;

length hash $ 64;
format hash $hex64.;

set HP_LEADS.lm_leads_details;

hash = SHA256('A00783126');

put hash;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But if I try to SHA256 an entire column of data the values are wrong and in some cases are way short of expected value length - &lt;STRONG&gt;same account number&lt;/STRONG&gt; from columnar results - with code below:&lt;/P&gt;&lt;P&gt;ED9440F53E640CD7588D92160103734E33770E5AA6158C9991B5E558686F5780&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hashingtest;

length hash $ 64;
format hash $hex64.;

set HP_LEADS.lm_leads_details;

hash = SHA256(accountnumber);

put hash;

run&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am not a SAS expert by any means but would appreciate any direction on this one.&lt;/P&gt;&lt;P&gt;I've checked my values at this website&amp;nbsp;&lt;A href="https://passwordsgenerator.net/sha256-hash-generator/" target="_blank"&gt;https://passwordsgenerator.net/sha256-hash-generator/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;And doublecheck results using a Microsoft Access macro (no laughing :-|)&lt;/P&gt;&lt;P&gt;So I'm confident the second code set results are not SHA256.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 17:34:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SHA256-wrong-values-in-table/m-p/705337#M26246</guid>
      <dc:creator>pryan75</dc:creator>
      <dc:date>2020-12-11T17:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: SHA256 wrong values in table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SHA256-wrong-values-in-table/m-p/705343#M26247</link>
      <description>&lt;P&gt;I did some experiment:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  have;
  a1 = 'A00783126';
run;

data _null_;
  set have;

  h1 = SHA256('A00783126');
  h2 = SHA256(a1);

  length h3 h4 $ 64;

  h3 = SHA256('A00783126');
  h4 = SHA256(a1);

  h5 = HASHING('SHA256', 'A00783126');
  h6 = HASHING('SHA256', a1);

  put 
  h1= $hex64.
  /
  h2= $hex64. 
  /
  h3= $hex64. 
  /
  h4= $hex64.
  /
  h5=
  /
  h6= 
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and the result was:&lt;/P&gt;
&lt;PRE&gt;h1=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h2=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h3=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h4=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h5=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h6=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;Looks fine to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are the data you have proper? Maybe try to add strip() function to remove leading and trailing blanks.&lt;/P&gt;
&lt;P&gt;Additional spaces at the end changes the result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have;

  h1 = SHA256('A00783126');
  h7 = SHA256('A00783126   ');

  put 
  h1= $hex64.
  /
  h7= $hex64.
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;log:&lt;/P&gt;
&lt;PRE&gt;h1=43E7361624A78AE87E9F8F36D1E2E88D92C861DFDE61672FA301952A1DE044D9
h7=73BC4975C5E495EF2096E860423C80FC19E1C0805E889F8823CB8917F8FA5541
NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 17:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SHA256-wrong-values-in-table/m-p/705343#M26247</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-12-11T17:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: SHA256 wrong values in table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SHA256-wrong-values-in-table/m-p/705378#M26248</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a tonne - heavily borrowing from you - this works like a charm:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lm_leads_hash;

  set HP_LEADS.lm_leads_details;
 length h1 $ 64;
  h1 = SHA256(strip(accountnumber));

  put 
  h1= $hex64.

  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The results in the log file are perfect - that output table is a mess - but the values have been hashed.&lt;/P&gt;&lt;P&gt;Thanks and have a great weekend!&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 19:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SHA256-wrong-values-in-table/m-p/705378#M26248</guid>
      <dc:creator>pryan75</dc:creator>
      <dc:date>2020-12-11T19:43:15Z</dc:date>
    </item>
  </channel>
</rss>

