Hi All,
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:
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?
I am also making an assumption that the code below is the SAS equivalent of Step 4?
digest = SHA256(concatenated_field_secret) ;
Many thanks in advance, I've tried various attempts but none seem right.
Code so far is (anonymised):
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;
warm regards
Steve
Not too sure what step 2 means, all the characters you have encode the same in ASCII and UTF8.
About step 3, this is how to use base64 encoding:
data TEST;
ENCODE = put('12345abcde',$base64x20.);
DECODE = input(ENCODE,$base64x20.);
run;
About step 4, you probably want to use function HASHING_HMAC.
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?
@SteveNZ - The MD5 function works great for anonymising IDs and we are on 9.4M2. We do something like this:
Client_Key = md5(cats('ClientID', Client_ID)),$hex10.);
SHA256 is safer than MD5.
MD5 vulnerabilities have been discovered, so it is no longer recommended for that cryptography.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.