This is because the output is base64, which is consistent with the signature of hmac:compute
.
I assume that you attempted to use base64:decode -- however, this function converts the actual base64-encoded bits to a string, interpreting them as UTF-8, which is not what you need here.
There are two binary types in JSONiq (they actually come from XML Schema): hexBinary
and base64Binary
. They have the same value space, but use different lexical spaces. The output can be converted to hexBinary
so as to get hexadecimal output like so:
import module namespace hmac = "http://zorba.io/modules/hmac";
hexBinary(hmac:compute("The quick brown fox jumps over the lazy dog", "key" ,"SHA256"))
Zorba then outputs the expected F7BC83F430538424B13298E6AA6FB143EF4D59A14946175997479DBC2D1A3CD8