Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

Problem getting string from encodeHMACSHA256 method

Hi, 

I'm trying to use the encodeHMACSHA256 method, but having some issues.

#setLanguageLevel 3;

Byte[] bytes = encodeHMACSHA256("key", "The quick brown fox jumps over the lazy dog");
String c = String(bytes);
printLine(bytes.length().toString());
printLine(c.getLength().toString());
//printLine(c); //Error, script never finishes...

The key and value in the example above should give the value "f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8" (according to both Wikipedia and an Online-encoder I found).

Thus the code above should also print that value on the last line. However, when I try to print the encoded string the script never completes. It just displays the spinner forever.

Is there a bug here?

RE: Problem getting string from encodeHMACSHA256 method

Hi Frode,

Not exactly sure what the difference is between these methods, but encodeSHA256 method is returning value you are expecting.

printLine(encodeSHA256("key", "The quick brown fox jumps over the lazy dog"));

Von: Michel Krohn-Dale 25. Sep 2019

RE: Problem getting string from encodeHMACSHA256 method

Thanks - I'll use that method instead :)

Von: Frode Lillerud 25. Sep 2019