recently I have come across several REST-APIs that require a hmac signature in order to authenticate the request.
In short the hmac algorithm combines a message and a secret key to create a hashed signature.
I got an example of an API, which requires a hmac signature. Each request must be signed by a SHA-256 HMAC in base64 encoding.
In the link below they have an example of the inputs and the expected output.
Given the example inputs from the documentation, I wasn´t able to create the expected hmac signature in KNIME.
I tried several different things:
the hmac hashing node. Unfortunately the node gives me a different result (or a different encoding?). (Hmac Hashing – KNIME Community Hub)
Palladan HashCalculator Node. The Node can hash strings with SHA-256, but there is no option to combine it with a secret key. This won’ t work.
the workflow from the following forum post. I updated the message and private key in the code snippet, but the result was again different from the documentation. I´m not a developer, which means the snippet might work only I am unable to complete the code correctly. HashCalculator using given private key and encrytion method
I attached a workflow with the different things I tried. Kaufland_API_HMAC.knwf (16.1 KB)
At this point I´m not sure what else to try. Any pointers or help would be highly appreciated.
I tried a couple different online hashers as well and most of the time I got the expected result from the documentation.
I found a copy paste error in my input data, I copied a aslightly different url into the KNIME workflow.
After I corrected that, I still couldn´t get the same result. I wanted to replicate the results you had with your online hashers and searched for the one you used in your screenshot above. And then I found the issue. When I select Hex as Output Format, I get the result from the documentation. When I select Base64, I get the same result the hmac node generates.
Hi @e2dboden,
sure can check if I can add a hex output as well.
Maybe you could do the transformation directly in knime itself
E.g. string Manipulation or expression node… 100% sure but maybe you could try
I tried to convert between base 64 and hex with standard nodes. I could not find a solution there. The python script @CyberCrimeFlo posted works for me.
@AnotherFraudUser If you happen to update the hmac node in the future and the hex output is not too much of an effort, I think me and other users with no developer background would appreciate a more accesible solution vi the hmac node.