<?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: UTF-8 Byte Array and Base64 Decode? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/681510#M206142</link>
    <description>Just checked and the HASHING_MAC  function is available only from 9.4M6 and we're on M4....</description>
    <pubDate>Thu, 03 Sep 2020 21:06:13 GMT</pubDate>
    <dc:creator>SteveNZ</dc:creator>
    <dc:date>2020-09-03T21:06:13Z</dc:date>
    <item>
      <title>UTF-8 Byte Array and Base64 Decode?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/680832#M205855</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To authenticate an API call with a provider we use I need to produce a digest which is proving pretty challenging. The steps to produce are:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN&gt;Concatenate all the fields in the table above in order (the nonce is a UUID)&lt;BR /&gt;fields = client-id + nonce + timestamp-epoch + http-method + http-url&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Produce a UTF-8 byte array of the concatenated string in Step (1)&lt;BR /&gt;fields_bytes = UTF8(fields)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Base-64 decode the supplied ClientSecret&lt;BR /&gt;secret_bytes = Base64Decode(ClientSecret)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Compute HMAC-256 on the string from Step (2) using the signing key from Step (3)&lt;BR /&gt;digest = HMAC256(fields_bytes, secret_bytes)&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;SPAN&gt;I've managed (by much Googling..) to do step one but am at a loss as to how to do steps 2 and 3 in SAS? Has anyone tackled something similar?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am also making an assumption that the code below is the SAS equivalent of Step 4?&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;digest = SHA256(concatenated_field_secret) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Many thanks in advance, I've tried various attempts but none seem right.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Code so far is (anonymised):&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fields (keep =  fields);
	*nonce;
	nonce = UUIDGEN();

	*timestamp-epoch;
	dt = datetime();
	unixEpoch = dhms('01jan1970'd,0,0,0);
	epoch = sum(dt,-unixEpoch);

	*fields;
	fields = catx('+','CLIENT_ID',nonce,epoch,'POST','https://API_PROVIDER/media/search HTTP/1.1');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;warm regards&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 23:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/680832#M205855</guid>
      <dc:creator>SteveNZ</dc:creator>
      <dc:date>2020-09-01T23:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: UTF-8 Byte Array and Base64 Decode?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/680876#M205885</link>
      <description>&lt;P&gt;Not too sure what step 2 means, all the characters you have encode the same in ASCII and UTF8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;About step 3, this is how to use base64 encoding:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST;
  ENCODE = put('12345abcde',$base64x20.);
  DECODE = input(ENCODE,$base64x20.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;About step 4, you probably want to use function&amp;nbsp;&lt;A tabindex="0" title="“HASHING_HMAC Function”" href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1h4xn5mswfh6in125pl83hieb48.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" data-docset-id="lefunctionsref" data-docset-version="9.4" data-original-href="n1h4xn5mswfh6in125pl83hieb48.htm"&gt;HASHING_HMAC&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 06:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/680876#M205885</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-02T06:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: UTF-8 Byte Array and Base64 Decode?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/681505#M206137</link>
      <description>&lt;P&gt;Thanks Chris, really appreciate the response and I'll give your suggestions a try. I have anonymised the post as it had my client specific client-id, is there a way you know of that can encode?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 20:56:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/681505#M206137</guid>
      <dc:creator>SteveNZ</dc:creator>
      <dc:date>2020-09-03T20:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: UTF-8 Byte Array and Base64 Decode?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/681510#M206142</link>
      <description>Just checked and the HASHING_MAC  function is available only from 9.4M6 and we're on M4....</description>
      <pubDate>Thu, 03 Sep 2020 21:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/681510#M206142</guid>
      <dc:creator>SteveNZ</dc:creator>
      <dc:date>2020-09-03T21:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: UTF-8 Byte Array and Base64 Decode?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/681528#M206146</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21489"&gt;@SteveNZ&lt;/a&gt;&amp;nbsp;- The MD5 function works great for anonymising IDs and we are on 9.4M2. We do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Client_Key = md5(cats('ClientID', Client_ID)),$hex10.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Sep 2020 22:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/681528#M206146</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-09-03T22:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: UTF-8 Byte Array and Base64 Decode?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/681539#M206153</link>
      <description>&lt;P&gt;SHA256 is safer than MD5.&lt;/P&gt;
&lt;P&gt;MD5 v&lt;SPAN&gt;ulnerabilities have been discovered, so it is no longer recommended for that cryptography.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 01:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/UTF-8-Byte-Array-and-Base64-Decode/m-p/681539#M206153</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-04T01:09:08Z</dc:date>
    </item>
  </channel>
</rss>

