I'm running the following code using the fcavalieri/zorba docker image. hmac:compute("The quick brown fox jumps over the lazy dog", "key" ,"SHA256") produces: 97yD9DBThCSxMpjmqm+xQ+9NWaFJRhdZl0edvC0aPNg= which when base64 decoded returns garbage rather than the expected f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
Am I using this module correctly?
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):
hexBinaryandbase64Binary. They have the same value space, but use different lexical spaces. The output can be converted tohexBinaryso as to get hexadecimal output like so:Zorba then outputs the expected
F7BC83F430538424B13298E6AA6FB143EF4D59A14946175997479DBC2D1A3CD8