<?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 hash value not found in lookup table (while present) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703640#M215632</link>
    <description>&lt;P&gt;Thanks, did it work for you? My find is still empty, not sure why though:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data find;
set lookup;
where put(ID_ano,$hex64.) eq "5A3558265A673F3F5E2B3F3F3F523308633F463F733F3F3F3F3F183F3F3252";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 04 Dec 2020 14:12:09 GMT</pubDate>
    <dc:creator>SarahDew</dc:creator>
    <dc:date>2020-12-04T14:12:09Z</dc:date>
    <item>
      <title>sha256 hash value not found in lookup table (while present)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703620#M215623</link>
      <description>&lt;P&gt;I need to anonymize some data and decided to use the sha256 function to generate anonymous ID's. I made a lookup table for myself, with the original ID and the hashed ID, and an output table with only the hashed ID for external use. The point is that only I would be able to de-anonymize the data when necessary, and the externals can give me the hash so I can find the match in the lookup table. But now, when I search for one of the hashed ID's in the lookup table, it is not found, while I can see it is there. So I cannot make the match. I replicated this behaviour in a simple example:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID;
datalines;
62851
62852
62853
62854
;
run;

data lookup;
set have;
format ID_ano $hex64.;
ID_ano = sha256(ID);
run;

data out (drop=ID);
set have;
format ID_ano $hex64.;
ID_ano = sha256(ID);
run;

data find;
set lookup;
where strip(ID_ano) eq "5A3558265A673F3F5E2B3F3F3F523308633F463F733F3F3F3F3F183F3F3252";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 13:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703620#M215623</guid>
      <dc:creator>SarahDew</dc:creator>
      <dc:date>2020-12-04T13:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: sha256 hash value not found in lookup table (while present)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703623#M215626</link>
      <description>&lt;P&gt;In the WHERE condition, the raw values is used. Instead of using STRIP (which is dangerous, as the value could contain a leading or trailing '20'x), use PUT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where put(ID_ano,$hex64.) eq "5A3558265A673F3F5E2B3F3F3F523308633F463F733F3F3F3F3F183F3F3252";
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Dec 2020 13:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703623#M215626</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-04T13:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: sha256 hash value not found in lookup table (while present)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703640#M215632</link>
      <description>&lt;P&gt;Thanks, did it work for you? My find is still empty, not sure why though:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data find;
set lookup;
where put(ID_ano,$hex64.) eq "5A3558265A673F3F5E2B3F3F3F523308633F463F733F3F3F3F3F183F3F3252";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Dec 2020 14:12:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703640#M215632</guid>
      <dc:creator>SarahDew</dc:creator>
      <dc:date>2020-12-04T14:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: sha256 hash value not found in lookup table (while present)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703643#M215635</link>
      <description>&lt;P&gt;See this complete code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID;
datalines;
62851
62852
62853
62854
;
run;

data lookup;
set have;
format ID_ano $hex64.;
ID_ano = sha256(ID);
put id_ano;
run;

data out (drop=ID);
set have;
format ID_ano $hex64.;
ID_ano = sha256(ID);
run;

data find;
set lookup;
where put(ID_ano,$hex64.) eq "5A3558265A67E5B4FF5E2B91A28D52330863D846D473A28C82F7D0188CC23252";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Partial log:&lt;/P&gt;
&lt;PRE&gt; 96         data find;
 97         set lookup;
 98         where put(ID_ano,$hex64.) eq "5A3558265A67E5B4FF5E2B91A28D52330863D846D473A28C82F7D0188CC23252";
 99         run;
 
 NOTE: There were 1 observations read from the data set WORK.LOOKUP.
       WHERE PUT(ID_ano, $HEX64.)='5A3558265A67E5B4FF5E2B91A28D52330863D846D473A28C82F7D0188CC23252';
 NOTE: The data set WORK.FIND has 1 observations and 2 variables.
&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Dec 2020 14:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703643#M215635</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-04T14:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: sha256 hash value not found in lookup table (while present)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703649#M215640</link>
      <description>It works, but I see you use a different hash string in the where clause, that I don't see in the lookup or output table. Also the actual ID_ano in find is different from the one you specified. Where did you get this value?&lt;BR /&gt;&lt;BR /&gt;Me: 5A3558265A673F3F5E2B3F3F3F523308633F463F733F3F3F3F3F183F3F3252&lt;BR /&gt;You: 5A3558265A67E5B4FF5E2B91A28D52330863D846D473A28C82F7D0188CC23252</description>
      <pubDate>Fri, 04 Dec 2020 14:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703649#M215640</guid>
      <dc:creator>SarahDew</dc:creator>
      <dc:date>2020-12-04T14:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: sha256 hash value not found in lookup table (while present)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703656#M215644</link>
      <description>&lt;P&gt;I added a PUT statement here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lookup;
set have;
format ID_ano $hex64.;
ID_ano = sha256(ID);
put id_ano;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and copied the string from the log.&lt;/P&gt;
&lt;P&gt;It has been my experience that the display of binary strings across the IOM bridge (if you work with Enterprise Guide) is not always correct, as the binary value might be converted somewhere along the way, and the HEX format is applied after that on the client side. We have had issues with incorrectly displayed UUID's (which are 16 binary bytes).&lt;/P&gt;
&lt;P&gt;The display in the log is always right, as the resulting text is not altered by the IOM bridge.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 15:17:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703656#M215644</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-04T15:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: sha256 hash value not found in lookup table (while present)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703680#M215657</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/244638"&gt;@SarahDew&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s suspicion of a possible character conversion seems very plausible to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/244638"&gt;@SarahDew&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Me: 5A3558265A673F3F5E2B3F3F3F523308633F463F733F3F3F3F3F183F3F3252&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Note that the above hex string looks suspicious in three ways:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;It has length 6&lt;STRONG&gt;2&lt;/STRONG&gt;, hence will &lt;EM&gt;never&lt;/EM&gt; match anything in $HEX6&lt;STRONG&gt;4&lt;/STRONG&gt;. format.&lt;/LI&gt;
&lt;LI&gt;I think a SHA256 digest typically looks like (roughly speaking) a &lt;EM&gt;randomly&lt;/EM&gt;&amp;nbsp;selected string from all possible 32-character strings. Under this assumption I would be very surprised to see a string in which one character occurs &lt;EM&gt;14&lt;/EM&gt; &lt;EM&gt;times&lt;/EM&gt; -- as is the case for '&lt;STRONG&gt;3F&lt;/STRONG&gt;'x in your reported string.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;3F&lt;/STRONG&gt; is the hexadecimal ASCII code of the question mark '&lt;STRONG&gt;?&lt;/STRONG&gt;' -- which, in turn, might be the replacement character if certain other characters cannot be (sort of) "displayed" properly.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 04 Dec 2020 17:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/703680#M215657</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-12-04T17:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: sha256 hash value not found in lookup table (while present)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/704140#M215836</link>
      <description>Thanks, this answers all my questions!&lt;BR /&gt;&lt;BR /&gt;The externals will transfer the dataset to SAS VA (Viya), so I'm not sure how the ID's will be displayed there and if the format will be kept. I will ask them to give me some test ID's to see if I can still make the match using the log.</description>
      <pubDate>Mon, 07 Dec 2020 14:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sha256-hash-value-not-found-in-lookup-table-while-present/m-p/704140#M215836</guid>
      <dc:creator>SarahDew</dc:creator>
      <dc:date>2020-12-07T14:02:10Z</dc:date>
    </item>
  </channel>
</rss>

