SHA1 / SHA256 Message Authentication

Post Reply
dfsocha
Newbie
Posts: 9
Joined: Wed Aug 16, 2017 8:51 pm

SHA1 / SHA256 Message Authentication

Post by dfsocha »

Everyone,

I am trying to make a web call to an API end for a online file transfer site that we use (FileGenius). They require all API calls to be signed using your API key and secret. The Secret needs to be hashed using SHA1, which then gets fed into the SHA256 HMAC signature along with a couple other parameters.

I am totally at a loss on where to start on this one. I have tried using the generateSignature function of a ByteArray, but cant seem to get what I want out of it. I suspect that is due to the fact that Switch is encoding the SHA1 hash with ASN.1, and then encrypting the that data.

I just need to get some message hashes.

Any thoughts?

Thanks,

David
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

Re: SHA1 / SHA256 Message Authentication

Post by cstevens »

I had to create my HMAC hash in an external program and call that from Switch. Couldn't find a way in Switch to do it. It might be possible using ByteArray.generateSignature(), but it sounds like that was deprecated in 20017 Update 2.

The lack of true JSON support and HMAC generation is making it difficult to integrate with modern APIs.
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: SHA1 / SHA256 Message Authentication

Post by Padawan »

I think I used openssl as command line tool in the past to do hmac's, but I remember it wasn't simple, I had to work with an intermediate batch file.

cstevens, have you tried Switch 2017, update 2 yet? It now has JSON.stringify() and JSON.Parse()
Post Reply